Message ID | 20220324223929.1893741-1-axelrasmussen@google.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 52035628fae646269b1379417926fa3d60ef87d0 |
Headers | show |
Series | [1/2] selftests: fix header dependency for pid_namespace selftests | expand |
On Thu, Mar 24, 2022 at 03:39:28PM -0700, Axel Rasmussen wrote: > The way the test target was defined before, when building with clang we > get a command line like this: > > clang -Wall -Werror -g -I../../../../usr/include/ \ > regression_enomem.c ../pidfd/pidfd.h -o regression_enomem > > This yields an error, because clang thinks we want to produce both a *.o > file, as well as a precompiled header: > > clang: error: cannot specify -o when generating multiple output files > > gcc, for whatever reason, doesn't exhibit the same behavior which I > suspect is why the problem wasn't noticed before. > > This can be fixed simply by using the LOCAL_HDRS infrastructure the > selftests lib.mk provides. It does the right think and marks the target > as depending on the header (so if the header changes, we rebuild), but > it filters the header out of the compiler command line, so we don't get > the error described above. > > Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> > --- Looks good, Reviewed-by: Christian Brauner <brauner@kernel.org>
On 3/24/22 4:39 PM, Axel Rasmussen wrote: > The way the test target was defined before, when building with clang we > get a command line like this: > > clang -Wall -Werror -g -I../../../../usr/include/ \ > regression_enomem.c ../pidfd/pidfd.h -o regression_enomem > > This yields an error, because clang thinks we want to produce both a *.o > file, as well as a precompiled header: > > clang: error: cannot specify -o when generating multiple output files > > gcc, for whatever reason, doesn't exhibit the same behavior which I > suspect is why the problem wasn't noticed before. > Thank you fixing this. > This can be fixed simply by using the LOCAL_HDRS infrastructure the > selftests lib.mk provides. It does the right think and marks the target > as depending on the header (so if the header changes, we rebuild), but > it filters the header out of the compiler command line, so we don't get > the error described above. > > Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> > --- > tools/testing/selftests/pid_namespace/Makefile | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/tools/testing/selftests/pid_namespace/Makefile b/tools/testing/selftests/pid_namespace/Makefile > index dcaefa224ca0..edafaca1aeb3 100644 > --- a/tools/testing/selftests/pid_namespace/Makefile > +++ b/tools/testing/selftests/pid_namespace/Makefile > @@ -1,8 +1,8 @@ > # SPDX-License-Identifier: GPL-2.0 > CFLAGS += -g -I../../../../usr/include/ > > -TEST_GEN_PROGS := regression_enomem > +TEST_GEN_PROGS = regression_enomem > > -include ../lib.mk > +LOCAL_HDRS += $(selfdir)/pidfd/pidfd.h > > -$(OUTPUT)/regression_enomem: regression_enomem.c ../pidfd/pidfd.h > +include ../lib.mk > Will apply this for Linux 5.18-rc2 thanks, -- Shuah
diff --git a/tools/testing/selftests/pid_namespace/Makefile b/tools/testing/selftests/pid_namespace/Makefile index dcaefa224ca0..edafaca1aeb3 100644 --- a/tools/testing/selftests/pid_namespace/Makefile +++ b/tools/testing/selftests/pid_namespace/Makefile @@ -1,8 +1,8 @@ # SPDX-License-Identifier: GPL-2.0 CFLAGS += -g -I../../../../usr/include/ -TEST_GEN_PROGS := regression_enomem +TEST_GEN_PROGS = regression_enomem -include ../lib.mk +LOCAL_HDRS += $(selfdir)/pidfd/pidfd.h -$(OUTPUT)/regression_enomem: regression_enomem.c ../pidfd/pidfd.h +include ../lib.mk
The way the test target was defined before, when building with clang we get a command line like this: clang -Wall -Werror -g -I../../../../usr/include/ \ regression_enomem.c ../pidfd/pidfd.h -o regression_enomem This yields an error, because clang thinks we want to produce both a *.o file, as well as a precompiled header: clang: error: cannot specify -o when generating multiple output files gcc, for whatever reason, doesn't exhibit the same behavior which I suspect is why the problem wasn't noticed before. This can be fixed simply by using the LOCAL_HDRS infrastructure the selftests lib.mk provides. It does the right think and marks the target as depending on the header (so if the header changes, we rebuild), but it filters the header out of the compiler command line, so we don't get the error described above. Signed-off-by: Axel Rasmussen <axelrasmussen@google.com> --- tools/testing/selftests/pid_namespace/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)