Use single multi-target compilation for universal2#571
Closed
jakelishman wants to merge 2 commits intoPyO3:mainfrom
Closed
Use single multi-target compilation for universal2#571jakelishman wants to merge 2 commits intoPyO3:mainfrom
universal2#571jakelishman wants to merge 2 commits intoPyO3:mainfrom
Conversation
As of Rust 1.61, it is possible to compile for more than one `--target` with a single compilation command. This commit refactors the build logic to avail itself of this functionality when doing the only multiple-target compilation we support, which is to make the combined `universal2` wheels for macOS. The combination of the multiple build artifacts into one universal2-compatible artifact is now done as part of the general artifact-path handling, which means we no longer have to sort out the configuration environment twice for the same system, and we no longer rely on `cargo` returning information about the built artifacts in the same order between two separate compilations. Beyond the immediate benefit of isolating the "create binary artifacts" logic into only a single place, this commit is intended to be a refactor along the path towards support for extracting non-binary artifacts that are side-effects of particular `RustExtension`'s build scripts.
This was referenced Feb 17, 2026
Author
|
I'll just close this one - it turned out to be easier to produce the superseding #572 than I expected, and the structure of them is almost identical. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As of Rust 1.61, it is possible to compile for more than one
--targetwith a single compilation command. This commit refactors the build logic to avail itself of this functionality when doing the only multiple-target compilation we support, which is to make the combineduniversal2wheels for macOS.The combination of the multiple build artifacts into one universal2-compatible artifact is now done as part of the general artifact-path handling, which means we no longer have to sort out the configuration environment twice for the same system, and we no longer rely on
cargoreturning information about the built artifacts in the same order between two separate compilations.Beyond the immediate benefit of isolating the "create binary artifacts" logic into only a single place, this commit is intended to be a refactor along the path towards support for extracting non-binary artifacts that are side-effects of particular
RustExtension's build scripts.This is a potential implementation of #563 (comment).
Warning: I don't think this should merge as-is. It breaks the ability to:
--crate-type=cdylibRustExtension.rustc_argswhen in
universal2mode. I think we could get round the--crate-typeproblem by patchingCargo.tomlinto a temporary directory, but breakingrustc_argsin the name of a refactor sounds to me to be fatal to this approach.I'm putting this up just to demonstrate the principle of what I was up to. I think I can rescue a fair amount of the refactor in this PR into something that still helps isolate the multi-target logic, but doesn't come with the caveats of doing a true multi-target build.