lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGNsrLBnQja3QGHMsoL4J27Uo90XXXbTgwXZ8OdsFRJEJpX5UQ@mail.gmail.com>
Date:   Thu, 29 Jun 2017 10:02:59 +0300
From:   Fathi Boudra <fathi.boudra@...aro.org>
To:     sjpark <sj38.park@...il.com>
Cc:     linux-kselftest@...r.kernel.org, Shuah Khan <shuah@...nel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        John Stultz <john.stultz@...aro.org>,
        Denys Dmytriyenko <denys@...com>
Subject: Re: [PATCH 2/3] selftests: seccomp: use LDLIBS instead of LDFLAGS

On 29 June 2017 at 00:40, sjpark <sj38.park@...il.com> wrote:
> Hi Fathi,
>
> On Wed, 28 Jun 2017, Fathi Boudra wrote:
>
>> seccomp_bpf fails to build due to undefined reference errors:
>>
>>  aarch64-linaro-linux-gcc --sysroot=/build/tmp-rpb-glibc/sysroots/hikey
>>  -O2 -pipe -g -feliminate-unused-debug-types -Wl,-no-as-needed -Wall
>>  -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -lpthread seccomp_bpf.c -o
>>  /build/tmp-rpb-glibc/work/hikey-linaro-linux/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf
>>  /tmp/ccrlR3MW.o: In function `tsync_sibling':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1920: undefined reference to `sem_post'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1920: undefined reference to `sem_post'
>>  /tmp/ccrlR3MW.o: In function `TSYNC_setup':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1863: undefined reference to `sem_init'
>>  /tmp/ccrlR3MW.o: In function `TSYNC_teardown':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1904: undefined reference to `sem_destroy'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1897: undefined reference to `pthread_kill'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1898: undefined reference to `pthread_cancel'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1899: undefined reference to `pthread_join'
>>  /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /tmp/ccrlR3MW.o: In function `TSYNC_siblings_fail_prctl':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1978: undefined reference to `sem_wait'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1990: undefined reference to `pthread_join'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1992: undefined reference to `pthread_join'
>>  /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_ancestor':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2016: undefined reference to `sem_wait'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2032: undefined reference to `pthread_join'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2034: undefined reference to `pthread_join'
>>  /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /tmp/ccrlR3MW.o: In function `TSYNC_two_sibling_want_nnp':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2046: undefined reference to `sem_wait'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2058: undefined reference to `pthread_join'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2060: undefined reference to `pthread_join'
>>  /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_no_filter':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2073: undefined reference to `sem_wait'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2098: undefined reference to `pthread_join'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2100: undefined reference to `pthread_join'
>>  /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_with_one_divergence':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2125: undefined reference to `sem_wait'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2143: undefined reference to `pthread_join'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2145: undefined reference to `pthread_join'
>>  /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>  /tmp/ccrlR3MW.o: In function `TSYNC_two_siblings_not_under_filter':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2169: undefined reference to `sem_wait'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2202: undefined reference to `pthread_join'
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:2227: undefined reference to `pthread_join'
>>  /tmp/ccrlR3MW.o: In function `tsync_start_sibling':
>>  /usr/src/debug/kselftests/4.12-r0/linux-4.12-rc7/tools/testing/selftests/seccomp/seccomp_bpf.c:1941: undefined reference to `pthread_create'
>>
>> It's GNU Make and linker specific.
>>
>> The default Makefile rule looks like:
>>
>> $(CC) $(CFLAGS) $(LDFLAGS) $@ $^ $(LDLIBS)
>>
>> When linking is done by gcc itself, no issue, but when it needs to be passed
>> to proper ld, only LDLIBS follows and then ld cannot know what libs to link
>> with.
>>
>> More detail:
>> https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
>>
>> LDFLAGS
>> Extra flags to give to compilers when they are supposed to invoke the linker,
>> ‘ld’, such as -L. Libraries (-lfoo) should be added to the LDLIBS variable
>> instead.
>>
>> LDLIBS
>> Library flags or names given to compilers when they are supposed to invoke the
>> linker, ‘ld’. LOADLIBES is a deprecated (but still supported) alternative to
>> LDLIBS. Non-library linker flags, such as -L, should go in the LDFLAGS
>> variable.
>>
>> https://lkml.org/lkml/2010/2/10/362
>>
>> tools/perf: libraries must come after objects
>>
>> Link order matters, use LDLIBS instead of LDFLAGS to properly link against
>> libpthread.
>>
>> Signed-off-by: Fathi Boudra <fathi.boudra@...aro.org>
>> ---
>>  tools/testing/selftests/seccomp/Makefile | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/testing/selftests/seccomp/Makefile b/tools/testing/selftests/seccomp/Makefile
>> index aeb0c805f3ca..d1c74ce70f08 100644
>> --- a/tools/testing/selftests/seccomp/Makefile
>> +++ b/tools/testing/selftests/seccomp/Makefile
>> @@ -1,8 +1,8 @@
>>  TEST_GEN_PROGS := seccomp_bpf
>>  CFLAGS += -Wl,-no-as-needed -Wall
>> -LDFLAGS += -lpthread
>> +LDLIBS += -lpthread
>>
>>  include ../lib.mk
>>
>>  $(TEST_GEN_PROGS): seccomp_bpf.c ../kselftest_harness.h
>> -     $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
>> +     $(CC) $(CFLAGS) $(LDLIBS) $< -o $@
>
> Shouldn't $(LDLIBS) follow $< ?

Good catch. Thanks, will add to v3.

>
> Thanks,
> SeongJae Park
>
>> --
>> 2.13.0
>>
>>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