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 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" 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 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"])