Skip to contentSkip to conversation

selftests/binderfs: use the Makefile's rules, not Make's implicit rules

PATCH In review John Hubbard 3 participants 3 messages May 3, 2024 Kselftest

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/binderfs: use the Makefile's rules, not Make's implicit rules

First of all, in order to build with clang at all, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via:

make LLVM=1 -C tools/testing/selftests

...the following error occurs:

clang: error: cannot specify -o when generating multiple output files

This is because clang, unlike gcc, won't accept invocations of this form:

clang file1.c header2.h

While trying to fix this, I noticed that:

a) selftests/lib.mk already avoids the problem, and

b) The binderfs Makefile indavertently bypasses the selftests/lib.mk build system, and quitely uses Make's implicit build rules for .c files instead.

The Makefile attempts to set up both a dependency and a source file, neither of which was needed, because lib.mk is able to automatically handle both. This line:

binderfs_test: binderfs_test.c

...causes Make's implicit rules to run, which builds binderfs_test without ever looking at lib.mk.

Fix this by simply deleting the "binderfs_test:" Makefile target and letting lib.mk handle it instead.

[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/

Fixes 6e29225af902 ("binderfs: port tests to test harness infrastructure")
Cc Christian Brauner <[email protected]>
---
 tools/testing/selftests/filesystems/binderfs/Makefile | 2 --
 1 file changed, 2 deletions(-)
tools/testing/selftests/filesystems/binderfs/Makefile +0 -2
index c2f7cef919c0..eb4c3b411934 100644
@@ -3,6 +3,4 @@
 CFLAGS += $(KHDR_INCLUDES) -pthread
 TEST_GEN_PROGS := binderfs_test
 
-binderfs_test: binderfs_test.c ../../kselftest.h ../../kselftest_harness.h
-
 include ../../lib.mk

base-commit: f03359bca01bf4372cf2c118cd9a987a5951b1c8
prerequisite-patch-id: b901ece2a5b78503e2fb5480f20e304d36a0ea27

Signature · 1 line
2.45.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 35 lines · John Hubbard

First of all, in order to build with clang at all, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via:

make LLVM=1 -C tools/testing/selftests

...the following error occurs:

clang: error: cannot specify -o when generating multiple output files

This is because clang, unlike gcc, won't accept invocations of this form:

clang file1.c header2.h

While trying to fix this, I noticed that:

a) selftests/lib.mk already avoids the problem, and

b) The binderfs Makefile indavertently bypasses the selftests/lib.mk build system, and quitely uses Make's implicit build rules for .c files instead.

The Makefile attempts to set up both a dependency and a source file, neither of which was needed, because lib.mk is able to automatically handle both. This line:

binderfs_test: binderfs_test.c

...causes Make's implicit rules to run, which builds binderfs_test without ever looking at lib.mk.

Fix this by simply deleting the "binderfs_test:" Makefile target and letting lib.mk handle it instead.

Quoted 6 lines

[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/

Fixes 6e29225af902 ("binderfs: port tests to test harness infrastructure")
Cc Christian Brauner <[email protected]>

---

maintainer
#2 lore raw
Quoted 36 lines · Christian Brauner
Quoted 35 lines · John Hubbard

First of all, in order to build with clang at all, one must first apply Valentin Obst's build fix for LLVM [1]. Once that is done, then when building with clang, via:

make LLVM=1 -C tools/testing/selftests

...the following error occurs:

clang: error: cannot specify -o when generating multiple output files

This is because clang, unlike gcc, won't accept invocations of this form:

clang file1.c header2.h

While trying to fix this, I noticed that:

a) selftests/lib.mk already avoids the problem, and

b) The binderfs Makefile indavertently bypasses the selftests/lib.mk build system, and quitely uses Make's implicit build rules for .c files instead.

The Makefile attempts to set up both a dependency and a source file, neither of which was needed, because lib.mk is able to automatically handle both. This line:

binderfs_test: binderfs_test.c

...causes Make's implicit rules to run, which builds binderfs_test without ever looking at lib.mk.

Fix this by simply deleting the "binderfs_test:" Makefile target and letting lib.mk handle it instead.

Quoted 9 lines
Quoted 6 lines

[1] https://lore.kernel.org/all/20240329-selftests-libmk-llvm-rfc-v1-1-2f9ed7d1c49f@valentinobst.de/

Fixes 6e29225af902 ("binderfs: port tests to test harness infrastructure")
Cc Christian Brauner <[email protected]>

---

Thank you. Applied to linunx-kselftest next for Linux 6.10-rc1

thanks,
-- Shuah