Re: Leopard SDK 10.4 strange phenomena libc
Re: Leopard SDK 10.4 strange phenomena libc
- Subject: Re: Leopard SDK 10.4 strange phenomena libc
- From: Terry Lambert <email@hidden>
- Date: Wed, 31 Oct 2007 14:47:59 -0700
You need to read <sys/cdefs.h>, specifically the section I put in
there about compilation environments. Or you need to read the Leopard
developer release notes. Or both.
On Oct 31, 2007, at 1:47 PM, mm w wrote:
$ gcc -mmacosx-version-min=10.4 -fPIC -c src/bundle.c -arch i686
-arch ppc -ansi -Wall -O2 -o build/bundle.o
$ nm build/bundle.o
00000000 T _init
U _system
You say: -mmacosx-version-min=10.4
Compiler hears: "Hi, I want the legacy compilation environment, rather
than a fully UNIX conformant environment."
$ gcc -c src/bundle.c -arch i686 -arch ppc -ansi -Wall -O2 -o build/
bundle.o
$ nm build/bundle.o
00000000 T _init
U _system$UNIX2003
You say:
Compiler hears: "Hi, I want the default compilation environment for
MacOS X 10.5, which is the UNIX conformant compilation environment"
AFAIK... everything is going well
in fact, i was in the same case with a bigger project, but i got an
error from ld:
$ gcc -c src/obj.c -arch i686 -arch ppc -ansi -Wall -O2 -o build/obj.o
$ gcc -bundle build/obj.o -o build/obj.so -mmacosx-version-min=10.4
-arch i686 -arch ppc -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk
-framework CoreFoundation
Undefined symbols for architecture i386:
"_system$UNIX2003", referenced from:
_method in obj.o
....
You say: -mmacosx-version-min=10.4
Linker hears: "Hi, I want to link against the 10.4 legacy libraries,
even though I may have imported symbols that only exist in the 10.5
libraries; if that happened, can you please give me a link error?"
This happens because an SDK includes headers, libraries, and so on,
and you've asked it to link against the Tiger libraries.
[ ... ]
Does this make any sense to you?
Yes. Functions which change behaviour because of UNIX conformance
have symbol decorations that get attached to them as a result of which
compilation environment you are using. You can mix compilation
environments, as long as you only use symbols that were also supported
in Tiger because of the UNIX conformance work that had been done
before Tiger shipped (several of us have been working on UNIX
conformance since November 2004 - it was a *very* big project, with
not a lot of people on it full time).
This is similar to the situation where we added 128 bit long double
support to Tiger, and as a result, we decorated functions which had to
know the size of long double (such as "printf") with $LDBL128 or
$LDBL64, and provided weak symbols for legacy applications that didn't
know about the decorations. For example, printf:
% nm /usr/lib/libc.dylib | grep "T _printf"
0006efcc T _printf
00115be4 T _printf$LDBL128
000cb720 T _printf$LDBL64
-
Bottom line is that you should try to use the same compilation
environment for all your code.
Basically, pick an SDK you want to target, and target it across all
your compilation units and linkages.
-- Terry
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden