[lkml]   [2020]   [Apr]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[tip: perf/urgent] perf python: Fix clang detection to strip out options passed in $CC
The following commit has been merged into the perf/urgent branch of tip:

Commit-ID: 9ff76cea4e9e6d49a6f764ae114fc0fb8de97816
Author: Arnaldo Carvalho de Melo <>
AuthorDate: Wed, 01 Apr 2020 09:33:59 -03:00
Committer: Arnaldo Carvalho de Melo <>
CommitterDate: Fri, 03 Apr 2020 10:04:59 -03:00

perf python: Fix clang detection to strip out options passed in $CC

The clang check in the python file expected $CC to be just the
name of the compiler, not the compiler + options, i.e. all options were
expected to be passed in $CFLAGS, this ends up making it fail in systems
where CC is set to, e.g.:

"aarch64-linaro-linux-gcc --sysroot=/oe/build/tmp/work/juno-linaro-linux/perf/1.0-r9/recipe-sysroot"

Like this:

$ python3
>>> from subprocess import Popen
>>> a = Popen(["aarch64-linux-gnu-gcc --sysroot=/oe/build/tmp/work/juno-linaro-linux/perf/1.0-r9/recipe-sysroot", "-v"])
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/", line 729, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.6/", line 1364, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'aarch64-linux-gnu-gcc --sysroot=/oe/build/tmp/work/juno-linaro-linux/perf/1.0-r9/recipe-sysroot': 'aarch64-linux-gnu-gcc --sysroot=/oe/build/tmp/work/juno-linaro-linux/perf/1.0-r9/recipe-sysroot'

Make it more robust, covering this case, by passing cc.split()[0] as the
first arg to popen().

Fixes: a7ffd416d804 ("perf python: Fix clang detection when using CC=clang-version")
Reported-by: Daniel Díaz <>
Reported-by: Naresh Kamboju <>
Tested-by: Daniel Díaz <>
Cc: Adrian Hunter <>
Cc: Ilie Halip <>
Cc: Jiri Olsa <>
Cc: Namhyung Kim <>
Signed-off-by: Arnaldo Carvalho de Melo <>
tools/perf/util/ | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/ b/tools/perf/util/
index 8a065a6..347b2c0 100644
--- a/tools/perf/util/
+++ b/tools/perf/util/
@@ -3,7 +3,7 @@ from subprocess import Popen, PIPE
from re import sub

cc = getenv("CC")
-cc_is_clang = b"clang version" in Popen([cc, "-v"], stderr=PIPE).stderr.readline()
+cc_is_clang = b"clang version" in Popen([cc.split()[0], "-v"], stderr=PIPE).stderr.readline()

def clang_has_option(option):
return [o for o in Popen([cc, option], stderr=PIPE).stderr.readlines() if b"unknown argument" in o] == [ ]
 \ /
  Last update: 2020-04-04 10:45    [W:0.102 / U:0.376 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site