]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
perf python: Filter out -specs=/a/b/c from the python binding cc options
authorArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 16 Feb 2017 00:36:48 +0000 (21:36 -0300)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Fri, 17 Feb 2017 13:31:13 +0000 (10:31 -0300)
The -spec=/path/to/file can be used to change what gcc puts in the cc,
ld, etc command lines, but this is not present in clang, filter it out
at the setup.py file by changing python2's internal variable where it
keeps its initial CFLAGS value.

With this all of perf can be built in at least Fedora 25, fixing this
problem:

    GEN      /tmp/build/perf/python/perf.so
    CC       /tmp/build/perf/builtin-buildid-list.o
  clang-4.0: error: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Werror,-Wunused-command-line-argument]
  clang-4.0: error: argument unused during compilation: '-specs=/usr/lib/rpm/redhat/redhat-hardened-cc1' [-Werror,-Wunused-command-line-argument]
  error: command 'clang' failed with exit status 1

Now I need to change all the containers where I have clang to build
perf with it, so that we can check that in other distros (opensuse, debian,
ubuntu, etc) this also works.

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/n/tip-g9lhgr162ao8ao29vvf0hgm1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/setup.py

index c8680984d2d6680f56a974a1b54056a5e74263e1..af415febbc46e65fd0bdda5cbf1c93f7fa3f9d76 100644 (file)
@@ -1,8 +1,15 @@
 #!/usr/bin/python2
 
-from distutils.core import setup, Extension
 from os import getenv
 
+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"])
+
+from distutils.core import setup, Extension
+
 from distutils.command.build_ext   import build_ext   as _build_ext
 from distutils.command.install_lib import install_lib as _install_lib