From 0528ef93e57faa0ad9889b4575af4c00ced7bd7e Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Sat, 23 Aug 2025 14:45:54 +0200 Subject: 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 --- mesonbuild/coredata.py | 10 ++++++++++ test cases/common/43 subproject options/meson.build | 2 +- .../43 subproject options/subprojects/subproject/meson.build | 6 +++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mesonbuild/coredata.py b/mesonbuild/coredata.py index 1200fb7b2..7c8c0c726 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 a90527294..d274fbfcd 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 548d7b4e3..24a9dc0e7 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.') -- cgit v1.2.3