backends: apply per-subproject language args to targets#15990
backends: apply per-subproject language args to targets#15990MaxandreOgeret wants to merge 2 commits into
Conversation
Compile and link args were collected via CoreData.get_external_args() and get_external_link_args(), which build an OptionKey without a subproject. Per-subproject values such as -Dsub:c_args=-DFOO or c_args in the default_options of a subproject() call were stored as augments in the option store but never consulted, so they silently never reached the compile or link command. Resolve the value per target with the existing augment- and override-aware CoreData.get_option_for_target() at the three target-context call sites. As a side effect, <lang>_args and <lang>_link_args entries in a target's override_options now take effect as well. Fixes mesonbuild#13260.
|
This makes me think that the interface for |
|
Agreed, the remaining callers are all target-less, a required subproject
parameter would work for all of them.
It would also fix compiler checks inside a subproject not seeing that
subproject's augments.
I think it should be done in a separate PR though, what do you think?
…On Thu, Jul 9, 2026 at 7:04 PM Dylan Baker ***@***.***> wrote:
*dcbaker* left a comment (mesonbuild/meson#15990)
<#15990 (comment)>
This makes me think that the interface for get_external_args is just a
foot-gun and either needs to be removed or needs to take a subproject:
SubProject required parameter.
—
Reply to this email directly, view it on GitHub
<#15990?email_source=notifications&email_token=AFN3EEWHYCUZXZAYADOJ32L5D6673A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOJSG4YTCNZRGAY2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4927117101>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFN3EEQVQI4T4YNWSFEPZPD5D6673AVCNFSNUABEKJSXA33TNF2G64TZHMYTSNZYGQZDGMR3JFZXG5LFHM2DQNBRHEZTKOBUHCQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AFN3EETE7LRF6JL3G2OM3OT5D6673A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOJSG4YTCNZRGAY2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KUZTPN52GK4S7NFXXG>
and Android
<https://github.com/notifications/mobile/android/AFN3EEQXB3OVDBVLPAWO5LD5D6673A5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOJSG4YTCNZRGAY2M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
|
I think I'd like to see |
|
Sounds good, I'll do that in this PR
…On Thu, Jul 9, 2026 at 8:52 PM Dylan Baker ***@***.***> wrote:
*dcbaker* left a comment (mesonbuild/meson#15990)
<#15990 (comment)>
I think I'd like to see get_external_args and get_external_link_args just
deleted and replaced by calls to get_option_for_target or get_option_value
in a single PR. The interfaces are fundamentally broken, and looking at the
link variant I can see at least two users in modules that are broken in the
same way that the calls you replaced here are.
—
Reply to this email directly, view it on GitHub
<#15990?email_source=notifications&email_token=AFN3EEX5SGJHHVB3VS3FCFD5D7LUJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOJSHAYDCMJZGM22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L#issuecomment-4928011935>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFN3EEQGWDKHMX3F4B6KXVL5D7LUJAVCNFSNUABEKJSXA33TNF2G64TZHMYTSNZYGQZDGMR3JFZXG5LFHM2DQNBRHEZTKOBUHCQXMAQ>
.
Triage notifications, keep track of coding agent tasks and review pull
requests on the go with GitHub Mobile for iOS
<https://github.com/notifications/mobile/ios/AFN3EEWSCJWDRX4JJDURCGT5D7LUJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOJSHAYDCMJZGM22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2KUZTPN52GK4S7NFXXG>
and Android
<https://github.com/notifications/mobile/android/AFN3EEXFNJRNU7CDRQHMUYT5D7LUJA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTIOJSHAYDCMJZGM22M4TFMFZW63VGMF2XI2DPOKSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
Download it today!
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
These wrappers built the OptionKey without a subproject, so any caller in a subproject context silently got the top-level value and per-subproject augments (-Dsub:c_args=...) were ignored. Replace them with explicit optstore.get_value_for() calls that state their subproject at the call site. Module callers (gnome, external_project) now pass the current subproject, so g-ir-scanner, gtkdoc and external project env vars pick up per-subproject language args. Compiler sanity checks, linker detection, the MSVC dep prefix probe and cargo cfg parsing keep the top-level value, but that choice is now visible at the call site. The lru_cache on get_external_link_args is dropped; the lookup is a few dict accesses. gnome's gir scanner appended env flags to the returned list, mutating the cached (now stored) value; it copies the list now.
|
Done, deleted both getters, converted the remaining callers in this PR (modules pass their subproject, detection/sanity-check paths keep the top-level value) Thanks a lot for taking time to review this :) |
|
Thanks for doing all of that, I think the end result is much better! |
Fixes #13260.
Per-subproject language args like
-Dsub:c_args=-DFOO(orc_argsin thedefault_optionsof asubproject()call) are accepted and stored, but never reach the compile or link command.They end up as augments in the option store and resolve fine through a subproject-qualified key - which is why
get_option('c_args')inside the subproject returns the value - but arg collection usesCoreData.get_external_args()/get_external_link_args(), which build theOptionKeywithout a subproject, so the augment is never consulted.Fix: resolve the value per target with the existing augment- and override-aware
get_option_for_target()at the three target-context call sites.The global getters are unchanged where no target context exists (compiler checks, linker detection, modules).Two side effects, noted in the release snippet:
<lang>_args/<lang>_link_argsin a target'soverride_optionsnow take effect (previously validated but ignored), and the per-subproject value replaces the global one rather than appending, consistent withget_option().Added a unit test where sources
#errorif their expected flag is missing; it fails without the fix.--
The second commit deletes get_external_args() / get_external_link_args() as suggested by @dcbaker. Modules now pass their subproject, other callers keep the top-level value explicitly.