2017-06-23 10:37:37

by Marcin Nowakowski

[permalink] [raw]
Subject: [PATCH 0/3] kselftest build errors

This patch series fixes build errors observed when building net, memfd, gpio and intel_pstate tests

Marcin Nowakowski (3):
selftests/{net,memfd}: fix undefined references to external libraries
selftests/gpio: fix build error
selftests/intel_pstate: fix undefined reference when building

tools/testing/selftests/gpio/Makefile | 2 +-
tools/testing/selftests/intel_pstate/Makefile | 2 +-
tools/testing/selftests/memfd/Makefile | 4 ++--
tools/testing/selftests/net/Makefile | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)

--
2.7.4


2017-06-23 10:37:40

by Marcin Nowakowski

[permalink] [raw]
Subject: [PATCH 1/3] selftests/{net,memfd}: fix undefined references to external libraries

net test fails to link properly due to a missing reference to -lnuma and
fails with:
reuseport_bpf_numa.c:138: undefined reference to `numa_run_on_node'
reuseport_bpf_numa.c:230: undefined reference to `numa_available'
reuseport_bpf_numa.c:233: undefined reference to `numa_max_node'
collect2: error: ld returned 1 exit status

running make -p shows that this is due to a wrong LDFLAGS variable
definition which doesn't include the output prefix location:

# makefile (from 'Makefile', line 6)
reuseport_bpf_numa: LDFLAGS += -lnuma
# Not a target:
reuseport_bpf_numa:

The same issue has been observed in memfd with its references to
libfuse.

Resolve this by adding a pattern-matching to allow the binary name to be
prefixed with an output location.

For memfd also replace LDFLAGS with LDLIBS definition to ensure correct
ordering of arguments in the make's implicit rules.

Fixes: a8ba798bc8ec ('selftests: enable O and KBUILD_OUTPUT')

Signed-off-by: Marcin Nowakowski <[email protected]>
---
tools/testing/selftests/memfd/Makefile | 4 ++--
tools/testing/selftests/net/Makefile | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index 79891d0..754e92f 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -6,8 +6,8 @@ CFLAGS += -I../../../../usr/include/
TEST_PROGS := run_fuse_test.sh
TEST_GEN_FILES := memfd_test fuse_mnt fuse_test

-fuse_mnt.o: CFLAGS += $(shell pkg-config fuse --cflags)
-fuse_mnt: LDFLAGS += $(shell pkg-config fuse --libs)
+%/fuse_mnt: CFLAGS += $(shell pkg-config fuse --cflags)
+%/fuse_mnt: LDLIBS += $(shell pkg-config fuse --libs)

include ../lib.mk

diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 35cbb4c..d7abe8b 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -3,7 +3,7 @@
CFLAGS = -Wall -Wl,--no-as-needed -O2 -g
CFLAGS += -I../../../../usr/include/

-reuseport_bpf_numa: LDFLAGS += -lnuma
+%/reuseport_bpf_numa: LDFLAGS += -lnuma

TEST_PROGS := run_netsocktests run_afpackettests test_bpf.sh netdevice.sh
TEST_GEN_FILES = socket
--
2.7.4

2017-06-23 10:37:53

by Marcin Nowakowski

[permalink] [raw]
Subject: [PATCH 3/3] selftests/intel_pstate: fix undefined reference when building

Currently the build fails with:

/tmp/ccmgtz8N.o: In function `main':
aperf.c:(.text+0x278): undefined reference to `sqrt'
collect2: error: ld returned 1 exit status

Replace LDFLAGS with LDLIBS to ensure proper ordering of arguments in
build rules.

Signed-off-by: Marcin Nowakowski <[email protected]>
---
tools/testing/selftests/intel_pstate/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/intel_pstate/Makefile b/tools/testing/selftests/intel_pstate/Makefile
index 19678e9..80fd0ba 100644
--- a/tools/testing/selftests/intel_pstate/Makefile
+++ b/tools/testing/selftests/intel_pstate/Makefile
@@ -1,5 +1,5 @@
CFLAGS := $(CFLAGS) -Wall -D_GNU_SOURCE
-LDFLAGS := $(LDFLAGS) -lm
+LDLIBS := $(LDFLAGS) -lm

TEST_GEN_FILES := msr aperf

--
2.7.4

2017-06-23 10:37:46

by Marcin Nowakowski

[permalink] [raw]
Subject: [PATCH 2/3] selftests/gpio: fix build error

While building selftests/gpio, gpio-utils from linux/tools/gpio as built
in the process as well. However, the OUTPUT make variable usage in
selftests breaks the build system in linux/tools/gpio resulting in its
output files placed in the selftests folder (due to lack of trailing
slash in the path, the files are placed directly in selftests):

make -f linux/tools/build/Makefile.build dir=. obj=lsgpio
make[3]: Entering directory '/mnt/ssd/MIPS/linux-next/tools/gpio'
CC linux/tools/testing/selftests/gpiolsgpio.o
CC linux/tools/testing/selftests/gpiogpio-utils.o
LD linux/tools/testing/selftests/gpiolsgpio-in.o

This pollutes the selftests directory and, most importantly, makes it
impossible for selftests/gpio to find the object file it's looking for
to link the test:

cc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
gpio-mockup-chardev.c ../../../gpio/gpio-utils.o
../../../../usr/include/linux/gpio.h -lmount -I/usr/include/libmount -o
gpio-mockup-chardev
gcc: error: ../../../gpio/gpio-utils.o: No such file or directory

Fix this by clearing the OUTPUT variable when invoking linux/tools/gpio
make to ensure it's built where expected.

Note, that this solution is not ideal as the output is placed in
linux/tools/gpio rather than a location relative to OUTPUT, but this at
least ensures the build succeeds.
Due to differences and complexities of selftests and linux/tools build
systems, it's not trivial to ensure linux/tools get built properly when
invoked recursively from selftests build and this is left as a future
task to resolve properly.

Fixes: a8ba798bc8ec ('selftests: enable O and KBUILD_OUTPUT')

Signed-off-by: Marcin Nowakowski <[email protected]>
---
tools/testing/selftests/gpio/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
index 298929d..950956e 100644
--- a/tools/testing/selftests/gpio/Makefile
+++ b/tools/testing/selftests/gpio/Makefile
@@ -23,7 +23,7 @@ LDLIBS += -lmount -I/usr/include/libmount
$(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h

../../../gpio/gpio-utils.o:
- make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
+ make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio OUTPUT=

../../../../usr/include/linux/gpio.h:
make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/
--
2.7.4

2017-06-23 19:44:14

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 0/3] kselftest build errors

On 06/23/2017 04:37 AM, Marcin Nowakowski wrote:
> This patch series fixes build errors observed when building net, memfd, gpio and intel_pstate tests
>
> Marcin Nowakowski (3):
> selftests/{net,memfd}: fix undefined references to external libraries
> selftests/gpio: fix build error
> selftests/intel_pstate: fix undefined reference when building
>
> tools/testing/selftests/gpio/Makefile | 2 +-
> tools/testing/selftests/intel_pstate/Makefile | 2 +-
> tools/testing/selftests/memfd/Makefile | 4 ++--
> tools/testing/selftests/net/Makefile | 2 +-
> 4 files changed, 5 insertions(+), 5 deletions(-)
>

Hi Marcin,

SeongJae Park sent me fixes for the memfd/net/intel_pstate problems
last week. I pulled those in already.

The gpio fix is something I need to look at closely to see if this is
the way to go. I will get back to you on that.

thanks,
-- Shuah

2017-06-28 08:31:04

by Fathi Boudra

[permalink] [raw]
Subject: Re: [PATCH 0/3] kselftest build errors

On 23 June 2017 at 22:44, Shuah Khan <[email protected]> wrote:
> On 06/23/2017 04:37 AM, Marcin Nowakowski wrote:
>> This patch series fixes build errors observed when building net, memfd, gpio and intel_pstate tests
>>
>> Marcin Nowakowski (3):
>> selftests/{net,memfd}: fix undefined references to external libraries
>> selftests/gpio: fix build error
>> selftests/intel_pstate: fix undefined reference when building
>>
>> tools/testing/selftests/gpio/Makefile | 2 +-
>> tools/testing/selftests/intel_pstate/Makefile | 2 +-
>> tools/testing/selftests/memfd/Makefile | 4 ++--
>> tools/testing/selftests/net/Makefile | 2 +-
>> 4 files changed, 5 insertions(+), 5 deletions(-)
>>
>
> Hi Marcin,
>
> SeongJae Park sent me fixes for the memfd/net/intel_pstate problems
> last week. I pulled those in already.
>
> The gpio fix is something I need to look at closely to see if this is
> the way to go. I will get back to you on that.

Any updates on the gpio fix? I've tested it and it works for me.

> thanks,
> -- Shuah
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2017-06-28 08:34:45

by Fathi Boudra

[permalink] [raw]
Subject: Re: [PATCH 2/3] selftests/gpio: fix build error

On 23 June 2017 at 13:37, Marcin Nowakowski
<[email protected]> wrote:
> While building selftests/gpio, gpio-utils from linux/tools/gpio as built
> in the process as well. However, the OUTPUT make variable usage in
> selftests breaks the build system in linux/tools/gpio resulting in its
> output files placed in the selftests folder (due to lack of trailing
> slash in the path, the files are placed directly in selftests):
>
> make -f linux/tools/build/Makefile.build dir=. obj=lsgpio
> make[3]: Entering directory '/mnt/ssd/MIPS/linux-next/tools/gpio'
> CC linux/tools/testing/selftests/gpiolsgpio.o
> CC linux/tools/testing/selftests/gpiogpio-utils.o
> LD linux/tools/testing/selftests/gpiolsgpio-in.o
>
> This pollutes the selftests directory and, most importantly, makes it
> impossible for selftests/gpio to find the object file it's looking for
> to link the test:
>
> cc -O2 -g -std=gnu99 -Wall -I../../../../usr/include/
> gpio-mockup-chardev.c ../../../gpio/gpio-utils.o
> ../../../../usr/include/linux/gpio.h -lmount -I/usr/include/libmount -o
> gpio-mockup-chardev
> gcc: error: ../../../gpio/gpio-utils.o: No such file or directory
>
> Fix this by clearing the OUTPUT variable when invoking linux/tools/gpio
> make to ensure it's built where expected.
>
> Note, that this solution is not ideal as the output is placed in
> linux/tools/gpio rather than a location relative to OUTPUT, but this at
> least ensures the build succeeds.
> Due to differences and complexities of selftests and linux/tools build
> systems, it's not trivial to ensure linux/tools get built properly when
> invoked recursively from selftests build and this is left as a future
> task to resolve properly.
>
> Fixes: a8ba798bc8ec ('selftests: enable O and KBUILD_OUTPUT')
>
> Signed-off-by: Marcin Nowakowski <[email protected]>

FWIW, I've tested the patch and it fixes the issue mentioned.

Tested-by: Fathi Boudra <[email protected]>

> ---
> tools/testing/selftests/gpio/Makefile | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/gpio/Makefile b/tools/testing/selftests/gpio/Makefile
> index 298929d..950956e 100644
> --- a/tools/testing/selftests/gpio/Makefile
> +++ b/tools/testing/selftests/gpio/Makefile
> @@ -23,7 +23,7 @@ LDLIBS += -lmount -I/usr/include/libmount
> $(BINARIES): ../../../gpio/gpio-utils.o ../../../../usr/include/linux/gpio.h
>
> ../../../gpio/gpio-utils.o:
> - make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio
> + make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C ../../../gpio OUTPUT=
>
> ../../../../usr/include/linux/gpio.h:
> make -C ../../../.. headers_install INSTALL_HDR_PATH=$(shell pwd)/../../../../usr/
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2017-06-28 14:21:45

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 0/3] kselftest build errors

On 06/28/2017 02:30 AM, Fathi Boudra wrote:
> On 23 June 2017 at 22:44, Shuah Khan <[email protected]> wrote:
>> On 06/23/2017 04:37 AM, Marcin Nowakowski wrote:
>>> This patch series fixes build errors observed when building net, memfd, gpio and intel_pstate tests
>>>
>>> Marcin Nowakowski (3):
>>> selftests/{net,memfd}: fix undefined references to external libraries
>>> selftests/gpio: fix build error
>>> selftests/intel_pstate: fix undefined reference when building
>>>
>>> tools/testing/selftests/gpio/Makefile | 2 +-
>>> tools/testing/selftests/intel_pstate/Makefile | 2 +-
>>> tools/testing/selftests/memfd/Makefile | 4 ++--
>>> tools/testing/selftests/net/Makefile | 2 +-
>>> 4 files changed, 5 insertions(+), 5 deletions(-)
>>>
>>
>> Hi Marcin,
>>
>> SeongJae Park sent me fixes for the memfd/net/intel_pstate problems
>> last week. I pulled those in already.
>>
>> The gpio fix is something I need to look at closely to see if this is
>> the way to go. I will get back to you on that.
>
> Any updates on the gpio fix? I've tested it and it works for me.
>

I haven't decided yet.

thanks,
-- Shuah

2017-06-29 08:37:57

by Fathi Boudra

[permalink] [raw]
Subject: Re: [PATCH 0/3] kselftest build errors

On 28 June 2017 at 17:21, Shuah Khan <[email protected]> wrote:
> On 06/28/2017 02:30 AM, Fathi Boudra wrote:
>> On 23 June 2017 at 22:44, Shuah Khan <[email protected]> wrote:
>>> On 06/23/2017 04:37 AM, Marcin Nowakowski wrote:
>>>> This patch series fixes build errors observed when building net, memfd, gpio and intel_pstate tests
>>>>
>>>> Marcin Nowakowski (3):
>>>> selftests/{net,memfd}: fix undefined references to external libraries
>>>> selftests/gpio: fix build error
>>>> selftests/intel_pstate: fix undefined reference when building
>>>>
>>>> tools/testing/selftests/gpio/Makefile | 2 +-
>>>> tools/testing/selftests/intel_pstate/Makefile | 2 +-
>>>> tools/testing/selftests/memfd/Makefile | 4 ++--
>>>> tools/testing/selftests/net/Makefile | 2 +-
>>>> 4 files changed, 5 insertions(+), 5 deletions(-)
>>>>
>>>
>>> Hi Marcin,
>>>
>>> SeongJae Park sent me fixes for the memfd/net/intel_pstate problems
>>> last week. I pulled those in already.
>>>
>>> The gpio fix is something I need to look at closely to see if this is
>>> the way to go. I will get back to you on that.
>>
>> Any updates on the gpio fix? I've tested it and it works for me.
>>
>
> I haven't decided yet.

another alternative is to use realpath:
-GPIODIR := ../../../gpio
+GPIODIR := $(realpath ../../../gpio)

btw, this commit:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=51c6bd7cbe0366b642d8ac90d98739c39ab091a9
should be reverted once the build error is addressed because they
shouldn't have been there in the first place due to lack of trailing
slash in the path.

> thanks,
> -- Shuah

2017-07-12 09:30:11

by Naresh Kamboju

[permalink] [raw]
Subject: Re: [PATCH 0/3] kselftest build errors

Hi Fathi and Shuah,

On 29 June 2017 at 14:07, Fathi Boudra <[email protected]> wrote:
> On 28 June 2017 at 17:21, Shuah Khan <[email protected]> wrote:
>> On 06/28/2017 02:30 AM, Fathi Boudra wrote:
>>> On 23 June 2017 at 22:44, Shuah Khan <[email protected]> wrote:
>>>> On 06/23/2017 04:37 AM, Marcin Nowakowski wrote:
>>>>> This patch series fixes build errors observed when building net, memfd, gpio and intel_pstate tests
>>>>>
>>>>> Marcin Nowakowski (3):
>>>>> selftests/{net,memfd}: fix undefined references to external libraries
>>>>> selftests/gpio: fix build error
>>>>> selftests/intel_pstate: fix undefined reference when building
>>>>>
>>>>> tools/testing/selftests/gpio/Makefile | 2 +-
>>>>> tools/testing/selftests/intel_pstate/Makefile | 2 +-
>>>>> tools/testing/selftests/memfd/Makefile | 4 ++--
>>>>> tools/testing/selftests/net/Makefile | 2 +-
>>>>> 4 files changed, 5 insertions(+), 5 deletions(-)
>>>>>
>>>>
>>>> Hi Marcin,
>>>>
>>>> SeongJae Park sent me fixes for the memfd/net/intel_pstate problems
>>>> last week. I pulled those in already.
>>>>
>>>> The gpio fix is something I need to look at closely to see if this is
>>>> the way to go. I will get back to you on that.
>>>
>>> Any updates on the gpio fix? I've tested it and it works for me.
>>>
>>
>> I haven't decided yet.
>
> another alternative is to use realpath:
> -GPIODIR := ../../../gpio
> +GPIODIR := $(realpath ../../../gpio)
>
> btw, this commit:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=51c6bd7cbe0366b642d8ac90d98739c39ab091a9
> should be reverted once the build error is addressed because they
> shouldn't have been there in the first place due to lack of trailing
> slash in the path.

The current status on linux-next is,
gpio-mockup-chardev.c building binary failed and shell script not able
to locate test binary,
gpio-mockup-chardev: No such file or directory

Bug link,
https://bugs.linaro.org/show_bug.cgi?id=3122

- Naresh
>
>> thanks,
>> -- Shuah

2017-07-24 18:28:39

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 0/3] kselftest build errors

On 07/12/2017 03:30 AM, Naresh Kamboju wrote:
> Hi Fathi and Shuah,
>
> On 29 June 2017 at 14:07, Fathi Boudra <[email protected]> wrote:
>> On 28 June 2017 at 17:21, Shuah Khan <[email protected]> wrote:
>>> On 06/28/2017 02:30 AM, Fathi Boudra wrote:
>>>> On 23 June 2017 at 22:44, Shuah Khan <[email protected]> wrote:
>>>>> On 06/23/2017 04:37 AM, Marcin Nowakowski wrote:
>>>>>> This patch series fixes build errors observed when building net, memfd, gpio and intel_pstate tests
>>>>>>
>>>>>> Marcin Nowakowski (3):
>>>>>> selftests/{net,memfd}: fix undefined references to external libraries
>>>>>> selftests/gpio: fix build error
>>>>>> selftests/intel_pstate: fix undefined reference when building
>>>>>>
>>>>>> tools/testing/selftests/gpio/Makefile | 2 +-
>>>>>> tools/testing/selftests/intel_pstate/Makefile | 2 +-
>>>>>> tools/testing/selftests/memfd/Makefile | 4 ++--
>>>>>> tools/testing/selftests/net/Makefile | 2 +-
>>>>>> 4 files changed, 5 insertions(+), 5 deletions(-)
>>>>>>
>>>>>
>>>>> Hi Marcin,
>>>>>
>>>>> SeongJae Park sent me fixes for the memfd/net/intel_pstate problems
>>>>> last week. I pulled those in already.
>>>>>
>>>>> The gpio fix is something I need to look at closely to see if this is
>>>>> the way to go. I will get back to you on that.
>>>>
>>>> Any updates on the gpio fix? I've tested it and it works for me.
>>>>
>>>
>>> I haven't decided yet.
>>
>> another alternative is to use realpath:
>> -GPIODIR := ../../../gpio
>> +GPIODIR := $(realpath ../../../gpio)
>>

You are welcome to send a patch.

>> btw, this commit:
>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=51c6bd7cbe0366b642d8ac90d98739c39ab091a9
>> should be reverted once the build error is addressed because they
>> shouldn't have been there in the first place due to lack of trailing
>> slash in the path.

Yes. This was a temporary solution.

thanks,
-- Shuah
>
> The current status on linux-next is,
> gpio-mockup-chardev.c building binary failed and shell script not able
> to locate test binary,
> gpio-mockup-chardev: No such file or directory
>
> Bug link,
> https://bugs.linaro.org/show_bug.cgi?id=3122
>
> - Naresh
>>
>>> thanks,
>>> -- Shuah
>
>