Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf build python: Don't leave a.out file when building with clang

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>

authored by

Ian Rogers and committed by
Namhyung Kim
6090e612 12690401

+10 -3
+10 -3
tools/perf/util/setup.py
··· 23 23 src_feature_tests = f'{srctree}/tools/build/feature' 24 24 25 25 def clang_has_option(option): 26 - cmd = shlex.split(f"{cc} {cc_options} {option}") 27 - cmd.append(path.join(src_feature_tests, "test-hello.c")) 26 + error_substrings = ( 27 + b"unknown argument", 28 + b"is not supported", 29 + b"unknown warning option" 30 + ) 31 + cmd = shlex.split(f"{cc} {cc_options} {option}") + [ 32 + "-o", "/dev/null", 33 + path.join(src_feature_tests, "test-hello.c") 34 + ] 28 35 cc_output = Popen(cmd, stderr=PIPE).stderr.readlines() 29 - 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))] == [ ] 36 + return not any(any(error in line for error in error_substrings) for line in cc_output) 30 37 31 38 if cc_is_clang: 32 39 from sysconfig import get_config_vars