From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> commit dd6e1fe91cdd52774ca642d1da75b58a86356b56 upstream. The clang compiler complains about some options even without a source file being available, while others require one, so use the simple tools/build/feature/test-hello.c file. Then check for the "is not supported" string in its output, in addition to the "unknown argument" already being looked for. This was noticed when building with clang-13 where -ffat-lto-objects isn't supported and since we were looking just for "unknown argument" and not providing a source code to clang, was mistakenly assumed as being available and not being filtered to set of command line options provided to clang, leading to a build failure. Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx> Cc: Fangrui Song <maskray@xxxxxxxxxx> Cc: Florian Fainelli <f.fainelli@xxxxxxxxx> Cc: Ian Rogers <irogers@xxxxxxxxxx> Cc: Jiri Olsa <jolsa@xxxxxxxxxx> Cc: John Keeping <john@xxxxxxxxxxxx> Cc: Leo Yan <leo.yan@xxxxxxxxxx> Cc: Michael Petlan <mpetlan@xxxxxxxxxx> Cc: Namhyung Kim <namhyung@xxxxxxxxxx> Cc: Nathan Chancellor <nathan@xxxxxxxxxx> Cc: Nick Desaulniers <ndesaulniers@xxxxxxxxxx> Cc: Sedat Dilek <sedat.dilek@xxxxxxxxx> Link: http://lore.kernel.org/lkml/ Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- tools/perf/util/setup.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py @@ -1,12 +1,14 @@ -from os import getenv +from os import getenv, path from subprocess import Popen, PIPE from re import sub cc = getenv("CC") cc_is_clang = b"clang version" in Popen([cc.split()[0], "-v"], stderr=PIPE).stderr.readline() +src_feature_tests = getenv('srctree') + '/tools/build/feature' def clang_has_option(option): - return [o for o in Popen([cc, option], stderr=PIPE).stderr.readlines() if b"unknown argument" in o] == [ ] + cc_output = Popen([cc, 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))] == [ ] if cc_is_clang: from distutils.sysconfig import get_config_vars Patches currently in stable-queue which might be from acme@xxxxxxxxxx are queue-5.17/perf-unwind-don-t-show-unwind-error-messages-when-au.patch queue-5.17/perf-arm-spe-fix-perf-report-mem-mode.patch queue-5.17/perf-session-remap-buf-if-there-is-no-space-for-even.patch queue-5.17/perf-tools-fix-perf-s-libperf_print-callback.patch queue-5.17/perf-build-don-t-use-ffat-lto-objects-in-the-python-feature-test-when-building-with-clang-13.patch queue-5.17/perf-python-fix-probing-for-some-clang-command-line-options.patch queue-5.17/tools-build-filter-out-options-and-warnings-not-supported-by-clang.patch queue-5.17/tools-build-use-shell-instead-of-to-get-embedded-libperl-s-ccopts.patch