Skip to content

Conversation

bonzini
Copy link
Collaborator

@bonzini bonzini commented Aug 26, 2025

Move "opt=value from machine file/command line" before subproject-specific values from project() or subproject().

Fixes: #14940

@bonzini bonzini added regression options Meson configuration options labels Aug 26, 2025
@bonzini bonzini force-pushed the fix14940 branch 2 times, most recently from b2ceea6 to b3c6a4c Compare August 26, 2025 10:19
@bonzini bonzini marked this pull request as ready for review August 27, 2025 11:07
@bonzini bonzini requested a review from jpakkane as a code owner August 27, 2025 11:07
@bonzini bonzini added this to the 1.9.1 milestone Aug 29, 2025
This reverts commit 5ab871b.
It is not needed anymore since the pre-1.8 semantics were the
good ones.
This reverts commit 9b1eb8b.
It is not needed anymore since the pre-1.8 semantics were the
good ones.

Only leave in place the new and clearer testcase names.
@bonzini
Copy link
Collaborator Author

bonzini commented Sep 10, 2025

Ping @jpakkane

- `opt=value` from machine file
- `opt=value` from command line
- `subp:opt=value` from parent project's default options
- `opt=value` from `subproject()` `default_options`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems incorrect. The command line should override anything set in project files. (given the description this list is sorted on increasing precedence)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was also what I thought when preparing the changes that went into 1.8.4. But it turns out that making two separate groups for global settings and augments (the machine file and command line winning in each group only) is more useful, and there are projects in the wild that rely on it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is it more useful specifically?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For example you can give -Dwerror=true but meson.build can override it to false for subprojects that are known to not behave; likewise for -Dwarning_level. It is also more in line with how default_library works in pre-1.8 releases (see the reverted test changes in this PR).

Besides, we got reports like #15006 where the new ordering breaks existing projects that worked before 1.8.4. I didn't have much time to debug what exactly caused the breakage, but this patch does fix it. So, while overall the new option code is now tamed, I think this part has to be rolled back.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even the documentation says so:

This is useful, for example, when building shared libraries in the main project and statically linking a subproject, or when the main project must build with no warnings but some subprojects cannot.

But the trick doesn't work anymore in 1.8.4

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem here seems to be that the table collates two different things making it hard to comprehend. Maybe it should be split in two, with a structure like:

  • Per-subproject settings always override the default value, no matter how or where they are defined
  • When configuring for the first time, values for options (and overrides) are used in the following order

And maybe have the array in decreasing order of priority, as that seems to be the more logical order.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even that is not unambiguously true, though I agree it's as close as you can get, because -Dopt does override "opt=value from subproject's default_options" which is subproject-specific. So I don't think it's much better than listing the possibilities one by one.

That said do you agree now that the ordering as implemented by the patch makes sense?

@jpakkane jpakkane merged commit 8bba5d0 into mesonbuild:master Sep 15, 2025
33 of 35 checks passed
@bonzini bonzini modified the milestones: 1.9.1, 1.8.5 Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
options Meson configuration options regression
Projects
None yet
Development

Successfully merging this pull request may close these issues.

subp:opt=value in main project's default_options is overridden by opt=value from command line since meson 1.8.4
2 participants