Skip to content

Implement the Unix build system refactor#24

Merged
emmatyping merged 21 commits into
3.15-rust-in-cpythonfrom
3.15-new-buildsystem
Mar 8, 2026
Merged

Implement the Unix build system refactor#24
emmatyping merged 21 commits into
3.15-rust-in-cpythonfrom
3.15-new-buildsystem

Conversation

@emmatyping

@emmatyping emmatyping commented Feb 4, 2026

Copy link
Copy Markdown

This PR refactors the build system as described in #23.

Platforms working:

  • Linux
  • Linux cross-build
  • macOS
  • iOS
  • Android
  • WASI

iOS seems to have some weirdness going on with finding the right sysroot I think, but I don't have a system to test it on at the moment.

Portions of this PR were made with Claude.

@emmatyping emmatyping changed the title WIP test for new build system design Implement the build system refactor Mar 2, 2026
@emmatyping
emmatyping marked this pull request as ready for review March 2, 2026 09:30
@emmatyping
emmatyping marked this pull request as draft March 2, 2026 09:45
@emmatyping
emmatyping marked this pull request as ready for review March 3, 2026 02:22
@emmatyping

Copy link
Copy Markdown
Author

Okay this PR now fixes all CI jobs/platforms save for:

  • iOS (seems the sysroot is not set properly)
  • tsan/ubsan (seems that something to do with atomics are not set properly)

Windows build support also needs to be implemented, but that can be done in a follow up

@emmatyping emmatyping changed the title Implement the build system refactor Implement the Unix build system refactor Mar 3, 2026
@Eclips4
Eclips4 self-requested a review March 7, 2026 21:12

@Eclips4 Eclips4 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you Emma! I'll do a follow up to fix macos & iOS builds.

@emmatyping
emmatyping merged commit 95753bb into 3.15-rust-in-cpython Mar 8, 2026
79 of 89 checks passed
@emmatyping
emmatyping deleted the 3.15-new-buildsystem branch March 8, 2026 22:33
RMPR pushed a commit to RMPR/cpython that referenced this pull request Jul 7, 2026
This PR pretty much completely refactors the Rust build system. There are now two main ways Rust code is built:

- The Rust triple is deduced based on the preprocessor run on Misc/platform_triplet.c
- A cpython-build-helper crate is used to pass the proper link arguments for each configuration
- The proper Rust toolchain is downloaded for iOS/Android/WASI for CI on those platforms
- cpython-sys is updated significantly to ensure bindgen properly generates the bindings for each platform

For shared builds, we build a crate into a cdylib and pass through link arguments from the makefile/configure and the linker executable so that the final link will match what is done for C programs.

For static builds, a cpython-rust-staticlib crate is a built which depends on and re-exports the module initializers for each crate. This ensures there aren't duplicated Rust stdlib/core symbols.

Fixes Rust-for-CPython#23
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