clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
Subsystems (2)
kernel test robot
build bot::::::
:::::: Manual check reason: "low confidence bisect report" ::::::
BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Ryan Roberts <[email protected]>
CC: Andrew Morton <[email protected]>
CC: Linux Memory Management List <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 7efd0a74039fb6b584be2cb91c1d0ef0bd796ee1 commit: c652df8a4a9d7853fa1100b244024fd6f1a9c18a selftests: link libasan statically for tests with -fsanitize=address date: 7 months ago
:::::: branch date: 17 hours ago
:::::: commit date: 7 months ago
compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240414/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/
All errors (new ones prefixed by >>):
>> clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'? -- >> clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
clang: error: cannot specify -o when generating multiple output files
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
+ Arnd
Quoted 17 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 7efd0a74039fb6b584be2cb91c1d0ef0bd796ee1 commit: c652df8a4a9d7853fa1100b244024fd6f1a9c18a selftests: link libasan statically for tests with -fsanitize=address compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/All errors (new ones prefixed by >>):
#
tools/testing/selftests/fchmodat2$make CC=clang
clang -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan -isystem usr/includefchmodat2_test.c-otools/testing/selftests/fchmodat2/fchmodat2_test
clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
make: *** [../lib.mk:181:tools/testing/selftests/fchmodat2/fchmodat2_test] Error 1
Quoted 6 lines
#
tools/testing/selftests/openat2$make CC=clang
clang -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasanopenat2_test.chelpers.chelpers.h-otools/testing/selftests/openat2/openat2_test
clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
clang: error: cannot specify -o when generating multiple output files
make: *** [../lib.mk:181:tools/testing/selftests/openat2/openat2_test] Error 1
Hi Arnd,
This change went in quite a while ago and is on;y just blowing up. I saw your comment in another thread [1] that Andrew merged your change to set -Wextra. Perhaps that's what has caused this to show up only now? *although I don't actually see -Wextra in the command line).
I guess the problem is that -static-libasan is only supported by gcc. But I'm Makefile-illiterate. Can anyone advise on what's the best way to make this argument gcc-only?
Thanks,
Ryan
Quoted 27 lines · Ryan Roberts
Quoted 17 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 7efd0a74039fb6b584be2cb91c1d0ef0bd796ee1 commit: c652df8a4a9d7853fa1100b244024fd6f1a9c18a selftests: link libasan statically for tests with -fsanitize=address compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/All errors (new ones prefixed by >>):
#
tools/testing/selftests/fchmodat2$make CC=clang
clang -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan -isystem usr/includefchmodat2_test.c-otools/testing/selftests/fchmodat2/fchmodat2_test
clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
make: *** [../lib.mk:181:tools/testing/selftests/fchmodat2/fchmodat2_test] Error 1Quoted 6 lines
#
tools/testing/selftests/openat2$make CC=clang
clang -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasanopenat2_test.chelpers.chelpers.h-otools/testing/selftests/openat2/openat2_test
clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
clang: error: cannot specify -o when generating multiple output files
make: *** [../lib.mk:181:tools/testing/selftests/openat2/openat2_test] Error 1Hi Arnd,
Quoted 8 lines
This change went in quite a while ago and is on;y just blowing up. I saw your comment in another thread [1] that Andrew merged your change to set -Wextra. Perhaps that's what has caused this to show up only now? *although I don't actually see -Wextra in the command line).
I guess the problem is that
-static-libasanis only supported by gcc. But I'm Makefile-illiterate. Can anyone advise on what's the best way to make this argument gcc-only?
Thanks for letting me know about the problem, I had indeed missed build-testing any of tools/testing, so this might not be the only problem there.
I'm not entirely sure how much of the Kbuild infrastructure we can rely on here. If the .config file gets included, this should work:
tools/testing/selftests/fchmodat2/Makefile +7 -1
@@ -1,6 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-or-later -CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan $(KHDR_INCLUDES) +CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined $(KHDR_INCLUDES) +ifdef CONFIG_CC_IS_GCC +CFLAGS += -static-libasan +else +CFLAGS += -static-libsan +endif + TEST_GEN_PROGS := fchmodat2_test include ../lib.mk
Alternatively, if the cc-option macro is available, you could try this one
CFLAGS += $(call cc-option, -static-libasan) $(call cc-option, -static-libsan)
Arnd
Quoted 62 lines · Arnd Bergmann
Quoted 27 lines · Ryan Roberts
Quoted 17 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 7efd0a74039fb6b584be2cb91c1d0ef0bd796ee1 commit: c652df8a4a9d7853fa1100b244024fd6f1a9c18a selftests: link libasan statically for tests with -fsanitize=address compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/All errors (new ones prefixed by >>):
#
tools/testing/selftests/fchmodat2$make CC=clang
clang -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan -isystem usr/includefchmodat2_test.c-otools/testing/selftests/fchmodat2/fchmodat2_test
clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
make: *** [../lib.mk:181:tools/testing/selftests/fchmodat2/fchmodat2_test] Error 1Quoted 6 lines
#
tools/testing/selftests/openat2$make CC=clang
clang -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasanopenat2_test.chelpers.chelpers.h-otools/testing/selftests/openat2/openat2_test
clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
clang: error: cannot specify -o when generating multiple output files
make: *** [../lib.mk:181:tools/testing/selftests/openat2/openat2_test] Error 1Hi Arnd,
Quoted 8 lines
This change went in quite a while ago and is on;y just blowing up. I saw your comment in another thread [1] that Andrew merged your change to set -Wextra. Perhaps that's what has caused this to show up only now? *although I don't actually see -Wextra in the command line).
I guess the problem is that
-static-libasanis only supported by gcc. But I'm Makefile-illiterate. Can anyone advise on what's the best way to make this argument gcc-only?Thanks for letting me know about the problem, I had indeed missed build-testing any of
tools/testing, so this might not be the only problem there.I'm not entirely sure how much of the
Kbuildinfrastructure we can rely on here. If the .config file gets included, this should work:tools/testing/selftests/fchmodat2/Makefile +7
-1@@ -1,6 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-or-later -CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan $(KHDR_INCLUDES) +CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined $(KHDR_INCLUDES) +ifdef CONFIG_CC_IS_GCC +CFLAGS += -static-libasan +else +CFLAGS += -static-libsan +endif + TEST_GEN_PROGS := fchmodat2_test include ../lib.mk
Quoted 6 lines
Alternatively, if the cc-option macro is available, you could try this one
CFLAGS += $(call cc-option, -static-libasan) $(call cc-option, -static-libsan)
Arnd
Thanks! I'll give this a try. Although I can't actually find any mention of -static-libsan in the clang manual. I believe I read somewhere that static linking is default for clang, so worst case, I guess we just leave it out (presumably that's effectively been the case so far anyway).
Quoted 37 lines · Arnd Bergmann
Quoted 27 lines · Ryan Roberts
Quoted 17 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 7efd0a74039fb6b584be2cb91c1d0ef0bd796ee1 commit: c652df8a4a9d7853fa1100b244024fd6f1a9c18a selftests: link libasan statically for tests with -fsanitize=address compiler: clang version 17.0.6 (https://github.com/llvm/llvm-project 6009708b4367171ccdbf4b5905cb6a803753fe18)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/All errors (new ones prefixed by >>):
#
tools/testing/selftests/fchmodat2$make CC=clang
clang -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan -isystem usr/includefchmodat2_test.c-otools/testing/selftests/fchmodat2/fchmodat2_test
clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
make: *** [../lib.mk:181:tools/testing/selftests/fchmodat2/fchmodat2_test] Error 1Quoted 6 lines
#
tools/testing/selftests/openat2$make CC=clang
clang -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasanopenat2_test.chelpers.chelpers.h-otools/testing/selftests/openat2/openat2_test
clang: error: unknown argument '-static-libasan'; did you mean '-static-libsan'?
clang: error: cannot specify -o when generating multiple output files
make: *** [../lib.mk:181:tools/testing/selftests/openat2/openat2_test] Error 1Hi Arnd,
Quoted 8 lines
This change went in quite a while ago and is on;y just blowing up. I saw your comment in another thread [1] that Andrew merged your change to set -Wextra. Perhaps that's what has caused this to show up only now? *although I don't actually see -Wextra in the command line).
I guess the problem is that
-static-libasanis only supported by gcc. But I'm Makefile-illiterate. Can anyone advise on what's the best way to make this argument gcc-only?
Quoted 7 lines
Thanks for letting me know about the problem, I had indeed missed build-testing any of
tools/testing, so this might not be the only problem there.I'm not entirely sure how much of the
Kbuildinfrastructure we can rely on here. If the .config file gets included, this should work:
Thanks for the pointers. Unfortunately neither don't works as we don't have any of the Kbuild infrastructure.
I'm not really sure what to do here. The best I've come up with so far is to just remove asan from these binaries. They are pretty simple selftests. I'm not sure its adding a whole lot of value anyway.
Does anyone have any advice?
Quoted 24 lines
tools/testing/selftests/fchmodat2/Makefile +7
-1@@ -1,6 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-or-later -CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan $(KHDR_INCLUDES) +CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined $(KHDR_INCLUDES) +ifdef CONFIG_CC_IS_GCC +CFLAGS += -static-libasan +else +CFLAGS += -static-libsan +endif + TEST_GEN_PROGS := fchmodat2_test include ../lib.mkAlternatively, if the cc-option macro is available, you could try this one
CFLAGS += $(call cc-option, -static-libasan) $(call cc-option, -static-libsan)
Arnd
Quoted 7 lines · Ryan Roberts
Quoted 5 lines · Arnd Bergmann
On Tue, Apr 16, 2024, at 16:33, Ryan Roberts wrote:
I'm not entirely sure how much of the
Kbuildinfrastructure we can rely on here. If the .config file gets included, this should work:
Quoted 14 lines
Thanks for the pointers. Unfortunately neither don't works as we don't have any of the
Kbuildinfrastructure.I'm not really sure what to do here. The best I've come up with so far is to just remove asan from these binaries. They are pretty simple selftests. I'm not sure its adding a whole lot of value anyway.
Does anyone have any advice?
Quoted 4 lines
Alternatively, if the cc-option macro is available, you could try this one
CFLAGS += $(call cc-option, -static-libasan) $(call cc-option, -static-libsan)
I had another look at this and found example code in tools/thermal/tmon/Makefile that you should be able to adapt. Apparently the cc-option macro is not provided by default, but there is a copy you can include:
# We need this for the "cc-option" macro.
include ../../build/Build.include
WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int override CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS}
# Add "-fstack-protector" only if toolchain supports it.
override CFLAGS+= $(call cc-option,-fstack-protector-strong)
Quoted 28 lines · Arnd Bergmann
Quoted 7 lines · Ryan Roberts
Quoted 5 lines · Arnd Bergmann
On Tue, Apr 16, 2024, at 16:33, Ryan Roberts wrote:
I'm not entirely sure how much of the
Kbuildinfrastructure we can rely on here. If the .config file gets included, this should work:Quoted 14 lines
Thanks for the pointers. Unfortunately neither don't works as we don't have any of the
Kbuildinfrastructure.I'm not really sure what to do here. The best I've come up with so far is to just remove asan from these binaries. They are pretty simple selftests. I'm not sure its adding a whole lot of value anyway.
Does anyone have any advice?
Quoted 4 lines
Alternatively, if the cc-option macro is available, you could try this one
CFLAGS += $(call cc-option, -static-libasan) $(call cc-option, -static-libsan)
I had another look at this and found example code in
tools/thermal/tmon/Makefilethat you should be able to adapt. Apparently the cc-option macro is not provided by default, but there is a copy you can include:
Quoted 6 lines
# We need this for the "cc-option" macro.
include ../../build/Build.include
WARNFLAGS=-Wall -Wshadow -W -Wformat -Wimplicit-function-declaration -Wimplicit-int override CFLAGS+= $(call cc-option,-O3,-O1) ${WARNFLAGS}
# Add "-fstack-protector" only if toolchain supports it.
override CFLAGS+= $(call cc-option,-fstack-protector-strong)
Ahh thanks! That sorted it:
(quoted diff) +0 -0
b/tools/testing/selftests/fchmodat2/Makefile
index 71ec34bf1501..a68bb5a00797 100644
tools/testing/selftests/fchmodat2/Makefile +2 -1
@@ -1,6 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-or-later +# We need this for the "cc-option" macro. +include ../../../build/Build.include -CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan
$(KHDR_INCLUDES)
+CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined $(KHDR_INCLUDES) +CFLAGS += $(call cc-option, -static-libasan) $(call cc-option, -static-libsan)
TEST_GEN_PROGS := fchmodat2_test
include ../lib.mk
(quoted diff) +0 -0
b/tools/testing/selftests/openat2/Makefile
index 254d676a2689..02af9b6ca5eb 100644
tools/testing/selftests/openat2/Makefile +5 -2
@@ -1,8 +1,11 @@ # SPDX-License-Identifier: GPL-2.0-or-later +# We need this for the "cc-option" macro. +include ../../../build/Build.include -CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined -static-libasan +CFLAGS += -Wall -O2 -g -fsanitize=address -fsanitize=undefined +CFLAGS += $(call cc-option, -static-libasan) $(call cc-option, -static-libsan) TEST_GEN_PROGS := openat2_test resolve_test rename_attack_test include ../lib.mk -$(TEST_GEN_PROGS): helpers.c helpers.h +$(TEST_GEN_PROGS): helpers.c
I'll tidy this up and send it out.
Thanks,
Ryan