Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
41add82
WIP test for new build system design
emmatyping Feb 4, 2026
363f9ac
Also pass whether or not the build is shared to cpython-sys
emmatyping Feb 4, 2026
e40d3aa
Properly pass linker arguments and set up static library building
emmatyping Mar 1, 2026
e24aa53
Modify build helper to handle differences in how Python symbols are l…
emmatyping Mar 1, 2026
025f3fc
Modify cdylib suffix on macOS
emmatyping Mar 1, 2026
5ce8a5f
Calculate Rust target from Misc/platform_triplet.c
emmatyping Mar 2, 2026
cb43e5b
Pass CPPFLAGS to cpython-sys and set target
emmatyping Mar 2, 2026
8c593c8
Detect LLVM triple and handle NDK sysroot
emmatyping Mar 2, 2026
a5fb908
Add targets for WASI, Android, and iOS
emmatyping Mar 2, 2026
b170c1b
Tweak WASI and Android sysroot searching
emmatyping Mar 2, 2026
b85f67e
Pin to 1.91.1 toolchain for CI
emmatyping Mar 2, 2026
98ed047
Fix bindings for 32bit (e.g. WASI) platforms
emmatyping Mar 2, 2026
4979e92
Fix remaining BLDSHARED references
emmatyping Mar 2, 2026
5c40dc8
Add LIBPYTHON search path for Android
emmatyping Mar 2, 2026
dfb1903
Get WASI working?
emmatyping Mar 2, 2026
2c08857
Try adding a fallback mapping of Rust->LLVM triples
emmatyping Mar 2, 2026
caf1f9f
Revert "Try adding a fallback mapping of Rust->LLVM triples"
emmatyping Mar 2, 2026
e1936b8
Ignore Rust build support dirs in generate_stdlib_module_names.py
emmatyping Mar 3, 2026
a59b300
Run cargo fmt && clippy
emmatyping Mar 3, 2026
9b33848
Pass through C standard flag to libclang for sanitizers
emmatyping Mar 3, 2026
74f6e7e
Add newline to end of cpython-sys/Cargo.toml
emmatyping Mar 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ jobs:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: dtolnay/rust-toolchain@1.91.1
with:
targets: ${{ matrix.arch }}-linux-android
- name: Build and test
run: ./Android/android.py ci --fast-ci ${{ matrix.arch }}-linux-android

Expand All @@ -396,7 +399,9 @@ jobs:
- uses: actions/checkout@v4
with:
persist-credentials: false

- uses: dtolnay/rust-toolchain@1.91.1
with:
targets: aarch64-apple-ios-sim
# GitHub recommends explicitly selecting the desired Xcode version:
# https://github.com/actions/runner-images/issues/12541#issuecomment-3083850140
# This became a necessity as a result of
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/reusable-wasi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.x'
- uses: dtolnay/rust-toolchain@1.91.1
with:
targets: wasm32-wasip1
- name: "Runner image version"
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: "Configure build Python"
Expand Down
16 changes: 16 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[workspace]
resolver = "3"
members = [
"Modules/_base64",
"Modules/_base64", "Modules/cpython-build-helper", "Modules/cpython-rust-staticlib",
"Modules/cpython-sys"
]
22 changes: 16 additions & 6 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ CARGO_HOME=@CARGO_HOME@
CARGO_TARGET_DIR=@CARGO_TARGET_DIR@
CARGO_PROFILE=@CARGO_PROFILE@
CARGO_TARGET=@CARGO_TARGET@
CARGO_TARGET_LINKER_ENV=@CARGO_TARGET_LINKER_ENV@
CARGO_DYLIB_SUFFIX=@CARGO_DYLIB_SUFFIX@
LLVM_TARGET=@LLVM_TARGET@
RUST_STATICLIB_DEP=@RUST_STATICLIB_DEP@

GNULD= @GNULD@

Expand Down Expand Up @@ -178,7 +182,8 @@ CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(LDVERSION)
SHLIB_SUFFIX= @SHLIB_SUFFIX@
EXT_SUFFIX= @EXT_SUFFIX@
LDSHARED= @LDSHARED@ $(PY_LDFLAGS)
BLDSHARED= @BLDSHARED@ $(PY_CORE_LDFLAGS)
BLDSHARED_EXE= @BLDSHARED_EXE@
BLDSHARED_ARGS= @BLDSHARED_ARGS@ $(PY_CORE_LDFLAGS)
LDCXXSHARED= @LDCXXSHARED@ $(PY_LDFLAGS)
DESTSHARED= $(BINLIBDEST)/lib-dynload

