A build project prefix ("build.") was introduced in 499f73da1 to separate build
files from host and build targets when cross compiling subprojects.
Additional work was done in 83fba12da. However, this prefix was missing from
some places:
- for generated files, with or without `build_subdir`: those files were
generated at the same place for both host and build targets.
- for include dirs: was erroring if it was only available in the build
tree.
- for subdirs
- for generated ast
Additionally, extra_build_dirs were double-prefixed.
Clang records the modification time of every header that goes into a
precompiled header. When a header gets a new modification time but
keeps its content, for example after switching branches back and
forth, the rebuilt PCH differs and ccache misses for every object file
that uses it.
Pass -Xclang -fno-pch-timestamp when creating the PCH if a compiler
cache is in use, as the ccache manual recommends.
Fixes#14662
project(), and add_languages() with no "native" keyword argument, were
looking for a host compiler even in build-machine subprojects.
Every caller other than `add_languages(native: bool)` was passing a
raw MachineChoice, so add the mapping in Interpreter.add_languages
and remove it from func_add_languages().
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
When scanning for the dependencies of a resource file, which is only
needed with glib older than 2.51.1, the first --sourcedir is documented
as "Current build dir" but is actually relative to the source directory,
which is the working directory of the command.
Search the build directory of the current meson.build and of each
user-specified directory before the corresponding source directory, as
the comment intended.
The helper uses a single --subdir to locate the documentation in both
the source tree and the build tree. In a subproject built for the build
machine the build directory has a different prefix than the source
directory, so the helper wrote into and installed from the wrong place.
Pass the directory in the build tree separately as --build-subdir and use
it for the output and for the install source, while --subdir remains the
source directory.
Cython can be used with more than one Python installation, and the
sanity check cannot know which one a project will use. A failure to
build the transpiled source against the default Python therefore does
not mean that the project will fail.
Split out the compiler invocation part of Compiler.sanity_check, so
that the Cython compiler can print a warning in that case and proceed
nevertheless. Failures to transpile, however, remain an error.
Fixes: #15740
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Ensure that any changes to clang or errors in meson's rspfile implementation
are caught, since this has just happened for GCC 16.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Combine three arguments in one, while also fixing two bugs. First,
on Windows g-ir-scanner and glib-mkenums broke for any path that had
backslashes but not spaces, because they produced a MSVC-format rsp file.
Most of the time shlex.split() would cope with it, but the Windows
quote_arg leaves arguments without spaces unquoted and shlex.split()
would treat those backslashes as escapes.
Second, the NASM format can now stop quoting arguments, which was incorrect
because nasm expects one-line-per-argument response files with unquoted
arguments.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
g-ir-scanner and glib-mkenums read the response file and split it with
shlex.split(), even on Windows hosts. However, Meson is currently
preparing MSVC-format response files on Windows hosts.
In preparation for fixing that, change CustomTarget's rspable field to
contain the actual response file syntax that the tool accepts.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Remove duplication of the choice of quoting function for MSVC/TASKING
on one side, and GCC on the other.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Move functions to handle RSP files out of linkers/base.py and ninjabackend.py,
so that backends.py can use them when it writes response files for custom
targets.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
When nasm is used as the link_language, the NinjaRule.write() and
NinjaBuildElement.write() methods quote respectively the rspfile_content
and the variables with gcc_rsp_quote, because NASM is neither MSVC nor
TASKING. However, if this is used with an MSVC toolchain, link.exe then
gets GCC-style quoting.
Teach Compiler to expose different RSP file syntaxes when used for
compilation vs. linking, and use the latter when writing the ninja rule
for linking.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
They were accidentally committed in 67d7ddb36
Then deleted in 45bfeba38
And were accidentally committed again in e6c4e8d04
So let's not just delete them, let's add a gitignore so they don't
get re-added
override_find_program collapses `native: true` to `native: false` when
not cross compiling. When wishing to add an override for both machines,
for example because a program has machine-independent output, this
causes the same (name, machine) pair to be overridden twice. As a
special exception allow repeated override_find_program when the
executable is the same.
Add documentation about how to call override_find_program properly
for such a program.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
BuildTarget.__init__ assigned self.extra_files after add_deps().
The assignment discarded files that add_deps() had appended from
declare_dependency(extra_files: ...); prior to commit 97a1c567c,
files from the interpreter were added with self.extra_files.append,
instead now it has to be assigned before add_deps().
Fixes: 97a1c567c ("interpreter: Move validation of BuildTarget(extra_files) to Interpreter", 2025-11-05)
Fixes: #15863
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
The list can be reused in the next call to add_languages:
success = len(langs) == len(args[0])
success &= self.add_languages(langs, required, MachineChoice.HOST)
success &= self.add_languages(langs, False, MachineChoice.BUILD)
Fixes: 17eb224aa
Fixes: aee7f375b
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
When a subproject failed, sub-subprojects were left in self.subprojects
but rolled back from the Build object. This caused different issues
in previous versions of Meson.
Until 1.10, and specifically until commit 1eac5a5, the rollback was partly
ineffective because Build instances shared the content of PerMachine fields
(e.g. dependency_overrides) by reference. Thus, the content of the
fields propagated to the superproject even without a merge()!
Subprojects-of-failed-subprojects were still included in the build,
because process_target_dependencies() saved the day while still leaving
behind tests, installed files and targets other than used libraries.
Since 1eac5a5 (and 1.11) the sharing bug was fixed, but on the other hand
the overrides were lost, causing warnings such as:
glib| WARNING: Subproject 'pcre2' did not override 'libpcre2-8' dependency and no variable name specified
Rolling back sub-subprojects ensures that Meson tries them again and
that their expceted overrides are recorded in Build.
The attached test covers both failure modes.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This has two effects. First, it makes it possible to track summaries
separately for host- and build-machine subprojects, which was a bug
in the 1.12 implementation of build-machine subprojects.
Second, it rolls back summaries on failed subprojects, instead of having
to skip them at the end of the run.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
In preparation for storing the summaries in Build itself, which
allows them to be rolled back for failing subprojects, make
Summary only store values that were already formatted and move
it to the build module.
The formatting and the validation of the values stay in
Interpreter.summary_impl.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
In order to check for recursive inclusion, do_subproject() looks up the
subproject using `self.build.machine_map[kwargs['for_machine']]`.
However, _do_subproject_meson() registered the holder and
pushed the subproject stack using just `kwargs['for_machine']`.
The two differ when build-machine subprojects request a subproject
with `native: false`, causing two bugs that are now fixed:
- first, a second request for the same sub-subproject did not find the first
one, and configured it again causing a "Second call to project()" error.
- second, the host machine was incorrectly passed to the CMakeInterpreter
for subprojects of build-machine subprojects. CMakeInterpreter
uses it directly to look up env.coredata, without going through the
machine map, so the mapping must be done in the interpreter.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
In order to correctly check for failing subprojects inclusion,
calls to self.disabled_subproject() need to use the correct
machine. Ensure this is the case by making for_machine a
non-optional parameter.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Building glib as both a build- and a host-machine subproject causes
a failure in the ninja backend due to "Multiple producers for Ninja
target 'glib@@glib20-pot'". Fix it by adding the "build." prefix to the
build-side subproject; while this does not necessarily make much sense
for the specific case of the POT update, it is the right thing to do in
general for run_target and alias_target.
The other backends do not have the same problem because they name
run targets after target.get_id().
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
A dependency may provide a program not just as a variable, but also
(if the dependency used a subproject fallback) as an override. So look
up overrides again in ModuleState.find_tool.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Python 3.10.11 was removed from the runner's tool cache. Images
20261012.333 and earlier had it; 20261022.344 has only 3.13, 3.14 and
the new 3.15.0
While meson still supports Python 3.10+, raising it to 3.13 here seems
reasonable since 3.10 will still be tested in other pipelines.
With the `cpp_importstd` option and the MSVC compiler, meson now builds the
module with the arguments of the targets that matter to the compiler when it
imports the module: the C runtime, the character set, the C++ standard, the
exception and floating point options, the macros read by the standard library,
and so on. This prevents reporting a C5050 warning, which would become an error
if using `werror`. Arguments that do not matter, such as warnings, optimization
and include directories, are ignored. A module is built for each different set
of arguments, and shared by the targets that have the same one, so the files in
the build directory are named `std.<id>.ifc`.
The module is no longer built through a compiler cache, which cannot restore it.