Commit 8b2f245f authored by Eduardo Habkost's avatar Eduardo Habkost Committed by Arnaldo Carvalho de Melo

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: default avatarEduardo Habkost <ehabkost@redhat.com>
Reported-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Tested-by: default avatarArnaldo 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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent e13a5d69
...@@ -9,12 +9,14 @@ def clang_has_option(option): ...@@ -9,12 +9,14 @@ def clang_has_option(option):
cc = getenv("CC") cc = getenv("CC")
if cc == "clang": if cc == "clang":
from _sysconfigdata import build_time_vars from distutils.sysconfig import get_config_vars
build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"]) vars = get_config_vars()
if not clang_has_option("-mcet"): for var in ('CFLAGS', 'OPT'):
build_time_vars["CFLAGS"] = sub("-mcet", "", build_time_vars["CFLAGS"]) vars[var] = sub("-specs=[^ ]+", "", vars[var])
if not clang_has_option("-fcf-protection"): if not clang_has_option("-mcet"):
build_time_vars["CFLAGS"] = sub("-fcf-protection", "", build_time_vars["CFLAGS"]) vars[var] = sub("-mcet", "", vars[var])
if not clang_has_option("-fcf-protection"):
vars[var] = sub("-fcf-protection", "", vars[var])
from distutils.core import setup, Extension from distutils.core import setup, Extension
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment