@@ -36,6 +36,8 @@ cd "$ORIG_PWD"
3636HOST_PLATFORM=" $( rustc --version --verbose | grep " host:" | awk ' { print $2 }' ) "
3737ENV_TARGET=$( echo $HOST_PLATFORM | sed ' s/-/_/g' )
3838
39+ RUSTC_MINOR_VERSION=$( rustc --version | awk ' { split($2,a,"."); print a[2] }' )
40+
3941# Set path to include our rustc wrapper as well as cbindgen
4042export LDK_RUSTC_PATH=" $( which rustc) "
4143export RUSTC=" $( pwd) /deterministic-build-wrappers/rustc"
@@ -571,17 +573,21 @@ if [ "$CLANGPP" != "" ]; then
571573 export CRATE_CC_NO_DEFAULTS=true
572574fi
573575
574- if [ " $2 " = " false" -a " $( rustc --print target-list | grep wasm32-wasi) " != " " ]; then
576+ WASM_TARGET=" wasm32-wasi"
577+ # In rust 1.84, the wasi target was renamed
578+ [ " $RUSTC_MINOR_VERSION " -ge 84 ] && WASM_TARGET=" wasm32-wasip1"
579+
580+ if [ " $2 " = " false" -a " $( rustc --print target-list | grep $WASM_TARGET ) " != " " ]; then
575581 # Test to see if clang supports wasm32 as a target (which is needed to build rust-secp256k1)
576582 echo " int main() {}" > genbindings_wasm_test_file.c
577- if clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c > /dev/null 2>&1 ; then
583+ if clang -nostdlib -o /dev/null --target=$WASM_TARGET -Wl,--no-entry genbindings_wasm_test_file.c > /dev/null 2>&1 ; then
578584 # And if it does, build a WASM binary without capturing errors
579585 export CFLAGS_wasm32_wasi=" $BASE_CFLAGS -target wasm32-wasi -O1"
580- RUSTFLAGS=" $BASE_RUSTFLAGS -C opt-level=1 --cfg=test_mod_pointers" cargo build $CARGO_BUILD_ARGS -v --target=wasm32-wasi
586+ RUSTFLAGS=" $BASE_RUSTFLAGS -C opt-level=1 --cfg=test_mod_pointers" cargo build $CARGO_BUILD_ARGS -v --target=$WASM_TARGET
581587 export CFLAGS_wasm32_wasi=" $BASE_CFLAGS -fembed-bitcode -target wasm32-wasi -Oz"
582- RUSTFLAGS=" $BASE_RUSTFLAGS -C embed-bitcode=yes -C opt-level=z -C linker-plugin-lto -C lto" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target=wasm32-wasi
588+ RUSTFLAGS=" $BASE_RUSTFLAGS -C embed-bitcode=yes -C opt-level=z -C linker-plugin-lto -C lto" CARGO_PROFILE_RELEASE_LTO=true cargo build $CARGO_BUILD_ARGS -v --release --target=$WASM_TARGET
583589 else
584- echo " Cannot build WASM lib as clang does not seem to support the wasm32-wasi target"
590+ echo " Cannot build WASM lib as clang does not seem to support the $WASM_TARGET target"
585591 fi
586592 rm genbindings_wasm_test_file.c
587593fi
@@ -621,7 +627,6 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
621627 if [ " $MACOS_SDK " != " " ]; then
622628 # At some point rustc fixed the issue which merits REALLY_PIN_CC. I'm not sure when,
623629 # however, so we just use 1.84 as the cutoff.
624- RUSTC_MINOR_VERSION=$( rustc --version | awk ' { split($2,a,"."); print a[2] }' )
625630 [ " $RUSTC_MINOR_VERSION " -lt 84 ] && REALLY_PIN_CC
626631 [ " $RUSTC_MINOR_VERSION " -lt 84 ] && OFFLINE_OPT=" --offline"
627632
0 commit comments