This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc 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]

Re: [PATCH] Fix test-suite failure with -Wl,--as-needed


On Mon,  8 Oct 2012 13:51:47 +1000, Allan wrote:
> When building the test-suite with --as-needed in your LDFLAGS, the
> test test-cond24 fails linking:
> 
> /build/nptl/tst-cond24.o: In function `thread_fun_timed':
> tst-cond24.c:(.text+0x30c): undefined reference to `clock_gettime'
> collect2: error: ld returned 1 exit status

I think the real fix should be to the link command and not to add
no-as-needed all over the place.  The current command looks like this
(shortened for clarity):

gcc $OPTIONS
-o /home/siddhesh/src/upstream/glibc-build/nptl/tst-cond24
$DYNAMIC_LINKER
-Wl,--as-needed -lrt -Wl,-z,combreloc -Wl,-z,relro
$MORE_OPTIONS /home/siddhesh/src/upstream/glibc-build/nptl/tst-cond24.o
$EVERYTHING_ELSE

which is wrong.  It should be:

gcc $OPTIONS \
-o $BUILDDIR/nptl/tst-cond24 \
$BUILDDIR/nptl/tst-cond24.o \
$DYNAMIC_LINKER \
-Wl,--as-needed -lrt -Wl,-z,combreloc -Wl,-z,relro \
$MORE_OPTIONS \
$EVERYTHING_ELSE

so that the linker can see the object file to decide if librt is needed
or not.  With the earlier form, it will always reject librt.


Siddhesh


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