[v2,4/4] perf python: only check for the clang features we care about removing

Message ID 9756370bbcf53781b073dfc7953b76db0b69a08b.1672192591.git.nabijaczleweli@nabijaczleweli.xyz
State New
Headers
Series [1/2] perf python: fix clang feature detection littering |

Commit Message

Ahelenia Ziemiańska Dec. 28, 2022, 1:58 a.m. UTC
  Instead of checking for all 6 flags every time for both fields,
only check for the ones we already know are in there.

This means instead of running 2*6 processes, we run, on my Bullseye system,
just one (for -fstack-protector-strong)! This reduces the run-time by
appx. (2*6-1)*.05=550ms (or, without the -c patch, 1.1s).

Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
---
 tools/perf/util/setup.py | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)
  

Patch

diff --git a/tools/perf/util/setup.py b/tools/perf/util/setup.py
index 0a557f2bf357..f4b94c0f9055 100644
--- a/tools/perf/util/setup.py
+++ b/tools/perf/util/setup.py
@@ -14,18 +14,9 @@  if cc_is_clang:
     vars = get_config_vars()
     for var in ('CFLAGS', 'OPT'):
         vars[var] = sub("-specs=[^ ]+", "", vars[var])
-        if not clang_has_option("-mcet"):
-            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])
-        if not clang_has_option("-fstack-protector-strong"):
-            vars[var] = sub("-fstack-protector-strong", "", vars[var])
-        if not clang_has_option("-fno-semantic-interposition"):
-            vars[var] = sub("-fno-semantic-interposition", "", vars[var])
-        if not clang_has_option("-ffat-lto-objects"):
-            vars[var] = sub("-ffat-lto-objects", "", vars[var])
+        for opt in ("-mcet", "-fcf-protection", "-fstack-clash-protection", "-fstack-protector-strong", "-fno-semantic-interposition", "-ffat-lto-objects"):
+            if vars[var].find(opt) != -1 and not clang_has_option(opt):
+                vars[var] = vars[var].replace(opt, "")
 
 from setuptools import setup, Extension