perf python: Remove -fstack-clash-protection when building with some clang versions

This change “perf python: Remove -fstack-clash-protection when building with some clang versions” in Linux kernel is authored by Arnaldo Carvalho de Melo <acme [at]> on Fri Jan 18 11:34:15 2019 -0300.

perf python: Remove -fstack-clash-protection when building with some clang versions

These options are not present in some (all?) 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 rawhide (now gearing towards f30), so check
if clang has the  and remove the missing ones from CFLAGS.

Cc: Eduardo Habkost <>
Cc: Thiago Macieira <>
Cc: Adrian Hunter <>
Cc: Jiri Olsa <>
Cc: Namhyung Kim <>
Signed-off-by: Arnaldo Carvalho de Melo <>

This Linux change may have been applied to various maintained Linux releases and you can find Linux releases including commit a5dcc4c.

There are 2 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 tools/perf/util/ | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/ b/tools/perf/util/
index 63f758c..64d1f36 100644
--- a/tools/perf/util/
+++ b/tools/perf/util/
@@ -17,6 +17,8 @@ if cc == "clang":
             vars[var] = sub("-mcet", "", vars[var])
         if not clang_has_option("-fcf-protection"):
             vars[var] = sub("-fcf-protection", "", vars[var])
+        if not clang_has_option("-fstack-clash-protection"):
+            vars[var] = sub("-fstack-clash-protection", "", vars[var])
 from distutils.core import setup, Extension

The commit for this change in Linux stable tree is a5dcc4c (patch).

Leave a Reply

Your email address will not be published. Required fields are marked *