Expand Down Expand Up @@ -988,7 +993,7 @@ clinic-tests: check-clean-src $(srcdir)/Lib/test/clinic.test.c
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/clinic/clinic.py -f $(srcdir)/Lib/test/clinic.test.c

# Build the interpreter
$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS)
$(BUILDPYTHON): Programs/python.o $(LINK_PYTHON_DEPS) $(RUST_STATICLIB_DEP)
$(LINKCC) $(PY_CORE_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(LINK_PYTHON_OBJS) $(LIBS) $(MODLIBS) $(SYSLIBS)

platform: $(PYTHON_FOR_BUILD_DEPS) pybuilddir.txt
Expand Down Expand Up @@ -1021,16 +1026,16 @@ $(LIBRARY): $(LIBRARY_OBJS)
libpython$(LDVERSION).so: $(LIBRARY_OBJS) $(DTRACE_OBJS)
# AIX Linker don't support "-h" option
if test "$(MACHDEP)" != "aix"; then \
$(BLDSHARED) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
$(BLDSHARED_EXE) $(BLDSHARED_ARGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
else \
$(BLDSHARED) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
$(BLDSHARED_EXE) $(BLDSHARED_ARGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM); \
fi
if test $(INSTSONAME) != $@; then \
$(LN) -f $(INSTSONAME) $@; \
fi

libpython3.so: libpython$(LDVERSION).so
$(BLDSHARED) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^
$(BLDSHARED_EXE) $(BLDSHARED_ARGS) $(NO_AS_NEEDED) -o $@ -Wl,-h$@ $^

libpython$(LDVERSION).dylib: $(LIBRARY_OBJS)
$(CC) -dynamiclib $(PY_CORE_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(LDVERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(DTRACE_OBJS) $(SHLIBS) $(LIBC) $(LIBM); \
Expand Down Expand Up @@ -3374,7 +3379,12 @@ Python/thread.o: @THREADHEADERS@ $(srcdir)/Python/condvar.h
# Module dependencies and platform-specific files

cpython-sys: Modules/cpython-sys/Cargo.toml Modules/cpython-sys/build.rs Modules/cpython-sys/wrapper.h Modules/cpython-sys/parser.h
CARGO_TARGET_DIR=$(abs_builddir)/target PYTHON_BUILD_DIR=$(abs_builddir) \$(CARGO_HOME)/bin/cargo build --lib --locked --package cpython-sys --profile $(CARGO_PROFILE) $(if $(CARGO_TARGET),--target=$(CARGO_TARGET)) --manifest-path $(srcdir)/Cargo.toml
CARGO_TARGET_DIR=$(abs_builddir)/target PYTHON_BUILD_DIR=$(abs_builddir) PY_CC="$(CC)" PY_CPPFLAGS="$(CPPFLAGS)" PY_CFLAGS="$(CFLAGS)" LLVM_TARGET="$(LLVM_TARGET)" $(CARGO_HOME)/bin/cargo build --lib --locked --package cpython-sys --profile $(CARGO_PROFILE) $(if $(CARGO_TARGET),--target=$(CARGO_TARGET)) --manifest-path $(srcdir)/Cargo.toml

RUST_STATICLIB_A= target/$(if $(CARGO_TARGET),$(CARGO_TARGET)/$(CARGO_TARGET_DIR),$(CARGO_TARGET_DIR))/libcpython_rust_staticlib.a

cpython-rust-staticlib: cpython-sys
CARGO_TARGET_DIR=$(abs_builddir)/target PYTHON_BUILD_DIR=$(abs_builddir) $(CARGO_HOME)/bin/cargo build --lib --locked --package cpython-rust-staticlib --profile $(CARGO_PROFILE) $(if $(CARGO_TARGET),--target=$(CARGO_TARGET)) --manifest-path $(srcdir)/Cargo.toml

# force rebuild when header file or module build flavor (static/shared) is changed
MODULE_DEPS_STATIC=Modules/config.c
Expand Down
Loading
Loading