aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo <acme@redhat.com>2018-08-14 17:00:40 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2018-08-14 17:50:20 -0400
commit5508672d7f4949f15c316ffd947228f130498534 (patch)
treeb087e2cb8503499d890f6924ed45c45bdc3fecf4
parent344353366591acf659a0d0dea498611da78d67e2 (diff)
perf python: Remove -mcet and -fcf-protection when building with clang
These options are not present in older clang versions, so when we build for a distro that has a gcc new enough to have these options and that the distro python build config settings use them but clang doesn't support, b00m. This is the case with fedora 28 and rawhide, so check if clang has the options and remove the missing ones from CFLAGS. 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: https://lkml.kernel.org/n/tip-7asds7yn6gzg6ns1lw17ukul@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--tools/perf/util/setup.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 001be4f9d3b9..97efbcad076e 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -1,12 +1,20 @@
1#!/usr/bin/python 1#!/usr/bin/python
2 2
3from os import getenv 3from os import getenv
4from subprocess import Popen, PIPE
5from re import sub
6
7def clang_has_option(option):
8 return [o for o in Popen(['clang', option], stderr=PIPE).stderr.readlines() if "unknown argument" in o] == [ ]
4 9
5cc = getenv("CC") 10cc = getenv("CC")
6if cc == "clang": 11if cc == "clang":
7 from _sysconfigdata import build_time_vars 12 from _sysconfigdata import build_time_vars
8 from re import sub
9 build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"]) 13 build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"])
14 if not clang_has_option("-mcet"):
15 build_time_vars["CFLAGS"] = sub("-mcet", "", build_time_vars["CFLAGS"])
16 if not clang_has_option("-fcf-protection"):
17 build_time_vars["CFLAGS"] = sub("-fcf-protection", "", build_time_vars["CFLAGS"])
10 18
11from distutils.core import setup, Extension 19from distutils.core import setup, Extension
12 20