aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian "sp1rit"​ <sp1rit@disroot.org>2025-07-27 10:03:57 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-08-10 22:38:30 +0300
commite6384b088a014f309b82b120db0badd7d8b8bb0e (patch)
tree88d0bca6af60ceef03cd1a9e58673afdd83bbffd
parent50c617bfabf3043c7a99d28112463ad68699b397 (diff)
downloadmeson-e6384b088a014f309b82b120db0badd7d8b8bb0e.zip
meson-e6384b088a014f309b82b120db0badd7d8b8bb0e.tar.gz
meson-e6384b088a014f309b82b120db0badd7d8b8bb0e.tar.bz2
build: Ensure that linker requested in link_language is available
Meson was running into an key lookup failure when evaluating the following: project('proj', 'c') executable('bin', link_language: 'cpp') and since 41eb18d also if the executable contained exclusively header sources.
-rw-r--r--mesonbuild/build.py5
-rw-r--r--test cases/failing/135 rust link_language/meson.build2
2 files changed, 6 insertions, 1 deletions
diff --git a/mesonbuild/build.py b/mesonbuild/build.py
index d489062..83c65b6 100644
--- a/mesonbuild/build.py
+++ b/mesonbuild/build.py
@@ -882,6 +882,11 @@ class BuildTarget(Target):
# did user override clink_langs for this target?
link_langs = [self.link_language] if self.link_language else clink_langs
+ if self.link_language:
+ if self.link_language not in self.all_compilers:
+ m = f'Target {self.name} requires {self.link_language} compiler not part of the project'
+ raise MesonException(m)
+
# If this library is linked against another library we need to consider
# the languages of those libraries as well.
if self.link_targets or self.link_whole_targets:
diff --git a/test cases/failing/135 rust link_language/meson.build b/test cases/failing/135 rust link_language/meson.build
index 695f9c4..195b516 100644
--- a/test cases/failing/135 rust link_language/meson.build
+++ b/test cases/failing/135 rust link_language/meson.build
@@ -1,7 +1,7 @@
# SPDX-license-identifer: Apache-2.0
# Copyright © 2021 Intel Corporation
-project('rust wrong link language')
+project('rust wrong link language', 'c')
if not add_languages('rust', required: false)
error('MESON_SKIP_TEST test requires rust compiler')