Let add_compiler_options and process_compiler_options handle subprojects,
and also run it for the main project to ensure that pending_options are
properly processed.
This exposes a bug because "comp" could have been None, so fix that.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This makes "meson setup --reconfigure" behave quite literally the same as
"meson configure" + "meson setup"; except that saving coredata and
cmdline file is delayed until the setup succeeds.
Fixes: #14575
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
For compatibility with Autotools, CFLAGS is added to the linker command
line if the compiler acts as a linker driver. However, this behavior
was lost in commit d37d649b0 ("Make all Meson level options overridable
per subproject.", 2025-02-13).
The issue is that (for example) c_link_args is stored in env.options, and
from that point on it is treated as a machine-file option. This includes
not being able to override it in compilers.get_global_options:
- initialize_from_top_level_project_call places it in pending_options
- add_lang_args passes the right value to add_compiler_option
- add_compiler_option calls add_system_option_internal
- add_system_option_internal fishes the value out of pending_options
and ignores what get_global_options provided.
Instead, store the putative values of the compiler options coming from
the environment in a separate dictionary, that is only accessed by
get_global_options. This way it never appears in pending_options, and
also there is no internal *_env_args variable anymore.
Fixes: #14533
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Make space for moving the larger comment about *_env_args, which will be before
the for loop once *_env_args is removed.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
On Windows, os.execv spawn the process in background and returns 0.
Therefore, it prevents devenv to return proper exit code from the
called process. (see https://github.com/python/cpython/issues/63323
for reference.)
The solution is to call subprocess.run instead, on Windows, at the
price of keeping the meson python process alive while the devenv
subprocess runs.
"rustdoc --test" relies on running host binaries, and has no way of wrapping
them with Meson's exe_wrapper. Just skip the doctests in that case.
Fixes: #14583
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Fixes a regression introduced in commit d37d649b08 "Make all Meson level
options overridable per subproject." This change results in every file
printing the warning "cl : Command line warning D9002 : ignoring unknown
option '/std:vc++14'"
Now that "get_option_..." is called before overwriting the option (instead
of after), we have to operate on compiler options, not meson options.
There is no such compiler option as /std:vc++14 (the meson option vc++xx is
split into /std:c++xx for the C++ standard version, and a separate flag
that enables Microsoft extensions). Remove the mapping from c++14 to
vc++14.
This is already done for bz2 and lzma, but even gzip is not always available
in a minimal Python installation. For example, this happens when building
Python from source without having zlib available.
Replace optlist2optdict with a convertor. However, while default_options
should use OptionKeys like it did before the option refactoring,
override_options keeps using strings.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
A convertor will *accept* something that is definitely a TYPE_var; but the
output can be any Python object that the evaluation function desires.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Allow OptionStringLikeDict to use non-string data types, and use it
as much as possible instead of string-valued dictionaries.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Make the validators accept any object since that is where the type
checking is done. The same is true for listify_array_value, which
also performs type checking.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Since opt.deprecated is a dictionary with string keys, the lookup must use
str() around the user-provided value; with some care because booleans
will be the meson-ic 'true' and 'false' instead of Python's 'True' and
'False'.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Apply the default_library=... default after the default options have been
converted to a dictionary, to avoid having to deal with all the possible types
of the default_options keyword argument.
Fixes: #14532
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Always use a dictionary (even though later OptionStore will convert it back to list
for hackish historical reasons) to make it easy to apply overrides. Long term
we probably want OptionStore to not know about T.List[str] at all, anyway.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Something like
subproject('sub', default_options: ['sub2:from_subp=true'])
will cause an assertion failure due to "key.subproject is None"
obviously being false. Just support this, since it's easy to do so.
By default we point to the start of the most recent token we parsed.
This is used when erroring out on parser issues, to print the line that
caused the error, with a pointer to where we were when we got the error.
In this particular case, the pointer pointed to the start of the last
token we successfully parsed (col), but was not updated if we hit a
token we didn't understand at all. Instead use a pointer to the
unrecognized token itself.
Fixes: https://github.com/mesonbuild/meson/issues/14415
See the way that it is created:
dir_node = assign(dir_var, function(include_directories, tgt.includes))
sys_node = assign(sys_var, function(include_directories, tgt.sys_includes, {is_system: True}))
inc_node = assign(inc_var, array([id_node(dir_var), id_node(sys_var)]))
Due to incorrect documentation, commit 1f4bb3737 ("modules/cmake: Make fully type
safe", 2025-04-02) added an incorrect assertion. Fix both.
Fixes: #14530
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
libc++ deprecated _LIBCPP_ENABLE_ASSERTIONS from version 18.
However, the libc++ shipped with Apple Clang backported that
deprecation in version 17 already,
which is the version which Apple currently ships for macOS.
This PR changes the _LIBCPP_ENABLE_ASSERTIONS deprecation check
to use version ">=17" on Apple Clang.
Which command line options are valid is not entirely known until the backend
option is processed. Split the validation to a separate function so that it
can be done later, and while at it mention all unknown options instead of
just the first.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Avoid reinventing the wheel and instead use a single helper, taking care
of logging and cross compilation.
Fixes: #14373
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>