Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 0 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,6 @@ jobs:
with:
toolchain: 1.95.0
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
# https://github.com/actions/runner-images/issues/12541 and
# https://github.com/actions/runner-images/issues/12751.
- name: Select Xcode version
run: |
sudo xcode-select --switch /Applications/Xcode_16.4.app

- name: Build and test
run: python3 Platforms/Apple ci iOS --fast-ci

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/reusable-emscripten.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ jobs:
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.x'
- uses: dtolnay/rust-toolchain@f133eefe930d61f0d9371efd474daf0125ed3dd1 # 1.95.0
with:
toolchain: 1.95.0
targets: wasm32-unknown-emscripten
- name: "Runner image version"
run: echo "IMAGE_OS_VERSION=${ImageOS}-${ImageVersion}" >> "$GITHUB_ENV"
- name: "Install Emscripten"
Expand Down
25 changes: 25 additions & 0 deletions Modules/cpython-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ fn emit_rerun_instructions(builddir: Option<&str>) {
"PY_CFLAGS",
"TARGET",
"WASI_SDK_PATH",
"EMSDK",
] {
println!("cargo:rerun-if-env-changed={var}");
}
Expand Down Expand Up @@ -227,6 +228,30 @@ fn generate_c_api_bindings(
}
}

if !have_sysroot && cargo_target.contains("emscripten") {
let mut candidates = Vec::new();
if let Ok(emsdk) = env::var("EMSDK") {
candidates.push(
PathBuf::from(&emsdk)
.join("upstream")
.join("emscripten")
.join("cache")
.join("sysroot"),
);
}
if let Ok(cc) = env::var("PY_CC")
&& let Some(parts) = shlex::split(&cc)
&& let Some(binary) = parts.first()
&& let Some(bin_dir) = Path::new(binary).parent()
{
candidates.push(bin_dir.join("cache").join("sysroot"));
}
if let Some(sysroot) = candidates.into_iter().find(|p| p.is_dir()) {
builder = builder.clang_arg(format!("--sysroot={}", sysroot.display()));
have_sysroot = true;
}
}

Comment on lines +231 to +254

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This points bidgen at emsdk's sysroot, same as WASI/Android blocks above.

@hoodmane hoodmane Aug 31, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It might be simpler to assume that $EMSDK/upstream/emscripten/cache/sysroot points to a valid sysroot and skip the second step.

// Android NDK: ANDROID_HOME is set by the CI/user environment, and
// Android/android-env.sh sets CC to the NDK clang binary at:
// $ANDROID_HOME/ndk/<ver>/toolchains/llvm/prebuilt/<host>/bin/<triple>-clang
Expand Down
1 change: 1 addition & 0 deletions configure

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

1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2410,6 +2410,7 @@ AS_CASE([$ac_sys_system],

dnl map int64_t and uint64_t to JS bigint
AS_VAR_APPEND([LDFLAGS_NODIST], [" -sWASM_BIGINT"])
AS_VAR_APPEND([LDFLAGS_NODIST], [" -fwasm-exceptions"])

@Eclips4 Eclips4 Aug 30, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Rust ships a prebuilt std for wasm32-unknown-emscripten, and it's compiled with -fwasm-exceptions.
So I suppose we have no choice here

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Let me ping @hoodmane. Hood, for context this PR is adding emscripten support to our Rust fork. Do you think adding wasm-exceptions would be an issue for users of CPython on Emscripten?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah, Pyodide uses it and it works well, panic and catch_unwind both work as expected. I don't think there is anything to worry about.


dnl Include file system support
AS_VAR_APPEND([LINKFORSHARED], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"])
Expand Down
Loading