Linux.3 in makedefs & Ubuntu12

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Linux.3 in makedefs & Ubuntu12

Quanah Gibson-Mount-3
I'm testing the ubuntu12 64-bit beta, and had to make the following change
to makedefs under the Linux.3 category.  Just FYI:

--- postfix-2.9.1.2z/makedefs.orig      2012-01-17 17:19:48.000000000 -0800
+++ postfix-2.9.1.2z/makedefs   2012-03-28 16:43:26.154076634 -0700
@@ -367,7 +373,7 @@
             SYSLIBS="-ldb"
             for name in nsl resolv
             do
-                for lib in /usr/lib64 /lib64 /usr/lib /lib
+                for lib in /usr/lib64 /lib64 /usr/lib /lib
/usr/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu
                 do
                test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
                    SYSLIBS="$SYSLIBS -l$name"



Apparently, Ubuntu/Debian put some of the libraries in an architecture
specific directory now (x86_64-linux-gnu).  I hit this for libnsl.

--Quanah

--

Quanah Gibson-Mount
Sr. Member of Technical Staff
Zimbra, Inc
A Division of VMware, Inc.
--------------------
Zimbra ::  the leader in open source messaging and collaboration
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Scott Kitterman-4


Quanah Gibson-Mount <[hidden email]> wrote:

>I'm testing the ubuntu12 64-bit beta, and had to make the following
>change
>to makedefs under the Linux.3 category.  Just FYI:
>
>--- postfix-2.9.1.2z/makedefs.orig      2012-01-17 17:19:48.000000000
>-0800
>+++ postfix-2.9.1.2z/makedefs   2012-03-28 16:43:26.154076634 -0700
>@@ -367,7 +373,7 @@
>             SYSLIBS="-ldb"
>             for name in nsl resolv
>             do
>-                for lib in /usr/lib64 /lib64 /usr/lib /lib
>+                for lib in /usr/lib64 /lib64 /usr/lib /lib
>/usr/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu
>                 do
>                test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
>                    SYSLIBS="$SYSLIBS -l$name"
>
>
>
>Apparently, Ubuntu/Debian put some of the libraries in an architecture
>specific directory now (x86_64-linux-gnu).  I hit this for libnsl.

wiki.debian.org/Multiarch

Scott K

Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Wietse Venema
In reply to this post by Quanah Gibson-Mount-3
Quanah Gibson-Mount:

> I'm testing the ubuntu12 64-bit beta, and had to make the following change
> to makedefs under the Linux.3 category.  Just FYI:
>
> --- postfix-2.9.1.2z/makedefs.orig      2012-01-17 17:19:48.000000000 -0800
> +++ postfix-2.9.1.2z/makedefs   2012-03-28 16:43:26.154076634 -0700
> @@ -367,7 +373,7 @@
>              SYSLIBS="-ldb"
>              for name in nsl resolv
>              do
> -                for lib in /usr/lib64 /lib64 /usr/lib /lib
> +                for lib in /usr/lib64 /lib64 /usr/lib /lib
> /usr/lib/x86_64-linux-gnu /lib/x86_64-linux-gnu

Perhaps you can suggest a way for makedefs to parse out the CPU
type from "uname -whatever" and use that in the library search?

The reason I ask this is that it makes little sense to hard-code
all possible architecture names in this script.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Michael Tokarev
On 29.03.2012 22:23, Wietse Venema wrote:
[]
> Perhaps you can suggest a way for makedefs to parse out the CPU
> type from "uname -whatever" and use that in the library search?

This isn't about uname.  Uname may return one thing, yet postfix
may be building for entirely another -- that's the main motivation
behind multiarch.

There, the only reasonable thing to do is to try to link an
executable - _provided_ that we need to actually verify the
two libs in question.

But on any modern linux system - and I really mean this, since
stuff for libc5 (pre-glibc linux) isn't interesting anymore
except of for some historical reasons, and other implementations
of libc on linux (uclibc, dietlibc) have -lnsl -lresolv.

So the best fix for this stuff is - in my opinion anyway -
just assume that -lnsl -lresolv is always there and add it
unconditionally on linux2 or linux3.

Note again that linux _kernel_ version has very little to
do with C library features present.

Besides, gcc --print-search-dirs (as already used in makedefs)
includes all necessary multiarch directories already.  So
I'm not really sure why the OP have this problem to start
with.  Here's the content of SEARCHDIRS variable from
makedefs script on my 32bit system:

 /lib /lib/i386-linux-gnu /usr/lib /usr/lib/i386-linux-gnu

