Subject: pkg/32697: Buildlink 3 causes build failures under Mac OS X
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Matthias Scheler <tron@zhadum.org.uk>
List: pkgsrc-bugs
Date: 02/02/2006 11:10:01
>Number:         32697
>Category:       pkg
>Synopsis:       Buildlink 3 causes build failures under Mac OS X
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 02 11:10:01 +0000 2006
>Originator:     tron@zhadum.org.uk
>Release:        Darwin 8.4.0
>Organization:
Matthias Scheler                                  http://scheler.de/~matthias/
>Environment:
System: Darwin excalibur.zhadum.org.uk 8.4.0 Darwin Kernel Version 8.4.0: Tue Jan  3 18:22:10 PST 2006; root:xnu-792.6.56.obj~1/RELEASE_PPC Power Macintosh powerpc
Architecture: powerpc
Machine: Power Macintosh
>Description:
Building "nas" under Mac OS X dies during the "configure" target:

checking build system type... powerpc-apple-darwin8.4.0
checking host system type... powerpc-apple-darwin8.4.0
checking for gcc... /usr/bin/cc
checking for C compiler default output... a.out
checking whether the C compiler works... configure: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.

The reason is that the empty program it just compiled, linked and started
crashed with a "Bus error". Careful investigation revealed that buildlink 3
is at fault here. The compiler invokes the linker "ld" like this:

ld -dynamic -arch ppc -weak_reference_mismatches non-weak -o a.out -lcrt1.o ...

"crt1.o" is the object file with the startup code which must be at the
beginning of the binary. Unfortunately buildlink 3 changes the link
order like this:

ld -dynamic -arch ppc -weak_reference_mismatches non-weak -o a.out ... -lcrt1.o ...

The startup code is therefore now longer at the beginning of the executable
and the program cashes when it is executed.

>How-To-Repeat:
cd pkgsrc/audio/nas
bmake

>Fix:
Teach "pkgsrc/mk/wrapper/cmd-sink-ld" to leave "-lcrt1.o" as the first
"library" which gets linked.