aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2020-08-17 15:36:40 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2020-08-18 08:11:25 +0200
commit847bb4347039e8f52c661a6d9cddd411f42b41ed (patch)
tree018ddefa47a059897a59dcf54189f9a3b113ac64
parentcbde13850f1334ef3019288096ccd95dfcdaec6e (diff)
downloadmeson-847bb4347039e8f52c661a6d9cddd411f42b41ed.zip
meson-847bb4347039e8f52c661a6d9cddd411f42b41ed.tar.gz
meson-847bb4347039e8f52c661a6d9cddd411f42b41ed.tar.bz2
clike: optimize to_native
Look for group-able flags with a single regex match, since we are already using regexes for .so files. Also weed out flags other than -isystem very quickly with a single startswith call. On a QEMU build, the time spent in to_native goes from 2.279s to 1.322s.
-rw-r--r--mesonbuild/compilers/mixins/clike.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/mesonbuild/compilers/mixins/clike.py b/mesonbuild/compilers/mixins/clike.py
index 95b9592..4311fa5 100644
--- a/mesonbuild/compilers/mixins/clike.py
+++ b/mesonbuild/compilers/mixins/clike.py
@@ -40,7 +40,9 @@ from .visualstudio import VisualStudioLikeCompiler
if T.TYPE_CHECKING:
from ...environment import Environment
-SOREGEX = re.compile(r'.*\.so(\.[0-9]+)?(\.[0-9]+)?(\.[0-9]+)?$')
+GROUP_FLAGS = re.compile(r'''\.so (?:\.[0-9]+)? (?:\.[0-9]+)? (?:\.[0-9]+)?$ |
+ ^(?:-Wl,)?-l |
+ \.a$''', re.X)
class CLikeCompilerArgs(arglist.CompilerArgs):
prepend_prefixes = ('-I', '-L')
@@ -69,8 +71,7 @@ class CLikeCompilerArgs(arglist.CompilerArgs):
group_start = -1
group_end = -1
for i, each in enumerate(new):
- if not each.startswith(('-Wl,-l', '-l')) and not each.endswith('.a') and \
- not SOREGEX.match(each):
+ if not GROUP_FLAGS.search(each):
continue
group_end = i
if group_start < 0:
@@ -85,6 +86,9 @@ class CLikeCompilerArgs(arglist.CompilerArgs):
default_dirs = self.compiler.get_default_include_dirs()
bad_idx_list = [] # type: T.List[int]
for i, each in enumerate(new):
+ if not each.startswith('-isystem'):
+ continue
+
# Remove the -isystem and the path if the path is a default path
if (each == '-isystem' and
i < (len(new) - 1) and
@@ -92,7 +96,7 @@ class CLikeCompilerArgs(arglist.CompilerArgs):
bad_idx_list += [i, i + 1]
elif each.startswith('-isystem=') and each[9:] in default_dirs:
bad_idx_list += [i]
- elif each.startswith('-isystem') and each[8:] in default_dirs:
+ elif each[8:] in default_dirs:
bad_idx_list += [i]
for i in reversed(bad_idx_list):
new.pop(i)