This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17480] collect2 on AIX calls static constructors of unreferenced object modules


------- Additional Comments From harco dot de dot hilster at ATConsultancy dot nl  2004-09-26 18:43 -------
I've written a collect3 perl script, that performs some of the optimalization of
the linker, and only collects the con-/destructors of object modules actually
referenced by the application. The results are shown below:

collect2:
$ g++ -o hello hello.cpp
$ ls -l hello
-rwxr-xr-x   1 huminf   staff       3474251 24 Sep 11:42 hello*
$ g++ -o hello hello.cpp -lxercesc.210
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_destroy
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_lock
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutexattr_init
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutexattr_settype
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_init
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutexattr_destroy
ld: 0711-317 ERROR: Undefined symbol: .pthread_mutex_unlock
ld: 0711-317 ERROR: Undefined symbol: _STL::cout
ld: 0711-317 ERROR: Undefined symbol: ._STL::ios_base::Init::~Init [in-charge]()
ld: 0711-317 ERROR: Undefined symbol: ._STL::ios_base::_Loc_init::~_Loc_init
[in-charge]()
ld: 0711-317 ERROR: Undefined symbol:
._STL::ios_base::_Loc_init::_Loc_init[in-charge]()
ld: 0711-317 ERROR: Undefined symbol: ._STL::ios_base::Init::Init[in-charge]()
ld: 0711-317 ERROR: Undefined symbol: ._STL::ios_base::_M_throw_failure()
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status
$ g++ -o hello hello.cpp -lxercesc.210 -lstlport_gcc -lpthread
$ ls -l hello
-rwxr-xr-x   1 huminf   staff      10857393 24 Sep 11:44 hello*

collect3:
$ g++ -o hello hello.cpp
$ ls -l hello
-rwxr-xr-x   1 huminf   staff         12122 24 Sep 11:30 hello*
$ ./hello
how big can hello get
$ g++ -o hello hello.cpp -lxercesc.210
$ ls -l hello
-rwxr-xr-x   1 huminf   staff         12122 24 Sep 11:39 hello*

collect3 (http://www.atconsultancy.nl/download/collect3) is a prove of concept
to show that g++/collect2 on AIX can behave identical to g++/ld on other
platforms. Tested with gcc-3.3.2, aix5l. I hope the same optimalization can be
added to collect2. Any feedback is welcome.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17480


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]