Skip to contentSkip to conversation

selftests: sync: missing CFLAGS while compiling

PATCH In review Anders Roxell 3 participants 4 messages Jan 5, 2018 – Jan 16, 2018 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests: sync: missing CFLAGS while compiling

Based on patch: https://patchwork.kernel.org/patch/10042045/

arch64-linux-gnu-gcc -c sync.c -o sync/sync.o
sync.c:42:29: fatal error: linux/sync_file.h: No such file or directory

 #include <linux/sync_file.h>
                             ^

CFLAGS is not used during the compile step, so the system instead of kernel headers are used. Fix this by using lib.mk's compile rules and remove CFLAGS from the linking step.

Reported-by Lei Yang <Lei.Yang at windriver.com>
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/sync/Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
tools/testing/selftests/sync/Makefile +1 -7
index b3c8ba3cb668..58b9336d6c84 100644
@@ -27,12 +27,6 @@ OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS))
 TESTS := $(patsubst %,$(OUTPUT)/%,$(TESTS))
 
 $(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS)
-	$(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS)
-
-$(OBJS): $(OUTPUT)/%.o: %.c
-	$(CC) -c $^ -o $@
-
-$(TESTS): $(OUTPUT)/%.o: %.c
-	$(CC) -c $^ -o $@
+	$(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(LDFLAGS)
 
 EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS)
Signature · 6 lines
2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tested-by on v1 1/1
#1 lore raw
Quoted 4 lines · Anders Roxell

Based on patch: https://patchwork.kernel.org/patch/10042045/

arch64-linux-gnu-gcc -c sync.c -o sync/sync.o
sync.c:42:29: fatal error: linux/sync_file.h: No such file or directory

Quoted 8 lines
 #include <linux/sync_file.h>
                             ^

CFLAGS is not used during the compile step, so the system instead of kernel headers are used. Fix this by using lib.mk's compile rules and remove CFLAGS from the linking step.

Reported-by Lei Yang <Lei.Yang at windriver.com>
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
Tested-by Naresh Kamboju <naresh.kamboju at linaro.org>
Quoted 23 lines
---
 tools/testing/selftests/sync/Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
tools/testing/selftests/sync/Makefile +1 -8
index b3c8ba3cb668..58b9336d6c84 100644
@@ -27,12 +27,6 @@ OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS))
 TESTS := $(patsubst %,$(OUTPUT)/%,$(TESTS))
 
 $(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS)
-       $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS)
-
-$(OBJS): $(OUTPUT)/%.o: %.c
-       $(CC) -c $^ -o $@
-
-$(TESTS): $(OUTPUT)/%.o: %.c
-       $(CC) -c $^ -o $@
+       $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(LDFLAGS)
 
 EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS)
--
Quoted 2 lines

2.11.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#2 lore raw
In reply to Anders Roxell
Quoted 9 lines · Anders Roxell

Based on patch: https://patchwork.kernel.org/patch/10042045/

arch64-linux-gnu-gcc -c sync.c -o sync/sync.o
sync.c:42:29: fatal error: linux/sync_file.h: No such file or directory

 #include <linux/sync_file.h>
                             ^

CFLAGS is not used during the compile step, so the system instead of kernel headers are used. Fix this by using lib.mk's compile rules and remove CFLAGS from the linking step.

Hmm. The changes don't match the change log. It odes more than just removing LDFLAGS from compile step,

Quoted 12 lines
Reported-by Lei Yang <Lei.Yang at windriver.com>
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/sync/Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
tools/testing/selftests/sync/Makefile +0 -0
index b3c8ba3cb668..58b9336d6c84 100644

tools/testing/selftests/sync/Makefile OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS)) · line 30

Quoted 4 lines
tools/testing/selftests/sync/Makefile +0 -1
@@ -27,12 +27,6 @@ OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS))
 TESTS := $(patsubst %,$(OUTPUT)/%,$(TESTS))
 
 $(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS)
-	$(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS)

So why not just delete $(LDFLAGS)??
$(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS)

tools/testing/selftests/sync/Makefile OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS)) · line 32

