Skip to content

Commit e99253c

Browse files
bonzinidcbaker
authored andcommitted
build: fix introspection interpreter issue when project selects Rust
The introspection interpreter sometimes produces targets with no source files; BuildTarget will then pick a random compiler, according to the order in clink_langs. According to the comment in sort_clink, clink_langs are supposed to list languages from *lowest* to highest priority. However, process_compilers_late() process clink_langs in straight order and returns the first language; which is the one with lowest priority. This became visible with the addition of Rust to clink_langs, because Rust has limitation on the names of library targets, but the bug existed before. Fixes: e49f2f7 Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 0705795 commit e99253c

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

mesonbuild/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ def process_compilers_late(self) -> None:
900900
# No source files or parent targets, target consists of only object
901901
# files of unknown origin. Just add the first clink compiler
902902
# that we have and hope that it can link these objects
903-
for lang in link_langs:
903+
for lang in reversed(link_langs):
904904
if lang in self.all_compilers:
905905
self.compilers[lang] = self.all_compilers[lang]
906906
break

test cases/rust/20 rust and cpp/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ project(
88
meson_version : '>= 1.2.0',
99
)
1010

11-
cpplib = static_library('cpp', 'lib.cpp')
11+
cpplib = static_library('cpp-lib', 'lib.cpp')
1212
exe = executable('main', 'main.rs', link_with : cpplib)
1313

1414
test('main', exe)

unittests/allplatformstests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,6 +3343,11 @@ def test_meson_configure_from_source_does_not_crash(self):
33433343
testdir = os.path.join(self.unit_test_dir, '58 introspect buildoptions')
33443344
self._run(self.mconf_command + [testdir])
33453345

3346+
@skip_if_not_language('rust')
3347+
def test_meson_configure_srcdir(self):
3348+
testdir = os.path.join(self.rust_test_dir, '20 rust and cpp')
3349+
self._run(self.mconf_command + [testdir])
3350+
33463351
def test_introspect_buildoptions_cross_only(self):
33473352
testdir = os.path.join(self.unit_test_dir, '82 cross only introspect')
33483353
testfile = os.path.join(testdir, 'meson.build')

0 commit comments

Comments
 (0)