Boost logo

Boost-Build :

Subject: [Boost-build] Suppress "weak external" exports from Mac OS X executables?
From: Allen Cronce (allenslists_at_[hidden])
Date: 2008-11-24 21:51:06


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

Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk