From mboxrd@z Thu Jan 1 00:00:00 1970 From: dave.anglin@nrc.ca To: gcc-gnats@gcc.gnu.org Subject: objc/2902: collect2 doesn't find ctors/dtors in shared libraries under hpux10.20 Date: Tue, 22 May 2001 11:46:00 -0000 Message-id: <20010522184444.25021.qmail@sourceware.cygnus.com> X-SW-Source: 2001-05/msg00636.html List-Id: >Number: 2902 >Category: objc >Synopsis: collect2 doesn't find ctors/dtors in shared libraries under hpux10.20 >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: sw-bug >Submitter-Id: net >Arrival-Date: Tue May 22 11:46:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: Dave Anglin >Release: gcc version 3.0 20010518 (prerelease) >Organization: >Environment: # ../../gcc/configure --host=hppa1.1-hp-hpux10.20 --target=hppa1.1-hp-hpux10.20 --srcdir=../../gcc --with-gcc-version-trigger=/xxx/gnu/gcc-3.0/gcc/version.c --with-gnu-as --enable-shared --enable-threads --enable-debug=no >Description: The symptom is a large number of failures in the testsuite with the following error: Executing on host: /xxx/gnu/gcc-3.0/objdir/gcc/xgcc -B/xxx/gnu/gcc-3.0/objdir/gcc/ /xxx/gnu/gcc-3.0/gcc/testsuite/objc/execute/_cmd.m -w -O -I/xxx/gnu/gcc-3.0/gcc/testsuite/../../libobjc -L/xxx/gnu/gcc-3.0/objdir/hppa1.1-hp-hpux10.20/libobjc/.libs -lobjc -lm -fPIC -o /xxx/gnu/gcc-3.0/objdir/gcc/testsuite/_cmd.x (timeout = 300) PASS: objc/execute/_cmd.m compilation, -O objc runtime: cannot find class Object FAIL: objc/execute/_cmd.m execution, -O In debugging this, I found that the constructors to build the classes Object and NXConstantString don't run when the application is linked with a shared libobjc. This is apparently because collect2 can't determine that these constructors are needed. Here is part of the output generated by collect2 with `-debug' linking _cmd.x: /usr/ccs/bin/ld -L/lib/pa1.1 -L/usr/lib/pa1.1 -z -u main -o /xxx/gnu/gcc-3.0/objdir/gcc/testsuite/_cmd.x /usr/ccs/lib/crt0.o -L/xxx/gnu/gcc-3.0/objdir/hppa1.1-hp-hpux10.20/libobjc/.libs -L/xxx/gnu/gcc-3.0/objdir/gcc -L/usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/3.0 -L/usr/ccs/bin -L/usr/ccs/lib -L/opt/langtools/lib -L/usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/3.0/../../.. /var/tmp/ccapeMug.o -lobjc -lm -lgcc -lc -lgcc /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/3.0/../../../../hppa1.1-hp-hpux10.20/bin/nm -n /xxx/gnu/gcc-3.0/objdir/gcc/testsuite/_cmd.x nm output with constructors/destructors. 000025e8 T _GLOBAL__I_main /usr/ccs/bin/chatr /xxx/gnu/gcc-3.0/objdir/gcc/testsuite/_cmd.x ldd output with constructors/destructors. dynamic /xxx/gnu/gcc-3.0/objdir/hppa1.1-hp-hpux10.20/libobjc/.libs/libobjc.sl.1 dynamic /usr/lib/libc.1 /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/3.0/../../../../hppa1.1-hp-hpux10.20/bin/nm -n /xxx/gnu/gcc-3.0/objdir/hppa1.1-hp-hpux10.20/libobjc/.libs/libobjc.sl.1 nm output with constructors/destructors. 00017aa0 T _GLOBAL__I___objc_linking 00017ad0 T _GLOBAL__I___objc_linking 00018210 T _GLOBAL__I_.._.._.._libobjc_NXConstStr.mSFndDa 00018228 T _GLOBAL__I_.._.._.._libobjc_NXConstStr.mSFndDa 0001a1e0 T _GLOBAL__I_.._.._.._libobjc_Object.mOXKa8a 0001a1f8 T _GLOBAL__I_.._.._.._libobjc_Object.mOXKa8a 0001b058 T _GLOBAL__I_.._.._.._libobjc_Protocol.mxvicuc 0001b070 T _GLOBAL__I_.._.._.._libobjc_Protocol.mxvicuc /usr/local/lib/gcc-lib/hppa1.1-hp-hpux10.20/3.0/../../../../hppa1.1-hp-hpux10.2 0/bin/nm -n /usr/lib/libc.1 nm output with constructors/destructors. 1 constructor(s) found 0 destructor(s) found 0 frame table(s) found [Leaving /xxx/gnu/gcc-3.0/objdir/gcc/testsuite/_cmd.x] >How-To-Repeat: Configure with `--enable-shared'. >Fix: >Release-Note: >Audit-Trail: >Unformatted: