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

add_languages doesn't honor default values if it's called for the first time from a reconfigure #10664

Open
dcbaker opened this issue Aug 5, 2022 · 0 comments
Assignees
Labels

Comments

@dcbaker
Copy link
Member

dcbaker commented Aug 5, 2022

Given a meson.build such as

project('foo', default_options : ['cpp_std=c++14'])
if get_option('with-cpp')
  add_languages(['cpp'])
  executable('exe', 'main.cpp')
endif

if you run meson as
meson setup builddir -Dwith-cpp=true then things work as expected and main.cpp is compiled with -std=c++14 (or equivalent)

However, if it's run as

meson setup builddir -Dwith-cpp=false`
meson configure builddir -Dwith-cpp=true`

Then meson will fail to honor the default cpp options, and will instead compile with whatever the default is (this is true of all cpp args, cpp_args, cpp_link_args, cpp_eh, etc)

This happens because the initial values are read into the transient Environment, and only copied into the presistant coredata when the compiler is initialized. We do this so that we can validate that the given compiler options are valid for the current compiler (both the argument itself, and the value of the argument), but this has the drawback that unused options do not persist.

I haven't checked, but I believe that this would be the same for values set in a machine file.

@dcbaker dcbaker added the bug label Aug 5, 2022
@dcbaker dcbaker self-assigned this Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant