aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorXavier Claessens <xavier.claessens@collabora.com>2023-07-10 13:21:41 -0400
committerJussi Pakkanen <jpakkane@gmail.com>2023-07-10 23:12:24 +0300
commit1fef03c0f04e86300bee5ff3f628752d9e27304d (patch)
treeda30cc605ac56797cfa20fb7fdb2cfa87d8d55f7 /mesonbuild
parentcd63853ad2928023ea045fb331866d547e9f49fc (diff)
downloadmeson-1fef03c0f04e86300bee5ff3f628752d9e27304d.zip
meson-1fef03c0f04e86300bee5ff3f628752d9e27304d.tar.gz
meson-1fef03c0f04e86300bee5ff3f628752d9e27304d.tar.bz2
build: dependencies should come after link_with on link command
This fixes regression caused by https://github.com/mesonbuild/meson/commit/3162b901cab46d66a30c66a4406195523714ecdc that changes the order in which libraries are put on the link command. In addition, that commit was wrong because libraries from dependencies were processed before process_compiler() is called, which that commit wanted to avoid.
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/build.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index eb13a89..3cb4a22 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -755,8 +755,19 @@ class BuildTarget(Target):
self.process_objectlist(objects)
self.process_kwargs(kwargs)
self.missing_languages = self.process_compilers()
- self.link(extract_as_list(kwargs, 'link_with'))
- self.link_whole(extract_as_list(kwargs, 'link_whole'))
+
+ # self.link_targets and self.link_whole_targets contains libraries from
+ # dependencies (see add_deps()). They have not been processed yet because
+ # we have to call process_compilers() first and we need to process libraries
+ # from link_with and link_whole first.
+ # See https://github.com/mesonbuild/meson/pull/11957#issuecomment-1629243208.
+ link_targets = extract_as_list(kwargs, 'link_with') + self.link_targets
+ link_whole_targets = extract_as_list(kwargs, 'link_whole') + self.link_whole_targets
+ self.link_targets.clear()
+ self.link_whole_targets.clear()
+ self.link(link_targets)
+ self.link_whole(link_whole_targets)
+
if not any([self.sources, self.generated, self.objects, self.link_whole_targets, self.structured_sources,
kwargs.pop('_allow_no_sources', False)]):
mlog.warning(f'Build target {name} has no sources. '
@@ -1337,8 +1348,8 @@ class BuildTarget(Target):
self.extra_files.extend(f for f in dep.extra_files if f not in self.extra_files)
self.add_include_dirs(dep.include_directories, dep.get_include_type())
self.objects.extend(dep.objects)
- self.link(dep.libraries)
- self.link_whole(dep.whole_libraries)
+ self.link_targets.extend(dep.libraries)
+ self.link_whole_targets.extend(dep.whole_libraries)
if dep.get_compile_args() or dep.get_link_args():
# Those parts that are external.
extpart = dependencies.InternalDependency('undefined',