Linux-kselftest Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] selftests: use LDLIBS for libraries instead of LDFLAGS
@ 2020-02-12 14:00 Dmitry Safonov
  2020-02-12 18:15 ` shuah
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Safonov @ 2020-02-12 14:00 UTC (permalink / raw)
  To: shuah
  Cc: linux-kselftest, avagin, linux-kernel, Dmitry Safonov,
	Dmitry Safonov, Shuah Khan

While building selftests, the following errors were observed:
> tools/testing/selftests/timens'
> gcc -Wall -Werror -pthread  -lrt -ldl  timens.c  -o tools/testing/selftests/timens/timens
> /usr/bin/ld: /tmp/ccGy5CST.o: in function `check_config_posix_timers':
> timens.c:(.text+0x65a): undefined reference to `timer_create'
> collect2: error: ld returned 1 exit status

Quoting commit 870f193d48c2 ("selftests: net: use LDLIBS instead of
LDFLAGS"):

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.

While at here, correct other selftests, not only timens ones.

Reported-by: Shuah Khan <skhan@kernel.org>
Signed-off-by: Dmitry Safonov <dima@arista.com>
---
 tools/testing/selftests/futex/functional/Makefile | 2 +-
 tools/testing/selftests/net/Makefile              | 4 ++--
 tools/testing/selftests/rtc/Makefile              | 2 +-
 tools/testing/selftests/timens/Makefile           | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/futex/functional/Makefile b/tools/testing/selftests/futex/functional/Makefile
index 30996306cabc..23207829ec75 100644
--- a/tools/testing/selftests/futex/functional/Makefile
+++ b/tools/testing/selftests/futex/functional/Makefile
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 INCLUDES := -I../include -I../../
 CFLAGS := $(CFLAGS) -g -O2 -Wall -D_GNU_SOURCE -pthread $(INCLUDES)
-LDFLAGS := $(LDFLAGS) -pthread -lrt
+LDLIBS := -lpthread -lrt
 
 HEADERS := \
 	../include/futextest.h \
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index b5694196430a..287ae916ec0b 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -27,5 +27,5 @@ KSFT_KHDR_INSTALL := 1
 include ../lib.mk
 
 $(OUTPUT)/reuseport_bpf_numa: LDLIBS += -lnuma
-$(OUTPUT)/tcp_mmap: LDFLAGS += -lpthread
-$(OUTPUT)/tcp_inq: LDFLAGS += -lpthread
+$(OUTPUT)/tcp_mmap: LDLIBS += -lpthread
+$(OUTPUT)/tcp_inq: LDLIBS += -lpthread
diff --git a/tools/testing/selftests/rtc/Makefile b/tools/testing/selftests/rtc/Makefile
index de9c8566672a..2d93d65723c9 100644
--- a/tools/testing/selftests/rtc/Makefile
+++ b/tools/testing/selftests/rtc/Makefile
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 CFLAGS += -O3 -Wl,-no-as-needed -Wall
-LDFLAGS += -lrt -lpthread -lm
+LDLIBS += -lrt -lpthread -lm
 
 TEST_GEN_PROGS = rtctest
 
diff --git a/tools/testing/selftests/timens/Makefile b/tools/testing/selftests/timens/Makefile
index e9fb30bd8aeb..b4fd9a934654 100644
--- a/tools/testing/selftests/timens/Makefile
+++ b/tools/testing/selftests/timens/Makefile
@@ -2,6 +2,6 @@ TEST_GEN_PROGS := timens timerfd timer clock_nanosleep procfs exec
 TEST_GEN_PROGS_EXTENDED := gettime_perf
 
 CFLAGS := -Wall -Werror -pthread
-LDFLAGS := -lrt -ldl
+LDLIBS := -lrt -ldl
 
 include ../lib.mk
-- 
2.25.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests: use LDLIBS for libraries instead of LDFLAGS
  2020-02-12 14:00 [PATCH] selftests: use LDLIBS for libraries instead of LDFLAGS Dmitry Safonov
@ 2020-02-12 18:15 ` shuah
  2020-02-13 20:24   ` shuah
  0 siblings, 1 reply; 4+ messages in thread
From: shuah @ 2020-02-12 18:15 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kselftest, avagin, linux-kernel, Dmitry Safonov, shuah

On 2/12/20 7:00 AM, Dmitry Safonov wrote:
> While building selftests, the following errors were observed:
>> tools/testing/selftests/timens'
>> gcc -Wall -Werror -pthread  -lrt -ldl  timens.c  -o tools/testing/selftests/timens/timens
>> /usr/bin/ld: /tmp/ccGy5CST.o: in function `check_config_posix_timers':
>> timens.c:(.text+0x65a): undefined reference to `timer_create'
>> collect2: error: ld returned 1 exit status
> 
> Quoting commit 870f193d48c2 ("selftests: net: use LDLIBS instead of
> LDFLAGS"):
> 
> 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.
> 
> While at here, correct other selftests, not only timens ones.
> 
> Reported-by: Shuah Khan <skhan@kernel.org>
> Signed-off-by: Dmitry Safonov <dima@arista.com>
> ---
>   tools/testing/selftests/futex/functional/Makefile | 2 +-
>   tools/testing/selftests/net/Makefile              | 4 ++--
>   tools/testing/selftests/rtc/Makefile              | 2 +-
>   tools/testing/selftests/timens/Makefile           | 2 +-
>   4 files changed, 5 insertions(+), 5 deletions(-)
> 


Looks good. Thanks for fixing it quickly.

Please split these into 4 patches and send one for each test.

For timens:

Tested-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests: use LDLIBS for libraries instead of LDFLAGS
  2020-02-12 18:15 ` shuah
