]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
perf build python: Don't leave a.out file when building with clang
authorIan Rogers <irogers@google.com>
Tue, 7 Oct 2025 15:38:35 +0000 (08:38 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Mon, 13 Oct 2025 08:58:51 +0000 (01:58 -0700)
Testing clang features doesn't specify a "-o" option so an a.out file
is created and left in the make directory (not the output). Fix this
by specifying a "-o" of "/dev/null". Reorganize the code a little to
help with readability.

Signed-off-by: Ian Rogers <irogers@google.com>
Tested-by: Justin Stitt <justinstitt@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/setup.py

index 9cae2c472f4ad4d9579e8528b8bb0152df6fe20e..b65b1792ca056f2ba5d673c5d571adfdf16dbd77 100644 (file)
@@ -23,10 +23,17 @@ assert srctree, "Environment variable srctree, for the Linux sources, not set"
 src_feature_tests  = f'{srctree}/tools/build/feature'
 
 def clang_has_option(option):
-    cmd = shlex.split(f"{cc} {cc_options} {option}")
-    cmd.append(path.join(src_feature_tests, "test-hello.c"))
+    error_substrings = (
+        b"unknown argument",
+        b"is not supported",
+        b"unknown warning option"
+    )
+    cmd = shlex.split(f"{cc} {cc_options} {option}") + [
+        "-o", "/dev/null",
+        path.join(src_feature_tests, "test-hello.c")
+    ]
     cc_output = Popen(cmd, stderr=PIPE).stderr.readlines()
-    return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o) or (b"unknown warning option" in o))] == [ ]
+    return not any(any(error in line for error in error_substrings) for line in cc_output)
 
 if cc_is_clang:
     from sysconfig import get_config_vars