Skip to content

Commit 5508672

Browse files
committed
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>
1 parent 3443533 commit 5508672

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

tools/perf/util/setup.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
#!/usr/bin/python
22

33
from os import getenv
4+
from subprocess import Popen, PIPE
5+
from re import sub
6+
7+
def clang_has_option(option):
8+
return [o for o in Popen(['clang', option], stderr=PIPE).stderr.readlines() if "unknown argument" in o] == [ ]
49

510
cc = getenv("CC")
611
if cc == "clang":
712
from _sysconfigdata import build_time_vars
8-
from re import sub
913
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"])
1018

1119
from distutils.core import setup, Extension
1220

0 commit comments

Comments
 (0)