helpGNU Libtool - Support: sr #105489, --whole-archive doesn't work on OSX

 
 

sr #105489: --whole-archive doesn't work on OSX

Submitted by:  None
Submitted on:  Wed 02 Aug 2006 01:21:12 AM UTC  
 
Category: NonePriority: 5 - Normal
Severity: 3 - NormalStatus: None
Privacy: PublicAssigned to: None
Originator Email: -unavailable-Open/Closed: Open
Operating System: Mac OS

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 05 Aug 2006 12:20:14 PM UTC, comment #2:

-noall_load is a flag that is accepted by /usr/bin/libtool (Apple's libtool) on Mac OS X/Darwin systems. It can not be specified as well as -all_load, it is the default, and there seems to be no good reason to specify it. It is also documented in libtool(1)'s man page:

-noall_load
For dynamic shared library files this specifies the the default
behavior of loading all members of archives on the command line
is not to be done. This option is used by the GNU compiler
driver, cc(1), when used with it's -dynamiclib option. This is
done to allow selective loading of the GNU's compiler's runtime
support library, libcc_dynamic.a .

Note that this flag is not accepted by either ld or ld64.

Peter O'Gorman <pogma>
Project Member
Fri 04 Aug 2006 07:41:22 PM UTC, comment #1:

Mac OS/X does have a way to turn off the all_load option. The (undocumented) option is -noall_load. I have this from Apple compiler developers.

Anonymous
Wed 02 Aug 2006 01:21:12 AM UTC, original submission:

(apologies if this is the wrong place to file bugs, I could find the bugtracker).

This bug tested on:
Darwin bioeng21.bioeng.auckland.ac.nz 8.7.0 Darwin Kernel Version 8.7.0: Fri May 26 15:20:53 PDT 2006; root:xnu-792.6.76.obj~1/RELEASE_PPC Power Macintosh powerpc

It seems that recent versions of libtool don't support the --whole-archive on MacOSX. This causes the --whole-archive flag to be passed to gcc (which seems to be silently ignored on OSX), resulting in a link which doesn't really contain the whole archive.
For example:

/bin/sh ./libtool --tag=CXX --mode=link g++ -g -O2 -o cellml_corba_server -lxml2 -lomniORB4 -lomnithread --whole-archive cellml_corba_server-Main.o ./libcellml_context.la ./libcellml_context_corba.la ./libcellml.la ./libcellml_corba.la ./libCORBASupport.la ./libltdlc.la
g++ -g -O2 -o .libs/cellml_corba_server --whole-archive cellml_corba_server-Main.o -Wl,-bind_at_load /usr/lib/libxml2.dylib -lpthread -lz /usr/lib/libiconv.dylib -lm -lomniORB4 -lomnithread ./.libs/libcellml_context.dylib ./.libs/libcellml_context_corba.dylib ./.libs/libcellml.dylib ./.libs/libcellml_corba.dylib ./.libs/libCORBASupport.a ./.libs/libltdlc.a
creating cellml_corba_server

bioeng21:~/physiome_builds/trees/CellML_DOM_API_OSX cmiss$ nm .libs/cellml_corba_server |grep gWrapperRepo
bioeng21:~/physiome_builds/trees/CellML_DOM_API_OSX cmiss$ nm .libs/libCORBASupport.a |grep gWrapperRepo
000000ac t __GLOBAL__D__Z18gWrapperRepositoryv

                1. a __GLOBAL__D__Z18gWrapperRepositoryv.eh

0000009c t __GLOBAL__I__Z18gWrapperRepositoryv

                1. a __GLOBAL__I__Z18gWrapperRepositoryv.eh

00000190 T __Z18gWrapperRepositoryv
00001820 S __Z18gWrapperRepositoryv.eh
00001a58 b __ZGVZ18gWrapperRepositoryvE2wr
00001a60 b __ZZ18gWrapperRepositoryvE2wr

I understand older libtools gave the -Wl,-all_load flag, which is similar to --whole-archive on the ld from GNU binutils. However, unlike GNU ld, you can't turn off all_load for some archives, and leave it on for others, so you end up messing up the linking of the implicit libraries:
^ioeng21:~/physiome_builds/trees/CellML_DOM_API_OSX cmiss$ g++ -Wl,-all_load -g -O2 -o .libs/cellml_corba_server --whole-archive cellml_corba_server-Main.o -Wl,-bind_at_load /usr/lib/libxml2.dylib -lpthread -lz /usr/lib/libiconv.dylib -lm -lomniORB4 -lomnithread ./.libs/libcellml_context.dylib ./.libs/libcellml_context_corba.dylib ./.libs/libcellml.dylib ./.libs/libcellml_corba.dylib ./.libs/libCORBASupport.a ./.libs/libltdlc.a
/usr/bin/ld: warning multiple definitions of symbol ___eprintf
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libgcc.a(_eprintf.o) private external definition of ___eprintf in section (__TEXT,__text)
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libstdc++.dylib(single module) definition of ___eprintf
/usr/bin/ld: warning multiple definitions of symbol ___divdi3
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libgcc.a(_divdi3.o) private external definition of ___divdi3 in section (__TEXT,__text)
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libgcc_s.dylib(_divdi3_s.o) definition of ___divdi3
/usr/bin/ld: warning multiple definitions of symbol ___udivdi3
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libgcc.a(_udivdi3.o) private external definition of ___udivdi3 in section (__TEXT,__text)
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libgcc_s.dylib(_udivdi3_s.o) definition of ___udivdi3
/usr/bin/ld: warning multiple definitions of symbol ___umoddi3
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libgcc.a(_umoddi3.o) private external definition of ___umoddi3 in section (__TEXT,__text)
/usr/lib/gcc/powerpc-apple-darwin8/4.0.0/libgcc_s.dylib(_umoddi3_s.o) definition of ___umoddi3

(which is presumably why older versions dropped that flag, and caused this bug).

Unless someone finds a better way, I think the correct solution will have to be to unarchive the convenience libraries and link the objects manually.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

CC list is empty

 

Do you think this task is very important?
If so, you can click here to add your encouragement to it.
This task has 0 encouragements so far.

Only logged-in users can vote.

 

Please enter the title of George Orwell's famous dystopian book (it's a date):

 

 

No Changes Have Been Made to This Item

Back to the top


Powered by Savane 3.1-cleanup