Skip to content

Commit 45b21a6

Browse files
committed
f check for clang wasm32 as well as rustc
1 parent 9dc582e commit 45b21a6

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

genbindings.sh

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,14 @@ else
180180
fi
181181

182182
if [ "$(rustc --print target-list | grep wasm32-wasi)" != "" ]; then
183-
cargo rustc -v --target=wasm32-wasi -- -C embed-bitcode=yes
184-
CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release --target=wasm32-wasi -- -C opt-level=s -C linker-plugin-lto -C lto
183+
# Test to see if clang supports wasm32 as a target (which is needed to build rust-secp256k1)
184+
echo "int main() {}" > genbindings_wasm_test_file.c
185+
clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c > /dev/null 2>&1 &&
186+
# And if it does, build a WASM binary without capturing errors
187+
cargo rustc -v --target=wasm32-wasi -- -C embed-bitcode=yes &&
188+
CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release --target=wasm32-wasi -- -C opt-level=s -C linker-plugin-lto -C lto ||
189+
echo "Cannot build WASM lib as clang does not seem to support the wasm32-wasi target"
190+
rm genbindings_wasm_test_file.c
185191
fi
186192

187193
# Now build with LTO on on both C++ and rust, but without cross-language LTO:

0 commit comments

Comments
 (0)