Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--default-library specified in crossfile and command line works inconsistently once reconfigured #11294

Open
sfan5 opened this issue Jan 13, 2023 · 5 comments

Comments

@sfan5
Copy link

sfan5 commented Jan 13, 2023

Describe the bug
Situation: Your cross file specifies libraries to build as static, but you configure a certain project to build as shared.
You configure, build, get a shared library and all is fine.
Then you edit your cross file in any way. The next time you build meson will automatically reconfigure, the shared setting gets "lost" and you suddenly get a static library.

To Reproduce
meson.build:

project('hello', 'c')
library('hello', 'hello.c')

hello.c:

int hello;

crossfile.txt

[built-in options]
default_library = 'static'
  1. meson build --cross-file crossfile.txt --default-library shared
  2. meson compile -C build -> [2/2] Linking target libhello.so
  3. touch crossfile.txt
  4. meson compile -C build -> a reconfigure runs and you get [2/2] Linking static target libhello.a

Expected behavior
Step 4 still links a shared library.

system parameters

  • Native build (but doesn't matter)
  • Arch Linux x86_64
  • Python 3.10.9
  • what meson --version: 1.0.0
  • what ninja --version: 1.11.1
@tristan957
Copy link
Contributor

I wonder what the intended behavior is supposed to be. Are you of any docs that talk about this precedence?

@StratusFearMe21
Copy link

StratusFearMe21 commented Jan 17, 2023

@tristan957 This is what the docs say the precedence should be

You can set some Meson built-in options on a per-subproject basis, such as default_library and werror. The order of precedence is:

  1. Command line
  2. Machine file
  3. Build system definitions

@sfan5
Copy link
Author

sfan5 commented May 11, 2023

Issue persists in meson 1.1.0.

@tristan957
Copy link
Contributor

@xclaesse you said you might know this issue right?

@xclaesse
Copy link
Member

The problem is on reconfigure we reload machine files and override options with what it contains. Meson should remember the source of every option (command line, machine file, env, etc) and only override if it got changed in a higher priority source. That means when reloading machine file we should override the option if the value we got was from env but not if it was from command line. That's also the reason why we don't update options when changing project(..., default_options: ...) because we don,t know if current value comes from command line or not.

This is something I got told that muon does correctly.

sfan5 added a commit to mpv-android/mpv-android that referenced this issue Aug 5, 2023
This keeps ruining my debugging sessions.
upstream report: mesonbuild/meson#11294
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants