]> git.bitcoin.ninja Git - ldk-c-bindings/commitdiff
Fix no-std+WASM builds by not mixing -flto and -fembed-bitcode
authorMatt Corallo <git@bluematt.me>
Sat, 1 May 2021 04:10:24 +0000 (04:10 +0000)
committerMatt Corallo <git@bluematt.me>
Sat, 1 May 2021 04:12:47 +0000 (04:12 +0000)
.github/workflows/build.yml
genbindings.sh

index 2db5936984a1cbf9c77170372b6be8d9ab5cdcb6..b68feb7b96c1b05af6e74567d00d6e1574ad7067 100644 (file)
@@ -15,7 +15,7 @@ jobs:
         run: |
           apt-get update
           apt-get -y dist-upgrade
-          apt-get -y install cargo valgrind lld git g++ clang
+          apt-get -y install cargo libstd-rust-dev-wasm32 valgrind lld git g++ clang
       - name: Checkout source code
         uses: actions/checkout@v2
       - name: Sanity test bindings against Cargo.toml RL
index e0ff6b3f060af4259a92c2545f6ced32d1a6b4d9..ea725bd5d1f96e1666baa958c7b01ced987b96e5 100755 (executable)
@@ -251,7 +251,7 @@ clang++ $LOCAL_CFLAGS -std=c++11 -flto -O2 demo.cpp target/release/libldk.a -ldl
 if [ "$HOST_PLATFORM" != "host: x86_64-apple-darwin" -a "$CLANGPP" != "" ]; then
        # If we can use cross-language LTO, use it for building C dependencies (i.e. libsecp256k1) as well
        export CC="$CLANG"
-       export CFLAGS_wasm32_wasi="-target wasm32"
+       export CFLAGS_wasm32_wasi="-target wasm32 -flto"
 fi
 
 if [ "$2" = "false" -a "$(rustc --print target-list | grep wasm32-wasi)" != "" ]; then
@@ -260,8 +260,6 @@ if [ "$2" = "false" -a "$(rustc --print target-list | grep wasm32-wasi)" != "" ]
        clang -nostdlib -o /dev/null --target=wasm32-wasi -Wl,--no-entry genbindings_wasm_test_file.c > /dev/null 2>&1 &&
        # And if it does, build a WASM binary without capturing errors
        cargo rustc -v --target=wasm32-wasi -- -C embed-bitcode=yes &&
-       # Now that we've done our last non-LTO build, turn on LTO in CFLAGS as well
-       export CFLAGS="$CFLAGS -flto" &&
        CARGO_PROFILE_RELEASE_LTO=true cargo rustc -v --release --target=wasm32-wasi -- -C opt-level=s -C linker-plugin-lto -C lto ||
        echo "Cannot build WASM lib as clang does not seem to support the wasm32-wasi target"
        rm genbindings_wasm_test_file.c