Re: [PATCH 5.6 00/23] 5.6.1-rc1 review

From: Daniel DÃaz
Date: Wed Apr 01 2020 - 09:46:10 EST


Hello!


On Wed, 1 Apr 2020 at 06:40, Arnaldo Carvalho de Melo
<arnaldo.melo@xxxxxxxxx> wrote:
> Can you please try the one-liner at the end of this message?
[...]
>
> From 2a88ba6ddf54a4340f5a5f896705d5e42561e210 Mon Sep 17 00:00:00 2001
> From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> Date: Wed, 1 Apr 2020 09:33:59 -0300
> Subject: [PATCH 1/1] perf python: Fix clang detection to strip out options
> passed in $CC
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> The clang check in the python setup.py 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/subprocess.py", line 729, in __init__
> restore_signals, start_new_session)
> File "/usr/lib/python3.6/subprocess.py", 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().
>
> Reported-by: Daniel DÃaz <daniel.diaz@xxxxxxxxxx>
> Reported-by: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx>
> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> Cc: Arnaldo Carvalho de Melo <arnaldo.melo@xxxxxxxxx>,
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> ---
> tools/perf/util/setup.py | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
> index 8a065a6f9713..347b2c0789e4 100644
> --- a/tools/perf/util/setup.py
> +++ b/tools/perf/util/setup.py
> @@ -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] == [ ]
> --
> 2.21.1

This worked on top of torvalds/master and linux-stable-rc/linux-5.6.y.

Thanks and greetings!

Daniel DÃaz
daniel.diaz@xxxxxxxxxx