Skip to content

Conversation

@bonzini
Copy link
Collaborator

@bonzini bonzini commented Dec 18, 2025

Building on #15395, actually add the functionality needed to build subproject for both machines. This is also propagated recursively to dependencies and subprojects of native: true subprojects.

Based on (and supersedes) #12258. Other than rebasing, the main logic changes are:

  • reimplemented copy and merge functionality: per-machine lists and dicts are copied properly while preserving v.host is v.build for bulid-machine subprojects
  • project arguments were broken and are now fixed (provided for free by the BuildProject class added by Allow subprojects to be built for both the build and host machine (1st part) #15395)
  • rewritten the handling of the subproject stack, keeping a single stack but storing (name, for_machine) tuples in it. This makes it possible to present chains of subprojects more clearly as a-0.1:b-2.0 (build):c-3.0. Note that in such a scenario c-3.0 is technically built for the host machine of b-2.0 (build) (which is the build machine of a-0.1). This is handled correctly by copy_for_build_machine() and PerMachine, but it messed up the old subproject stack handling.
  • postconf scripts are not blocked. dist and postconf scripts should receive the subproject's roots, which is a separate change. This can be handled separately after Allow subprojects to be built for both the build and host machine (1st part) #15395 is merged.

For now I've tested this on QEMU, by adding native: true to all subprojects linked to Rust procedural macro crates (such as proc_macro2, quote, syn) and removing it from the crates' static_library invocations. All crates can find their dependencies correctly and there are no warnings about cross compilation breakage, including those that are only depended upon indirectly.

It certainly can be stressed a bit more, so I'm leaving it as draft for now.

dcbaker and others added 22 commits December 18, 2025 08:50
Which maps subproject name to version
Because it can be None, it is not possible to use PerMachineDefaultable.
Which de-duplicates a lot of printing material and makes it easier to
change things.
Store it at construction time instead of extracting it from kwargs
repeatedly.

Extracted from a patch by Dylan Baker <dylan@pnwbakers.com>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Forcing the executor to the build machine doesn't actually work
correctly once we allow build subprojects, but it also uses the
wrong cmake_prefix_path.
Do not bother fully creating a new Build, since the environment will be overwritten
anyway.  Prefer setattr to __dict__ assignment.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Recursively copy the value if it is a collection; this ensures
that values are not overwritten until merge() is called.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
stdlibs is a similar kind of cache to depenency_overrides, share it
between build and host when not cross compiling.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Do not rummage into build.projects_args.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
All callers pass the subproject and machine of a target, move
that to the callee.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This makes things easier to understand, with the project_args
and project_link_args having the same structure as Build.global_args
and Build.global_link_args.

The difference is that the new member always includes an entry
for the root project, so adjust those cases that need to look at
subprojects only.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
We need this information later to build both a build and a host
subproject separately. It's a lot of boilerplate and has been split out
to try to simplify review of the difficult pieces
Currently, the assumption is that a subproject will only be built for
the host machine. Instead back the storage with PerMachine objects,
which fixes this. This goal of this patch is to extend the storage, not
enable per-machine subprojects yet.
Extracted from a patch by Dylan Baker <dylan@pnwbakers.com>
The builddir will not mirror the subdir in this case, and we need to
track that.
…ild == host config

In order to run a build machine only subproject, we create a new Build,
Environment, and CoreData object that have look like a host == build
configuration, but that are properly merged back into the originals.

[Paolo: Rewritten Build.merge]
The current situation in Meson is that subprojects are always built for
the host machine. This means that while cross compiling, a tool that
must be run on the build machine must have all of its dependencies met
by the system (pkg-config, cmake, config-tool, etc); but dependencies
for the host machine can be built. With this patch subprojects may also
be built for the build machine.

Nothing should ever be installed from a subproject for the build
machine, while cross compiling. However, we we are not cross compiling
they are installed, since Meson can't really tell the difference between
a host and build dependency.
Which is required to make test for installed files work correctly
@bonzini bonzini force-pushed the subproject-per-machine branch 2 times, most recently from 82a9dc4 to f397d2a Compare December 18, 2025 13:00
bonzini and others added 2 commits December 18, 2025 14:32
Extracted from a patch by Dylan Baker <dylan@pnwbakers.com>

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
@bonzini bonzini force-pushed the subproject-per-machine branch from f397d2a to 45d036f Compare December 18, 2025 13:32

Subprojects may now be built for the host or build machine (or both). This means
that build time dependencies can be built for the matching running the build in a
cross compile setup. When a subproject is run for the build machine it will act
Copy link
Member

Choose a reason for hiding this comment

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

Something is off in this sentence.

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

Successfully merging this pull request may close these issues.

3 participants