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.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 34435336
#!/usr/bin/python
from os import getenv
from subprocess import Popen, PIPE
from re import sub
def clang_has_option(option):
return [o for o in Popen(['clang', option], stderr=PIPE).stderr.readlines() if "unknown argument" in o] == [ ]
cc = getenv("CC")
if cc == "clang":
from _sysconfigdata import build_time_vars
from re import sub
build_time_vars["CFLAGS"] = sub("-specs=[^ ]+", "", build_time_vars["CFLAGS"])
if not clang_has_option("-mcet"):
build_time_vars["CFLAGS"] = sub("-mcet", "", build_time_vars["CFLAGS"])
if not clang_has_option("-fcf-protection"):
build_time_vars["CFLAGS"] = sub("-fcf-protection", "", build_time_vars["CFLAGS"])
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