This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Fix test-suite failure with -Wl,--as-needed
- From: Siddhesh Poyarekar <siddhesh at redhat dot com>
- To: Allan McRae <allan at archlinux dot org>
- Cc: libc-alpha at sourceware dot org
- Date: Mon, 8 Oct 2012 10:07:49 +0530
- Subject: Re: [PATCH] Fix test-suite failure with -Wl,--as-needed
- References: <1349668307-26132-1-git-send-email-allan@archlinux.org>
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