aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/build.py
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-08-08 21:18:41 -0400
committerEli Schwartz <eschwartz@archlinux.org>2022-08-11 07:12:55 -0400
commit00f8ced0486d495ce83ab32c6065dd8ea96f63e8 (patch)
tree0ba4657cddc3ad9090a5b4ba7a47fea9b2da61c3 /mesonbuild/build.py
parentca40dda1467bd8dada7dc7d729c8136f13ccd579 (diff)
downloadmeson-00f8ced0486d495ce83ab32c6065dd8ea96f63e8.zip
meson-00f8ced0486d495ce83ab32c6065dd8ea96f63e8.tar.gz
meson-00f8ced0486d495ce83ab32c6065dd8ea96f63e8.tar.bz2
add compilers from extracted objects directly to build targets
In order to reliably link to static libraries or individual object files, we need to take their languages into account as well. For static libraries this is easy: we just add the static library's list of compilers to the build target. For extracted objects, we need to only add the ones for the objects we use. But we did this really inefficiently -- in fact, downright terribly. We iterated over all source files from the extracted objects, then tried to look up a new compiler for them. Even though the extracted objects already had a list of compilers! This broke once compilers were made per-subproject, because while the extracted objects have a reference to all the compilers it needs (just like static archives do, actually) we might not actually be able to look up that compiler from scratch inside the current subproject. Fix this by asking the extracted objects to categorize all its own sources and return the compilers we want. Fixes #10579
Diffstat (limited to 'mesonbuild/build.py')
-rw-r--r--mesonbuild/build.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index c626ce5..33d91f3 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -39,7 +39,7 @@ from .mesonlib import (
MesonBugException
)
from .compilers import (
- is_object, clink_langs, sort_clink, lang_suffixes, all_languages,
+ is_object, clink_langs, sort_clink, all_languages,
is_known_suffix, detect_static_linker
)
from .interpreterbase import FeatureNew, FeatureDeprecated
@@ -950,12 +950,15 @@ class BuildTarget(Target):
for o in self.objects:
if not isinstance(o, ExtractedObjects):
continue
- for s in o.srclist:
+ compsrcs = o.classify_all_sources(o.srclist, [])
+ for comp in compsrcs:
# Don't add Vala sources since that will pull in the Vala
# compiler even though we will never use it since we are
# dealing with compiled C code.
- if not s.endswith(lang_suffixes['vala']):
- sources.append(s)
+ if comp.language == 'vala':
+ continue
+ if comp.language not in self.compilers:
+ self.compilers[comp.language] = comp
if sources:
# For each source, try to add one compiler that can compile it.
#