Quoted 10 lines
tools/testing/selftests/sync/Makefile +1 -6
-
-$(OBJS): $(OUTPUT)/%.o: %.c
-	$(CC) -c $^ -o $@
-
-$(TESTS): $(OUTPUT)/%.o: %.c
-	$(CC) -c $^ -o $@
+	$(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(LDFLAGS)
 
 EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS)

I can't take this patch the way it is. It breaks the following use-case:

make O=/tmp/kselftest TARGETS=sync kselftest

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

#3 lore raw
Quoted 11 lines · Shuah Khan
Quoted 9 lines · Anders Roxell

Based on patch: https://patchwork.kernel.org/patch/10042045/

arch64-linux-gnu-gcc -c sync.c -o sync/sync.o
sync.c:42:29: fatal error: linux/sync_file.h: No such file or directory

 #include <linux/sync_file.h>
                             ^

CFLAGS is not used during the compile step, so the system instead of kernel headers are used. Fix this by using lib.mk's compile rules and remove CFLAGS from the linking step.

Quoted 2 lines

Hmm. The changes don't match the change log. It odes more than just removing LDFLAGS from compile step,

oh, you are correct. I'm sorry.
I will re-spin the patch and make the changelog reflect the actual change next time.

Quoted 29 lines
Quoted 13 lines
Reported-by Lei Yang <Lei.Yang at windriver.com>
Signed-off-by Anders Roxell <anders.roxell at linaro.org>
---
 tools/testing/selftests/sync/Makefile | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
tools/testing/selftests/sync/Makefile +0 -0
index b3c8ba3cb668..58b9336d6c84 100644

tools/testing/selftests/sync/Makefile OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS)) · line 30

Quoted 4 lines
tools/testing/selftests/sync/Makefile +0 -1
@@ -27,12 +27,6 @@ OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS))
 TESTS := $(patsubst %,$(OUTPUT)/%,$(TESTS))
 
 $(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS)
-     $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS)

So why not just delete $(LDFLAGS)??
$(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS)

Quoted 8 lines
tools/testing/selftests/sync/Makefile +1 -6
-
-$(OBJS): $(OUTPUT)/%.o: %.c
-     $(CC) -c $^ -o $@
-
-$(TESTS): $(OUTPUT)/%.o: %.c
-     $(CC) -c $^ -o $@
+     $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(LDFLAGS)
 
Quoted 7 lines

tools/testing/selftests/sync/Makefile OBJS := $(patsubst %,$(OUTPUT)/%,$(OBJS)) · line 32

Quoted 2 lines
tools/testing/selftests/sync/Makefile +0 -0
 EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS)

I can't take this patch the way it is. It breaks the following use-case:

make O=/tmp/kselftest TARGETS=sync kselftest

Oh, I've missed that use-case. Will fix that in the re-spin of the patch.

To fix this build issue when cross compiling

tools/testing/selftests/sync/Makefile +1 -1
@@ -30,7 +30,7 @@ $(TEST_CUSTOM_PROGS): $(TESTS) $(OBJS)
        $(CC) -o $(TEST_CUSTOM_PROGS) $(OBJS) $(TESTS) $(CFLAGS) $(LDFLAGS)
 
 $(OBJS): $(OUTPUT)/%.o: %.c
-       $(CC) -c $^ -o $@
+       $(CC) -c $^ -o $@ $(CFLAGS)
 
 $(TESTS): $(OUTPUT)/%.o: %.c
        $(CC) -c $^ -o $@

The other issue that needs to be addressed somehow would be make the build system do
headers_install or if that should be a prerequisite.
I've seen ways to install the headers: "make -C ../../../.. headers_install" if the headers
aren't there, in
tools/testing/selftests/gpio/Makefile tools/testing/selftests/vm/Makefile

Is that the preferred way or should an update in Documentation/dev-tools/kselftest.rst be done to say do "make headers_install" before
building kselftests?

Cheers,
Anders

Quoted 3 lines

thanks,
-- Shuah

--
To unsubscribe from this list: send the line "unsubscribe linux-kselftest" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html