aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2025-08-23 14:45:54 +0200
committerJussi Pakkanen <jussi.pakkanen@mailbox.org>2025-08-25 16:49:40 +0300
commit0528ef93e57faa0ad9889b4575af4c00ced7bd7e (patch)
tree752ab1d2f026e7e30f88f019836ddd700bdc8174
parent85f16a129bc5f6b2111187dd302405dc9554d817 (diff)
downloadmeson-0528ef93e57faa0ad9889b4575af4c00ced7bd7e.zip
meson-0528ef93e57faa0ad9889b4575af4c00ced7bd7e.tar.gz
meson-0528ef93e57faa0ad9889b4575af4c00ced7bd7e.tar.bz2
coredata: check for per-subproject compiler and linker arguments
The compiler and linker argument options are special and are only added when the compiler is first discovered. Thus any project-specific values in a child project will remain sitting in pending_options after initialize_from_subproject_call; coredata needs to inform the option store that they now exist. Fixes: #14939 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--mesonbuild/coredata.py10
-rw-r--r--test cases/common/43 subproject options/meson.build2
-rw-r--r--test cases/common/43 subproject options/subprojects/subproject/meson.build6
3 files changed, 16 insertions, 2 deletions
diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py
index 1200fb7..7c8c0c7 100644
--- a/mesonbuild/coredata.py
+++ b/mesonbuild/coredata.py
@@ -582,6 +582,16 @@ class CoreData:
def process_compiler_options(self, lang: str, comp: Compiler, subproject: str) -> None:
self.add_compiler_options(comp.get_options(), lang, comp.for_machine, subproject)
+ for key in [OptionKey(f'{lang}_args'), OptionKey(f'{lang}_link_args')]:
+ if self.is_cross_build():
+ key = key.evolve(machine=comp.for_machine)
+ # the global option is already there, but any augment is still
+ # sitting in pending_options has to be taken into account
+ assert key in self.optstore
+ if subproject:
+ skey = key.evolve(subproject=subproject)
+ self.optstore.add_compiler_option(lang, skey, self.optstore.get_value_object(key))
+
for key in comp.base_options:
if subproject:
skey = key.evolve(subproject=subproject)
diff --git a/test cases/common/43 subproject options/meson.build b/test cases/common/43 subproject options/meson.build
index a905272..d274fbf 100644
--- a/test cases/common/43 subproject options/meson.build
+++ b/test cases/common/43 subproject options/meson.build
@@ -1,4 +1,4 @@
-project('suboptions')
+project('suboptions', default_options: {'c_args': ['-O']})
subproject('subproject')
diff --git a/test cases/common/43 subproject options/subprojects/subproject/meson.build b/test cases/common/43 subproject options/subprojects/subproject/meson.build
index 548d7b4..24a9dc0 100644
--- a/test cases/common/43 subproject options/subprojects/subproject/meson.build
+++ b/test cases/common/43 subproject options/subprojects/subproject/meson.build
@@ -1,7 +1,11 @@
project('subproject', 'c',
- default_options: {'c_std': 'c11'})
+ default_options: {'c_std': 'c11', 'c_args': ['-O2']})
assert(get_option('c_std') == 'c11')
+# could be -O2 as above, or for some cross compilation tests in
+# CI it could come from the machine file. but it's certainly
+# not the value in the top-level project.
+assert(get_option('c_args') != ['-O'])
if get_option('opt')
error('option set when it should be unset.')