Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: saveFP, restFP



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dallman, John wrote:
| I'm starting work on moving some code up from Mac OX X 10.3
| and XCode 1.1's GCC 3.3 to Mac OS X 10.4 and XCode 2.2's
| GCC 4.0.1. I'm not building in the XCode IDE; I'm calling
| GCC and ld from shell scripts for reasons that are long and
| complex and utterly unchangeable. The code is all C, with
| no Objective-C or C++.
|
| I found, somewhat to my surprise, that GCC doesn't generate
| calls to saveFP and restFP at -O3, but does at -O1 and -O2.
| In GCC 4.0.1, those routines are supplied by libgcc_static.a
| in /usr/lib/gcc/powerpc-apple-darwin8/4.0.1, and when gcc
| is driving ld itself, it includes that archive library
| without any fuss.
|
| However, that doesn't happen when I use ld to build a dylib.
| That's fair enough in many ways: libgcc_static.a is clearly
| quite tightly bound to that particular version of GCC. But
| embedding the explicit path
|
|   /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/libgcc_static.a
|
| in my link script is not really attractive; it's the kind of
| thing that could easily be forgotten when one upgrades to a
| later GCC in a year's time. I'm using ld to build a dylib
| because I couldn't find a satisfactory way to do it with
| gcc or libtool. Here's the command line:
|
| $export="/path/to/text/file/with/symbols/to/be/exported"
| $archive="/path/to/archive/library/with/all/our/code/for/the/dylib"
|
| ld -dylib -flat_namespace -single_module 				\
|    -dylib_compatibility_version 17.1				\
|    -headerpad_max_install_names					\
|    -exported_symbols_list $export /usr/lib/dylib1.o		\
|    -lSystem -lSystemStubs						\
|    /usr/lib/gcc/powerpc-apple-darwin8/4.0.1/libgcc_static.a \
|    -o name.dylib

Use the compiler driver to link, replace gcc with g++ if linking c++ code.

gcc -dynamiclib -flat_namespace -Wl,-single_module \
- -compatibility_version 17.1 -current_version 17.1 \
- -Wl,-headerpad_max_install_names \
- -exported_symbols_list $export -o name.dylib

Peter

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)

iQCVAwUBQ6AWb7iDAg3OZTLPAQIWlAQAi6teMn5SUxbS5T/RdSzgKRaseZXb6HwX
sCj9JPOp+DhwHDFOJIesMMTylWLgD6v2tYx2G7eHn4b+Q6ABr1+9vi8vEg1p0BVO
b5VjG2LG43N7nvkB1Rmee7+Chw1gG3a8ylMQ/7squXIsEUOE+BPGM4PT+XMJ/R9H
aQXd5OiQPyQ=
=Q/hX
-----END PGP SIGNATURE-----
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Unix-porting mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/unix-porting/email@hidden

This email sent to email@hidden
References: 
 >saveFP, restFP (From: "Dallman, John" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.