From 1c604be4930e2a57097c67cc3974a3ccc088776d Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Sun, 30 Aug 2026 07:36:16 +0000 Subject: [PATCH 1/5] Use the default xcode version --- .github/workflows/build.yml | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 90ae3a5ec16076..e7ab3f93209784 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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 From 443f62bc05df2dff4243e8fdcce3d5a4793f2f7f Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Sun, 30 Aug 2026 08:49:37 +0000 Subject: [PATCH 2/5] Install the wasm32-unknown-emscripten Rust target in Emscripten CI --- .github/workflows/reusable-emscripten.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/reusable-emscripten.yml b/.github/workflows/reusable-emscripten.yml index c8832342d9892d..c48904848bbaab 100644 --- a/.github/workflows/reusable-emscripten.yml +++ b/.github/workflows/reusable-emscripten.yml @@ -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" From 2262ac561253cd83237f36617a97453c0e7927d8 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Sun, 30 Aug 2026 09:13:12 +0000 Subject: [PATCH 3/5] what if? --- Modules/cpython-sys/build.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/Modules/cpython-sys/build.rs b/Modules/cpython-sys/build.rs index a4e92b9ea90d1d..62b4cab3053741 100644 --- a/Modules/cpython-sys/build.rs +++ b/Modules/cpython-sys/build.rs @@ -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}"); } @@ -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; + } + } + // 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//toolchains/llvm/prebuilt//bin/-clang From 56587b3d6296ee94200f727c04f3dbd5788d99f5 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Sun, 30 Aug 2026 09:42:54 +0000 Subject: [PATCH 4/5] it seems that rust 1.95's prebuilt std for wasm32-unknown-emscripten is compiled with -fwasm-exceptions --- configure | 1 + configure.ac | 1 + 2 files changed, 2 insertions(+) diff --git a/configure b/configure index 9ebeb0ca5ed46c..7b5f7bd98caaeb 100755 --- a/configure +++ b/configure @@ -9815,6 +9815,7 @@ fi as_fn_append LINKFORSHARED " -sALLOW_MEMORY_GROWTH -sINITIAL_MEMORY=20971520" as_fn_append LDFLAGS_NODIST " -sWASM_BIGINT" + as_fn_append LDFLAGS_NODIST " -fwasm-exceptions" as_fn_append LINKFORSHARED " -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js" as_fn_append LINKFORSHARED " -sEXPORTED_RUNTIME_METHODS=FS,callMain,ENV,HEAPU32,TTY,ERRNO_CODES" diff --git a/configure.ac b/configure.ac index 2f3c7641afe735..7fde993529f831 100644 --- a/configure.ac +++ b/configure.ac @@ -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"]) dnl Include file system support AS_VAR_APPEND([LINKFORSHARED], [" -sFORCE_FILESYSTEM -lidbfs.js -lnodefs.js -lproxyfs.js -lworkerfs.js"]) From 25d7cf1b36286e27560665206f18c4797a943ab1 Mon Sep 17 00:00:00 2001 From: Kirill Podoprigora Date: Tue, 1 Sep 2026 19:19:03 +0000 Subject: [PATCH 5/5] Simplification --- Modules/cpython-sys/build.rs | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/Modules/cpython-sys/build.rs b/Modules/cpython-sys/build.rs index 62b4cab3053741..a0898972ec9954 100644 --- a/Modules/cpython-sys/build.rs +++ b/Modules/cpython-sys/build.rs @@ -228,25 +228,16 @@ 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()) { + if !have_sysroot + && cargo_target.contains("emscripten") + && let Ok(emsdk) = env::var("EMSDK") + { + let sysroot = PathBuf::from(&emsdk) + .join("upstream") + .join("emscripten") + .join("cache") + .join("sysroot"); + if sysroot.is_dir() { builder = builder.clang_arg(format!("--sysroot={}", sysroot.display())); have_sysroot = true; }