and here's how it looks like when setting CC="gcc -m64" before
invoking makedefs:

 /lib /lib64 /lib/x86_64-linux-gnu /usr/lib /usr/lib64 /usr/lib/x86_64-linux-gnu

> The reason I ask this is that it makes little sense to hard-code
> all possible architecture names in this script.

That'd be wrong, because some of these libs wont work on current
arch directly anyway, and may be unrelated to the postfix build.

Thanks,

/mjt
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Quanah Gibson-Mount-3
--On Thursday, March 29, 2012 10:56 PM +0400 Michael Tokarev
<[hidden email]> wrote:

> Besides, gcc --print-search-dirs (as already used in makedefs)
> includes all necessary multiarch directories already.  So
> I'm not really sure why the OP have this problem to start
> with.  Here's the content of SEARCHDIRS variable from
> makedefs script on my 32bit system:

If postfix doesn't find nsl or resolv in the directories in that list, it
won't add them to the library list.  Thus the build fails.

--Quanah

--

Quanah Gibson-Mount
Sr. Member of Technical Staff
Zimbra, Inc
A Division of VMware, Inc.
--------------------
Zimbra ::  the leader in open source messaging and collaboration
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

John Peach-2
On Thu, 29 Mar 2012 12:10:26 -0700
Quanah Gibson-Mount <[hidden email]> wrote:

> --On Thursday, March 29, 2012 10:56 PM +0400 Michael Tokarev
> <[hidden email]> wrote:
>
> > Besides, gcc --print-search-dirs (as already used in makedefs)
> > includes all necessary multiarch directories already.  So
> > I'm not really sure why the OP have this problem to start
> > with.  Here's the content of SEARCHDIRS variable from
> > makedefs script on my 32bit system:
>
> If postfix doesn't find nsl or resolv in the directories in that
> list, it won't add them to the library list.  Thus the build fails.
>
> --Quanah
>
> --
>
> Quanah Gibson-Mount
> Sr. Member of Technical Staff
> Zimbra, Inc
> A Division of VMware, Inc.
> --------------------
> Zimbra ::  the leader in open source messaging and collaboration


My Ubuntu Precise box has the following in in /etc/ld.so.conf which
will pick up those directories:

cat /etc/ld.so.conf
include /etc/ld.so.conf.d/*.conf

cat /etc/ld.so.conf.d/*.conf
# Multiarch support
/lib/i386-linux-gnu
/usr/lib/i386-linux-gnu
/lib/i686-linux-gnu
/usr/lib/i686-linux-gnu
# libc default configuration
/usr/local/lib
/usr/lib/nvidia-settings
# Multiarch support
/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu
/usr/lib/nvidia-current
/usr/lib32/nvidia-current
# Legacy biarch compatibility support
/lib32
/usr/lib32
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Michael Tokarev
In reply to this post by Quanah Gibson-Mount-3
On 29.03.2012 23:10, Quanah Gibson-Mount wrote:
> --On Thursday, March 29, 2012 10:56 PM +0400 Michael Tokarev <[hidden email]> wrote:
>
>> Besides, gcc --print-search-dirs (as already used in makedefs)
>> includes all necessary multiarch directories already.  So
>> I'm not really sure why the OP have this problem to start
>> with.  Here's the content of SEARCHDIRS variable from
>> makedefs script on my 32bit system:
>
> If postfix doesn't find nsl or resolv in the directories in that list, it won't add them to the library list.  Thus the build fails.

Oh.  The code I was referring to has been removed in
postfix 2.9.  The fragment from postfix-2.8.7:

                SEARCHDIRS=$(${CC-gcc} -print-search-dirs 2>/dev/null |
                        sed -n '/^libraries: =/s/libraries: =//p' |
                        sed -e 's/:/\n/g' | xargs -n1 readlink -f |
                        grep -v 'gcc\|/[0-9.]\+$' | sort -u)
                if [ -z "$SEARCHDIRS" ]; then
                        SEARCHDIRS="/usr/lib64 /lib64 /usr/lib /lib"
                fi
                for name in nsl resolv $GDBM_LIBS
                do
                    for lib in $SEARCHDIRS
                    do
                        test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
                            SYSLIBS="$SYSLIBS -l$name"
                            break
                        }
                    done
                done

The same fragment from postfix-2.9.1:

                for name in nsl resolv $GDBM_LIBS
                do
                    for lib in /usr/lib64 /lib64 /usr/lib /lib
                    do
                        test -e $lib/lib$name.a -o -e $lib/lib$name.so && {
                            SYSLIBS="$SYSLIBS -l$name"
                            break
                        }
                    done
                done


I don't know why this has been changed in 2.9, seems to
be a regression.

But at any case, the whole test appears to be wrong for
a long time already.  -lnsl -lresolv should be used
unconditionally for linux2 and linux3.

Thanks,

/mjt
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Wietse Venema
In reply to this post by Michael Tokarev
Michael Tokarev:
[ Charset ISO-8859-1 unsupported, converting... ]
> On 29.03.2012 22:23, Wietse Venema wrote:
> []
> > Perhaps you can suggest a way for makedefs to parse out the CPU
> > type from "uname -whatever" and use that in the library search?
>
> This isn't about uname.  Uname may return one thing, yet postfix
> may be building for entirely another -- that's the main motivation
> behind multiarch.

The makedefs script assumes Postfix is built for the current
architecture. It needs command-line overrides to cross-compile
(at least that't the version I am working with).

> So the best fix for this stuff is - in my opinion anyway -
> just assume that -lnsl -lresolv is always there and add it
> unconditionally on linux2 or linux3.

That may well be the simplest solution.

> .  Here's the content of SEARCHDIRS variable from
> makedefs script on my 32bit system:

Hmm, I see no SEARCHDIRS in my makedefs files. What does yours
look like?

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Michael Tokarev
In reply to this post by John Peach-2
On 29.03.2012 23:23, John Peach wrote:

> My Ubuntu Precise box has the following in in /etc/ld.so.conf which
> will pick up those directories:

You can install libraries for other architectures - sparc, mipsel,
etc - and the corresponding dirs will be added to the list.  Yes
even if you're on x86, you can run sparc executables still in means
of qemu for example - it will register as binfmt-misc handler which
is able to run foreign code, for which corresponding foreign libraries
are needed.

Note yet again: hardcoding various i686/i386/x86_64/etc paths is
wrong, the world is FAR from being x86-only.

/mjt
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Wietse Venema
In reply to this post by Michael Tokarev
Michael Tokarev:
>                 SEARCHDIRS=$(${CC-gcc} -print-search-dirs 2>/dev/null |
>                         sed -n '/^libraries: =/s/libraries: =//p' |
>                         sed -e 's/:/\n/g' | xargs -n1 readlink -f |
>                         grep -v 'gcc\|/[0-9.]\+$' | sort -u)
>                 if [ -z "$SEARCHDIRS" ]; then
>                         SEARCHDIRS="/usr/lib64 /lib64 /usr/lib /lib"
>                 fi

You won't find this in the makedefs files from postfix.org mirrors.
I suppose this was added by a Linux distribution maintainer.

        Wietse
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Michael Tokarev
On 29.03.2012 23:32, Wietse Venema wrote:

> Michael Tokarev:
>>                 SEARCHDIRS=$(${CC-gcc} -print-search-dirs 2>/dev/null |
>>                         sed -n '/^libraries: =/s/libraries: =//p' |
>>                         sed -e 's/:/\n/g' | xargs -n1 readlink -f |
>>                         grep -v 'gcc\|/[0-9.]\+$' | sort -u)
>>                 if [ -z "$SEARCHDIRS" ]; then
>>                         SEARCHDIRS="/usr/lib64 /lib64 /usr/lib /lib"
>>                 fi
>
> You won't find this in the makedefs files from postfix.org mirrors.
> I suppose this was added by a Linux distribution maintainer.

Most likely by Debian maintainer, LaMont Jones.  Indeed, there's
no such code in official postfix.  But this snipped can be used
there just fine.

But I still think the best is to enable -lnsl -lresolv unconditionally,
as these libs are linked into postfix on linux for about 15 years
already anyway...

/mjt
Reply | Threaded
Open this post in threaded view
|

Re: Linux.3 in makedefs & Ubuntu12

Michael Tokarev
In reply to this post by Wietse Venema
On 29.03.2012 23:29, Wietse Venema wrote:

> Michael Tokarev:
>> On 29.03.2012 22:23, Wietse Venema wrote:
>> []
>>> Perhaps you can suggest a way for makedefs to parse out the CPU
>>> type from "uname -whatever" and use that in the library search?
>>
>> This isn't about uname.  Uname may return one thing, yet postfix
>> may be building for entirely another -- that's the main motivation
>> behind multiarch.
>
> The makedefs script assumes Postfix is built for the current
> architecture. It needs command-line overrides to cross-compile
> (at least that't the version I am working with).

It is possible to override $CC and $LD -- this should be
enough for cross-compilation already.

Note that the resulting binaries - even being foreign to the host
architecture - may actually work just fine, using some emulator
layer like qemu-user (www.qemu.org).  So even build system tries
to run executables it just built, the build process may complete
successfully.

Thanks,

/mjt