* [PATCH v1] perf build: Don't leave a.out file when building with clang
@ 2025-10-06 22:21 Ian Rogers
2025-10-06 22:24 ` Ian Rogers
2025-10-06 23:39 ` Justin Stitt
0 siblings, 2 replies; 3+ messages in thread
From: Ian Rogers @ 2025-10-06 22:21 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, James Clark, linux-perf-users,
linux-kernel, llvm
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>
---
tools/perf/util/setup.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index dd289d15acfd..6caf2126b1cd 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -22,8 +22,16 @@ assert srctree, "Environment variable srctree, for the Linux sources, not set"
src_feature_tests = f'{srctree}/tools/build/feature'
def clang_has_option(option):
- cc_output = Popen([cc, cc_options + option, path.join(src_feature_tests, "test-hello.c") ], 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))] == [ ]
+ error_substrings = (
+ b"unknown argument",
+ b"is not supported",
+ b"unknown warning option"
+ )
+ clang_command = [cc, cc_options + option,
+ "-o", "/dev/null",
+ path.join(src_feature_tests, "test-hello.c") ]
+ cc_output = Popen(clang_command, stderr=PIPE).stderr.readlines()
+ 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
--
2.51.0.618.g983fd99d29-goog
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1] perf build: Don't leave a.out file when building with clang
2025-10-06 22:21 [PATCH v1] perf build: Don't leave a.out file when building with clang Ian Rogers
@ 2025-10-06 22:24 ` Ian Rogers
2025-10-06 23:39 ` Justin Stitt
1 sibling, 0 replies; 3+ messages in thread
From: Ian Rogers @ 2025-10-06 22:24 UTC (permalink / raw)
To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Ian Rogers,
Adrian Hunter, Nathan Chancellor, Nick Desaulniers,
Bill Wendling, Justin Stitt, James Clark, linux-perf-users,
linux-kernel, llvm
On Mon, Oct 6, 2025 at 3:21 PM Ian Rogers <irogers@google.com> wrote:
>
> 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>
Maybe a fixes tag of:
Fixes: 5508672d7f49 perf python: Remove -mcet and -fcf-protection when
building with clang
Thanks,
Ian
> ---
> tools/perf/util/setup.py | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
> index dd289d15acfd..6caf2126b1cd 100644
> --- a/tools/perf/util/setup.py
> +++ b/tools/perf/util/setup.py
> @@ -22,8 +22,16 @@ assert srctree, "Environment variable srctree, for the Linux sources, not set"
> src_feature_tests = f'{srctree}/tools/build/feature'
>
> def clang_has_option(option):
> - cc_output = Popen([cc, cc_options + option, path.join(src_feature_tests, "test-hello.c") ], 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))] == [ ]
> + error_substrings = (
> + b"unknown argument",
> + b"is not supported",
> + b"unknown warning option"
> + )
> + clang_command = [cc, cc_options + option,
> + "-o", "/dev/null",
> + path.join(src_feature_tests, "test-hello.c") ]
> + cc_output = Popen(clang_command, stderr=PIPE).stderr.readlines()
> + 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
> --
> 2.51.0.618.g983fd99d29-goog
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v1] perf build: Don't leave a.out file when building with clang
2025-10-06 22:21 [PATCH v1] perf build: Don't leave a.out file when building with clang Ian Rogers
2025-10-06 22:24 ` Ian Rogers
@ 2025-10-06 23:39 ` Justin Stitt
1 sibling, 0 replies; 3+ messages in thread
From: Justin Stitt @ 2025-10-06 23:39 UTC (permalink / raw)
To: Ian Rogers
Cc: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
Namhyung Kim, Alexander Shishkin, Jiri Olsa, Adrian Hunter,
Nathan Chancellor, Nick Desaulniers, Bill Wendling, James Clark,
linux-perf-users, linux-kernel, llvm
Hi,
On Mon, Oct 06, 2025 at 03:21:16PM -0700, Ian Rogers wrote:
> 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>
> ---
> tools/perf/util/setup.py | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
> index dd289d15acfd..6caf2126b1cd 100644
> --- a/tools/perf/util/setup.py
> +++ b/tools/perf/util/setup.py
> @@ -22,8 +22,16 @@ assert srctree, "Environment variable srctree, for the Linux sources, not set"
> src_feature_tests = f'{srctree}/tools/build/feature'
>
> def clang_has_option(option):
> - cc_output = Popen([cc, cc_options + option, path.join(src_feature_tests, "test-hello.c") ], 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))] == [ ]
> + error_substrings = (
> + b"unknown argument",
> + b"is not supported",
> + b"unknown warning option"
> + )
> + clang_command = [cc, cc_options + option,
> + "-o", "/dev/null",
> + path.join(src_feature_tests, "test-hello.c") ]
> + cc_output = Popen(clang_command, stderr=PIPE).stderr.readlines()
> + 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
> --
> 2.51.0.618.g983fd99d29-goog
>
>
Thanks
Justin
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-06 23:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-06 22:21 [PATCH v1] perf build: Don't leave a.out file when building with clang Ian Rogers
2025-10-06 22:24 ` Ian Rogers
2025-10-06 23:39 ` Justin Stitt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®