[Pythonmac-SIG] A -flat_namespace alternative for OS X 10.3

Bob Ippolito bob at redivi.com
Fri Nov 7 15:13:03 EST 2003


It just came to my attention that OS X 10.3 has made Yet Another Change 
To Dyld For The Better Thats Unfortunately Not Backwards Compatible.  I 
imagine we'll be seeing at least one of these every release, continuing 
the trend.  Personally, for 10.4, I'd like to see an equivalent to 
@executable_path for bundles, so that one may embed frameworks inside 
of a plugin bundle.. I'll probably file a radar for that one.

In the man page for ld(1) in OS X 10.3, there is the following new 
addition in the "TWO-LEVEL AND FLAT NAMESPACES" section
        When   creating  a  output  file  with  the  static  link  
editor  when
        -twolevel_namespace is in effect (now the default) all undefined 
refer-
        ences  must be satisfied at static link time.  The flags to 
allow unde-
        fined references, -Usymbol_name, -undefined warning and 
-undefined sup-
        press  can't  be  used.   When  the environment variable 
MACOSX_DEPLOY-
        MENT_TARGET is set to 10.3 then -undefined dynamic_lookup can  
also  be
        used.

and... in the "symbols related" part of the OPTIONS section:

        -undefined treatment
               Specifies how undefined symbols are to  be  treated.   
treatment
               can  be: error, warning, or suppress.  Which cause the 
treatment
               of undefined symbols as either, errors, warnings, or  
suppresses
               the  checking  of  undefined  symbols.   The default is 
to treat
               undefined symbols as  errors.   When  the  environment  
variable
               MACOSX_DEPLOYMENT_TARGET   is   set   to  10.3  then  
-undefined
               dynamic_lookup can also be used to allow any  undefined  
symbols
               to  be  looked up dynamically at runtime.  Use of a 
binary built
               with this flag requires a system with a dynamic linker 
from  Mac
               OS  X  10.3 or later.  The flag -undefined define_a_way 
can also
               be used to cause the static linker to create a  private  
defini-
               tion  for  all undefined symbols.  This flag should only 
be used
               if it is known that the undefined symbols are not 
referenced  as
               any use of them may cause a crash.

What this means to us, is that in situations where -flat_namespace 
-undefined suppress would be used, we can (instead of actually fixing 
the code) use -undefined dynamic_lookup instead if on OS X and 
MACOSX_DEPLOYMENT_TARGET is set.  The primary case for this seems to be 
SWIG, which to this day still loves that stupid -flat_namespace hack.  
I will be using this for any "-flat_namespace" modules in my new 
Panther package, which includes at least PyOpenGL, M2Crypto.

I found this out because yesterday a coworker of mine pointed me to a 
Perl discussion, where (thankfully it wasn't us this time) Apple 
screwed up a Perl configuration file (aptly named Config.pm) that 
effects how Perl extensions are built.  The mixup they made was that 
they set ld to be "MACOSX_DEPLOYMENT_TARGET=10.3; ld -undefined 
dynamic_lookup -bundle ... something.." instead of "env 
MACOSX_DEPLOYMENT_TARGET=10.3; ld -undefined dynamic_lookup -bundle ... 
something ..." .. Oops!  :)  Unfortunately for Perl users and Apple, 
this actually prevents a bunch of the most popular Perl modules from 
building, such as the MySQL DBI bindings!  So, since I had never seen 
dynamic_lookup before, I read the man page.

-bob




More information about the Pythonmac-SIG mailing list