Skip to content

Commit

Permalink
f new rustc
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Jan 17, 2025
1 parent bcb0c50 commit e4683b2
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions genbindings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ cd "$ORIG_PWD"
HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')"
ENV_TARGET=$(echo $HOST_PLATFORM | sed 's/-/_/g')

RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')

# Set path to include our rustc wrapper as well as cbindgen
export LDK_RUSTC_PATH="$(which rustc)"
export RUSTC="$(pwd)/deterministic-build-wrappers/rustc"
Expand Down Expand Up @@ -571,17 +573,21 @@ if [ "$CLANGPP" != "" ]; then
export CRATE_CC_NO_DEFAULTS=true
fi

if [ "$2" = "false" -a "$(rustc --print target-list | grep wasm32-wasi)" != "" ]; then
WASM_TARGET="wasm32-wasi"
# In rust 1.84, the wasi target was renamed
[ "$RUSTC_MINOR_VERSION" -ge 84 ] && WASM_TARGET="wasm32-wasip1"

if [ "$2" = "false" -a "$(rustc --print target-list | grep $WASM_TARGET)" != "" ]; then
# Test to see if clang supports wasm32 as a target (which is needed to build rust-secp256k1)
echo "int main() {}" > genbindings_wasm_test_file.c
if clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c > /dev/null 2>&1; then
if clang -nostdlib -o /dev/null --target=$WASM_TARGET -Wl,--no-entry genbindings_wasm_test_file.c > /dev/null 2>&1; then
# And if it does, build a WASM binary without capturing errors
export CFLAGS_wasm32_wasi="$BASE_CFLAGS -target wasm32-wasi -O1"
RUSTFLAGS="$BASE_RUSTFLAGS -C opt-level=1 --cfg=test_mod_pointers" cargo build $CARGO_BUILD_ARGS -v --target=wasm32-wasi
RUSTFLAGS="$BASE_RUSTFLAGS -C opt-level=1 --cfg=test_mod_pointers" cargo build $CARGO_BUILD_ARGS -v --target=$WASM_TARGET
export CFLAGS_wasm32_wasi="$BASE_CFLAGS -fembed-bitcode -target wasm32-wasi -Oz"
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
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
else
echo "Cannot build WASM lib as clang does not seem to support the wasm32-wasi target"
echo "Cannot build WASM lib as clang does not seem to support the $WASM_TARGET target"
fi
rm genbindings_wasm_test_file.c
fi
Expand Down Expand Up @@ -621,7 +627,6 @@ if [ "$CLANGPP" != "" -a "$LLD" != "" ]; then
if [ "$MACOS_SDK" != "" ]; then
# At some point rustc fixed the issue which merits REALLY_PIN_CC. I'm not sure when,
# however, so we just use 1.84 as the cutoff.
RUSTC_MINOR_VERSION=$(rustc --version | awk '{ split($2,a,"."); print a[2] }')
[ "$RUSTC_MINOR_VERSION" -lt 84 ] && REALLY_PIN_CC
[ "$RUSTC_MINOR_VERSION" -lt 84 ] && OFFLINE_OPT="--offline"

Expand Down

0 comments on commit e4683b2

Please sign in to comment.