@@ -36,6 +36,8 @@ cd "$ORIG_PWD"
36
36
HOST_PLATFORM=" $( rustc --version --verbose | grep " host:" | awk ' { print $2 }' ) "
37
37
ENV_TARGET=$( echo $HOST_PLATFORM | sed ' s/-/_/g' )
38
38
39
+ RUSTC_MINOR_VERSION=$( rustc --version | awk ' { split($2,a,"."); print a[2] }' )
40
+
39
41
# Set path to include our rustc wrapper as well as cbindgen
40
42
export LDK_RUSTC_PATH=" $( which rustc) "
41
43
export RUSTC=" $( pwd) /deterministic-build-wrappers/rustc"
@@ -571,17 +573,21 @@ if [ "$CLANGPP" != "" ]; then
571
573
export CRATE_CC_NO_DEFAULTS=true
572
574
fi
573
575
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
575
581
# Test to see if clang supports wasm32 as a target (which is needed to build rust-secp256k1)
576
582
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
578
584
# And if it does, build a WASM binary without capturing errors
579
585
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
581
587
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
583
589
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"
585
591
fi
586
592
rm genbindings_wasm_test_file.c
587
593
fi
@@ -619,23 +625,34 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
619
625
LINK_ARG_FLAGS=" -C link-arg=-fuse-ld=$LLD "
620
626
export LDK_CLANG_PATH=$( which $CLANG )
621
627
if [ " $MACOS_SDK " != " " ]; then
622
- REALLY_PIN_CC
628
+ # At some point rustc fixed the issue which merits REALLY_PIN_CC. I'm not sure when,
629
+ # however, so we just use 1.84 as the cutoff.
630
+ [ " $RUSTC_MINOR_VERSION " -lt 84 ] && REALLY_PIN_CC
631
+ [ " $RUSTC_MINOR_VERSION " -lt 84 ] && OFFLINE_OPT=" --offline"
632
+
623
633
export CLANG=" $( pwd) /../deterministic-build-wrappers/clang-lto-link-osx"
624
634
for ARG in $CFLAGS_aarch64_apple_darwin ; do
625
635
MANUAL_LINK_CFLAGS=" $MANUAL_LINK_CFLAGS -C link-arg=$ARG "
626
636
done
637
+ # rustc appears to always look for rust-objcopy, though this may be fixed by
638
+ # https://github.com/rust-lang/rust/pull/134240 in rust 1.85.
639
+ if [ " $RUSTC_MINOR_VERSION " = 84 ]; then
640
+ mkdir -p objcopy-bin
641
+ ln -s ` which llvm-objcopy` objcopy-bin/rust-objcopy
642
+ PATH=" $PATH :$( pwd) /objcopy-bin"
643
+ fi
627
644
# While there's no reason LTO should fail here (and it didn't use to), it now fails with errors like
628
645
# ld64.lld: error: undefined symbol: core::fmt::Formatter::debug_lower_hex::hf8e8a79f43d62b68
629
646
export CFLAGS_aarch64_apple_darwin=" $CFLAGS_aarch64_apple_darwin -O3 -fPIC -fembed-bitcode"
630
- RUSTC_BOOTSTRAP=1 RUSTFLAGS=" $BASE_RUSTFLAGS -C target-cpu=apple-a14 -C embed-bitcode=yes -C linker-plugin-lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14" cargo build $CARGO_BUILD_ARGS --offline -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort
647
+ RUSTC_BOOTSTRAP=1 RUSTFLAGS=" $BASE_RUSTFLAGS -C target-cpu=apple-a14 -C embed-bitcode=yes -C linker-plugin-lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-mcpu=apple-a14" cargo build $CARGO_BUILD_ARGS $OFFLINE_OPT -v --release --target aarch64-apple-darwin -Zbuild-std=std,panic_abort
631
648
if [ " $HOST_OSX " != " true" ]; then
632
649
# If we're not on OSX but can build OSX binaries, build the x86_64 OSX release now
633
650
MANUAL_LINK_CFLAGS=" "
634
651
for ARG in $CFLAGS_x86_64_apple_darwin ; do
635
652
MANUAL_LINK_CFLAGS=" $MANUAL_LINK_CFLAGS -C link-arg=$ARG "
636
653
done
637
654
export CFLAGS_x86_64_apple_darwin=" $CFLAGS_x86_64_apple_darwin -O3 -fPIC -fembed-bitcode"
638
- RUSTC_BOOTSTRAP=1 RUSTFLAGS=" $BASE_RUSTFLAGS -C target-cpu=sandybridge -C embed-bitcode=yes -C linker-plugin-lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mtune=sandybridge" cargo build $CARGO_BUILD_ARGS --offline -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort
655
+ RUSTC_BOOTSTRAP=1 RUSTFLAGS=" $BASE_RUSTFLAGS -C target-cpu=sandybridge -C embed-bitcode=yes -C linker-plugin-lto -C linker=$CLANG $MANUAL_LINK_CFLAGS $LINK_ARG_FLAGS -C link-arg=-march=sandybridge -C link-arg=-mtune=sandybridge" cargo build $CARGO_BUILD_ARGS $OFFLINE_OPT -v --release --target x86_64-apple-darwin -Zbuild-std=std,panic_abort
639
656
fi
640
657
fi
641
658
# If we're on an M1 don't bother building X86 binaries
0 commit comments