diff options
author | Eduardo Habkost <ehabkost@redhat.com> | 2018-10-05 16:40:58 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-10-08 13:30:45 -0400 |
commit | 8b2f245faa6238e28a1d801e8633515251d1acfc (patch) | |
tree | a10f1c137ce8d6ead5e4f24e6e5050f4c5d0b4a2 | |
parent | e13a5d69c31d35538e80176d54d95b6addf4dcbf (diff) |
perf python: More portable way to make CFLAGS work with clang
The existing code that tries to make CFLAGS compatible with clang
doesn't work with Python 3.
Instead of trying to touch _sysconfigdata.build_time_vars directly,
change the dictionary returned by disutils.sysconfig.get_config_vars().
This works on both Python 2 and Python 3.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Reported-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/20181005204058.7966-3-ehabkost@redhat.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/util/setup.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py index 261a55e7e1b2..63f758c655d5 100644 --- a/tools/perf/util/setup.py +++ b/tools/perf/util/setup.py | |||
@@ -9,12 +9,14 @@ def clang_has_option(option): | |||
9 | 9 | ||
10 | cc = getenv("CC") | 10 | cc = getenv("CC") |
11 | if cc == "clang": | 11 | if cc == "clang": |
12 | from _sysconfigdata import build_time_vars | 12 | from distutils.sysconfig import get_config_vars |
13 | build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"]) | 13 | vars = get_config_vars() |
14 | if not clang_has_option("-mcet"): | 14 | for var in ('CFLAGS', 'OPT'): |
15 | build_time_vars["CFLAGS"] = sub("-mcet", "", build_time_vars["CFLAGS"]) | 15 | vars[var] = sub("-specs=[^ ]+", "", vars[var]) |
16 | if not clang_has_option("-fcf-protection"): | 16 | if not clang_has_option("-mcet"): |
17 | build_time_vars["CFLAGS"] = sub("-fcf-protection", "", build_time_vars["CFLAGS"]) | 17 | vars[var] = sub("-mcet", "", vars[var]) |
18 | if not clang_has_option("-fcf-protection"): | ||
19 | vars[var] = sub("-fcf-protection", "", vars[var]) | ||
18 | 20 | ||
19 | from distutils.core import setup, Extension | 21 | from distutils.core import setup, Extension |
20 | 22 | ||