@ 2020-02-13 20:24   ` shuah
  2020-02-13 20:25     ` Dmitry Safonov
  0 siblings, 1 reply; 4+ messages in thread
From: shuah @ 2020-02-13 20:24 UTC (permalink / raw)
  To: Dmitry Safonov
  Cc: linux-kselftest, avagin, linux-kernel, Dmitry Safonov, shuah

On 2/12/20 11:15 AM, shuah wrote:
> On 2/12/20 7:00 AM, Dmitry Safonov wrote:
>> While building selftests, the following errors were observed:
>>> tools/testing/selftests/timens'
>>> gcc -Wall -Werror -pthread  -lrt -ldl  timens.c  -o 
>>> tools/testing/selftests/timens/timens
>>> /usr/bin/ld: /tmp/ccGy5CST.o: in function `check_config_posix_timers':
>>> timens.c:(.text+0x65a): undefined reference to `timer_create'
>>> collect2: error: ld returned 1 exit status
>>
>> Quoting commit 870f193d48c2 ("selftests: net: use LDLIBS instead of
>> LDFLAGS"):
>>
>> 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.
>>
>> While at here, correct other selftests, not only timens ones.
>>
>> Reported-by: Shuah Khan <skhan@kernel.org>
>> Signed-off-by: Dmitry Safonov <dima@arista.com>
>> ---
>>   tools/testing/selftests/futex/functional/Makefile | 2 +-
>>   tools/testing/selftests/net/Makefile              | 4 ++--
>>   tools/testing/selftests/rtc/Makefile              | 2 +-
>>   tools/testing/selftests/timens/Makefile           | 2 +-
>>   4 files changed, 5 insertions(+), 5 deletions(-)
>>
> 
> 
> Looks good. Thanks for fixing it quickly.
> 
> Please split these into 4 patches and send one for each test.
> 
> For timens:
> 
> Tested-by: Shuah Khan <skhan@linuxfoundation.org>
> 

In the interest of getting this fix in, I applied it to

git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git 
fixes branch.

No need to do anything.

thanks,
-- Shuah


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] selftests: use LDLIBS for libraries instead of LDFLAGS
  2020-02-13 20:24   ` shuah
@ 2020-02-13 20:25     ` Dmitry Safonov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Safonov @ 2020-02-13 20:25 UTC (permalink / raw)
  To: shuah; +Cc: linux-kselftest, avagin, linux-kernel, Dmitry Safonov

On 2/13/20 8:24 PM, shuah wrote:
> In the interest of getting this fix in, I applied it to
> 
> git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git
> fixes branch.
> 
> No need to do anything.

Ah, thank you!
I was on other issues - sorry for the delay.

Thanks,
          Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-12 14:00 [PATCH] selftests: use LDLIBS for libraries instead of LDFLAGS Dmitry Safonov
2020-02-12 18:15 ` shuah
2020-02-13 20:24   ` shuah
2020-02-13 20:25     ` Dmitry Safonov

Linux-kselftest Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-kselftest/0 linux-kselftest/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-kselftest linux-kselftest/ https://lore.kernel.org/linux-kselftest \
		linux-kselftest@vger.kernel.org
	public-inbox-index linux-kselftest

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kselftest


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git