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

From: Ahelenia Ziemiańska
Date: Tue Dec 27 2022 - 20:59:26 EST


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@xxxxxxxxxxxxxxxxxx>
---
tools/perf/util/setup.py | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)

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

--
2.30.2

Attachment: signature.asc
Description: PGP signature