Skip to content

Commit dd6e1fe

Browse files
committed
perf python: Fix probing for some clang command line options
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@intel.com> Cc: Fangrui Song <maskray@google.com> Cc: Florian Fainelli <f.fainelli@gmail.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: John Keeping <john@metanate.com> Cc: Leo Yan <leo.yan@linaro.org> Cc: Michael Petlan <mpetlan@redhat.com> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Nick Desaulniers <ndesaulniers@google.com> Cc: Sedat Dilek <sedat.dilek@gmail.com> Link: http://lore.kernel.org/lkml/ Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
1 parent 41caff4 commit dd6e1fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tools/perf/util/setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
from os import getenv
1+
from os import getenv, path
22
from subprocess import Popen, PIPE
33
from re import sub
44

55
cc = getenv("CC")
66
cc_is_clang = b"clang version" in Popen([cc.split()[0], "-v"], stderr=PIPE).stderr.readline()
7+
src_feature_tests = getenv('srctree') + '/tools/build/feature'
78

89
def clang_has_option(option):
9-
return [o for o in Popen([cc, option], stderr=PIPE).stderr.readlines() if b"unknown argument" in o] == [ ]
10+
cc_output = Popen([cc, option, path.join(src_feature_tests, "test-hello.c") ], stderr=PIPE).stderr.readlines()
11+
return [o for o in cc_output if ((b"unknown argument" in o) or (b"is not supported" in o))] == [ ]
1012

1113
if cc_is_clang:
1214
from distutils.sysconfig import get_config_vars

0 commit comments

Comments
 (0)