|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Suppress "weak external" exports from Mac OS X executables?Hi all,
We're using boost static libraries in our projects. We've noticed that there are tons of symbol exports in our Mac OS X executables, even after stripping. Here's an excerpt from an "nm -m" command: --snip-- 00008330 (__TEXT,__text) weak external __ZN5boost10filesystem10basic_pathISsNS0_11path_traitsEEdVEPKc 0000c240 (__TEXT,__text) weak external __ZN5boost10filesystem22basic_filesystem_errorINS0_10basic_pathISsNS0_11path_traitsEEEEC2ERKSsRKS4_NS_6system10error_codeE 00009d80 (__TEXT,__text) weak external __ZN5boost10filesystem22basic_filesystem_errorINS0_10basic_pathISsNS0_11path_traitsEEEED0Ev 00009ef0 (__TEXT,__text) weak external __ZN5boost10filesystem22basic_filesystem_errorINS0_10basic_pathISsNS0_11path_traitsEEEED1Ev 0000b340 (__TEXT,__text) weak external __ZN5boost15throw_exceptionINS_10filesystem22basic_filesystem_errorINS1_10basic_pathISsNS1_11path_traitsEEEEEEEvRKT_ 00008540 (__TEXT,__text) weak external __ZN5boost16exception_detail10clone_baseD0Ev --snip-- Note that these are "defined" externals, meaning the code being exported actually exists in the executable section of the binary. I would expect to possibly see exported symbols like this in shared libraries, but not application executables. In some applications, we see hundreds of these exports. I've tried to suppress these symbols by disabling visibility in the boost static libraries, but that hasn't worked. Yes, I'm aware of gcc 4.0 visibility issues with exception handling across shared libraries. But since we're statically linking, we shouldn't see those kind of problems. I suspect that the problem is I'm just not passing the cflags or cxxflags correctly. Either that, or this isn't really a symbol visibility issue. In any case, here's the command line I tried: ./tools/jam/src/bin.macosxx86/bjam debug release toolset=darwin address-model=32 architecture=combined threading=multi link=shared,static macosx-version=10.5 macosx-version-min=10.4 darwin/ cflags=-fvisibility=hidden darwin/cxxflags=-fvisibility=hidden -- layout=system --prefix=/tmp/boostbuild_20081124_142343/32 --exec- prefix=/tmp/boostbuild_20081124_142343/32 --builddir=../../../ buildProductsMac/boost install Thanks in advance for any suggestions regarding eliminating these symbol exports. Best, -- Allen Cronce _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build |
|
|
Re: Suppress "weak external" exports from Mac OS X executables?Hi Allen !
An'n Dienstag 25 November 2008 hett Allen Cronce schreven: > I suspect that the problem is I'm just not passing the cflags or > cxxflags correctly. Most probably. > Either that, or this isn't really a symbol > visibility issue. > > In any case, here's the command line I tried: > > ./tools/jam/src/bin.macosxx86/bjam debug release toolset=darwin > address-model=32 architecture=combined threading=multi > link=shared,static macosx-version=10.5 macosx-version-min=10.4 darwin/ > cflags=-fvisibility=hidden darwin/cxxflags=-fvisibility=hidden -- 1. simply use cxxflags= , not darwin/cxxflags 2. Use quotes around -fvisibility=hidden else bjam will split again at "=" something like cxxflags=" -fvisibility=hidden" should work. > layout=system --prefix=/tmp/boostbuild_20081124_142343/32 --exec- > prefix=/tmp/boostbuild_20081124_142343/32 --builddir=../../../ > buildProductsMac/boost install add -d+2 or use -n to see the resulting command line. Check this for your flags. > Thanks in advance for any suggestions regarding eliminating these > symbol exports. Please post the resulting command line next time. Yours, Jürgen -- * Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für * voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH * fax : ++49 511 262926 99 ! Lister Straße 15 * juergen.hunold@... ! www.ivembh.de * * Geschäftsführer: ! Sitz des Unternehmens: Hannover * Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965 * PD Dr.-Ing. Alfons Radtke ! _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build |
|
|
Re: Suppress "weak external" exports from Mac OS X executables?Hi Jürgen,
Thanks for getting back to me so quickly. Using your suggestions I was able to successfully pass the required flags on the command line. Sure enough, specifying visibility as hidden disabled the symbol exports in our applications. In addition to being cleaner, this also reduces the size of the binaries. In one case, I saw a reduction of 22k bytes. For posterity, here's the build command line that worked: ./tools/jam/src/bin.macosxx86/bjam -d+2 debug release toolset=darwin address-model=32 architecture=combined threading=multi link=static macosx-version=10.5 macosx-version-min=10.4 cflags="- fvisibility=hidden -arch x86_64 -arch ppc64" cxxflags="- fvisibility=hidden -arch x86_64 -arch ppc64" --layout=system --prefix=/ tmp/boostbuild_20081124_142343/32 --exec-prefix=/tmp/ boostbuild_20081124_142343/32 --build-dir=../../../buildProductsMac/ boost install This results in the correct g++ command lines being generated. Here's a sample: "g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline - Wall -mmacosx-version-min=10.4 -no-cpp-precomp -gdwarf-2 -Wno-long- double -isysroot /Developer/SDKs/MacOSX10.5.sdk -arch i386 -arch ppc - fvisibility=hidden -arch x86_64 -arch ppc64 -fvisibility=hidden -arch x86_64 -arch ppc64 -DBOOST_ALL_NO_LIB=1 -DNDEBUG -I"." -c -o "../../../buildProductsMac/boost/boost/bin.v2/libs/math/build/ darwin-4.0.1/release/address-model-32/architecture-combined/link- static/macosx-version-min-10.4/macosx-version-10.5/threading-multi/ hypot.o" "libs/math/build/../src/tr1/hypot.cpp" Although because I'm specifying both cflags and cxxflags, I'm seeing two copies of my options on the command line. I guess I should just specify cflags instead of both. As an aside, once I learned how to pass cflags correctly, I was able to add 64 bit architectures to the existing 32 bit ones specified via the "address-model" option. This allowed me to build quad binaries in one pass. Previously our script would build the 32 bit and 64 bit binaries separately, then stitch them together with lipo. Anyway, things look good now. Thanks again for your help Jürgen. Best, -- Allen Cronce On Nov 25, 2008, at 5:24 AM, Jürgen Hunold wrote: > Hi Allen ! > > An'n Dienstag 25 November 2008 hett Allen Cronce schreven: > >> I suspect that the problem is I'm just not passing the cflags or >> cxxflags correctly. > > Most probably. > >> Either that, or this isn't really a symbol >> visibility issue. >> >> In any case, here's the command line I tried: >> >> ./tools/jam/src/bin.macosxx86/bjam debug release toolset=darwin >> address-model=32 architecture=combined threading=multi >> link=shared,static macosx-version=10.5 macosx-version-min=10.4 >> darwin/ >> cflags=-fvisibility=hidden darwin/cxxflags=-fvisibility=hidden -- > > 1. simply use cxxflags= , not darwin/cxxflags > 2. Use quotes around -fvisibility=hidden else bjam will split again > at "=" > > something like cxxflags=" -fvisibility=hidden" should work. > >> layout=system --prefix=/tmp/boostbuild_20081124_142343/32 --exec- >> prefix=/tmp/boostbuild_20081124_142343/32 --builddir=../../../ >> buildProductsMac/boost install > > add -d+2 or use -n to see the resulting command line. Check this for > your > flags. > >> Thanks in advance for any suggestions regarding eliminating these >> symbol exports. > > Please post the resulting command line next time. > > Yours, > > Jürgen > > -- > * Dipl.-Math. Jürgen Hunold ! Ingenieurgesellschaft für > * voice: ++49 511 262926 57 ! Verkehrs- und Eisenbahnwesen mbH > * fax : ++49 511 262926 99 ! Lister Straße 15 > * juergen.hunold@... ! www.ivembh.de > * > * Geschäftsführer: ! Sitz des Unternehmens: Hannover > * Prof. Dr.-Ing. Thomas Siefer ! Amtsgericht Hannover, HRB 56965 > * PD Dr.-Ing. Alfons Radtke ! > _______________________________________________ > Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost-build |
| Free Forum Powered by Nabble | Forum Help |