Skip to content

Commit 0528ef9

Browse files
bonzinijpakkane
authored andcommitted
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 <[email protected]>
1 parent 85f16a1 commit 0528ef9

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

mesonbuild/coredata.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,16 @@ def add_compiler_options(self, c_options: MutableKeyedOptionDictType, lang: str,
582582
def process_compiler_options(self, lang: str, comp: Compiler, subproject: str) -> None:
583583
self.add_compiler_options(comp.get_options(), lang, comp.for_machine, subproject)
584584

585+
for key in [OptionKey(f'{lang}_args'), OptionKey(f'{lang}_link_args')]:
586+
if self.is_cross_build():
587+
key = key.evolve(machine=comp.for_machine)
588+
# the global option is already there, but any augment is still
589+
# sitting in pending_options has to be taken into account
590+
assert key in self.optstore
591+
if subproject:
592+
skey = key.evolve(subproject=subproject)
593+
self.optstore.add_compiler_option(lang, skey, self.optstore.get_value_object(key))
594+
585595
for key in comp.base_options:
586596
if subproject:
587597
skey = key.evolve(subproject=subproject)

test cases/common/43 subproject options/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
project('suboptions')
1+
project('suboptions', default_options: {'c_args': ['-O']})
22

33
subproject('subproject')
44

test cases/common/43 subproject options/subprojects/subproject/meson.build

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
project('subproject', 'c',
2-
default_options: {'c_std': 'c11'})
2+
default_options: {'c_std': 'c11', 'c_args': ['-O2']})
33

44
assert(get_option('c_std') == 'c11')
5+
# could be -O2 as above, or for some cross compilation tests in
6+
# CI it could come from the machine file. but it's certainly
7+
# not the value in the top-level project.
8+
assert(get_option('c_args') != ['-O'])
59

610
if get_option('opt')
711
error('option set when it should be unset.')

0 commit comments

Comments
 (0)