From ed4d51210f9d937bb7ad31a42d9ec704ad9c3476 Mon Sep 17 00:00:00 2001 From: Nadav Ivgi Date: Wed, 2 Apr 2025 12:46:15 +0300 Subject: [PATCH 1/2] wasm: Update EMCC_OPTIONS default behavior - If no EMCC_OPTIONS is specified, enable all options necessary for the NPM WASM package build by default. - If it is specified, use it as-is with no added defaults. This enables full control over the options, e.g. for esplora, which has to disable some. This also updates the gitlab CI build to use the correct EMCC_OPTIONS for the esplora build. --- .gitlab-ci.yml | 4 ++-- src/wasm_package/build.sh | 2 +- tools/build_wasm.sh | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ddee97372..19c851b16 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -139,12 +139,12 @@ build_wally_release_files: - mv release wallycore-android-jni - tar czf wally_dist/wallycore-android-jni.tar.gz --remove-files wallycore-android-jni - source /opt/emsdk/emsdk_env.sh - - EMCC_OPTIONS="-s EXPORT_ES6=1 -s MODULARIZE=1" tools/build_wasm.sh + - tools/build_wasm.sh - cp contrib/wally_js_example.html dist/wallycore.html - cd dist - tar czf ../wally_dist/wallycore-wasm.tar.gz --remove-files wallycore.html wallycore.js wallycore.wasm - cd .. - - EMCC_OPTIONS="-s MODULARIZE=1" EXPORTED_FUNCTIONS="['_malloc','_free','_wally_init','_wally_asset_value_commitment','_wally_asset_generator_from_bytes']" tools/build_wasm.sh + - EMCC_OPTIONS="-s MODULARIZE=1 -s EXPORT_NAME=InitWally" EXPORTED_FUNCTIONS="['_malloc','_free','_wally_init','_wally_asset_value_commitment','_wally_asset_generator_from_bytes']" tools/build_wasm.sh - cd dist - tar czf ../wally_dist/esplora-wasm.tar.gz --remove-files wallycore.js wallycore.wasm - cd .. diff --git a/src/wasm_package/build.sh b/src/wasm_package/build.sh index 787bf6f92..0dbe7cd7d 100755 --- a/src/wasm_package/build.sh +++ b/src/wasm_package/build.sh @@ -2,7 +2,7 @@ set -xeo pipefail # Build WASM (Note Elements is always enabled) -(cd ../.. && EMCC_OPTIONS="-s EXPORT_ES6=1 -s MODULARIZE=1" ./tools/build_wasm.sh) +(cd ../.. && ./tools/build_wasm.sh) mkdir -p libwally_wasm && cp ../../dist/wallycore.{js,wasm} libwally_wasm/ touch libwally_wasm/index # necessary for webpack to work (fixes "Can't resolve './' in 'wasm_package/libwally_wasm'") diff --git a/tools/build_wasm.sh b/tools/build_wasm.sh index 6acc72e9f..47164cd50 100755 --- a/tools/build_wasm.sh +++ b/tools/build_wasm.sh @@ -30,7 +30,7 @@ export CFLAGS="-fno-stack-protector" emconfigure ./configure --build=$HOST_OS ac_cv_c_bigendian=no --disable-swig-python --disable-swig-java $DISABLE_ELEMENTS --disable-tests --enable-export-all --enable-wasm-interface emmake make -j $num_jobs -EMCC_OPTIONS="$EMCC_OPTIONS -s EXPORT_NAME=InitWally -s WASM_BIGINT" +: ${EMCC_OPTIONS:="-s EXPORT_ES6=1 -s WASM_BIGINT"} : ${OPTIMIZATION_LEVEL:=3} : ${EXPORTED_RUNTIME_METHODS:='cwrap,ccall,getValue,UTF8ToString'} # Get the list of functions to export From f394af85081cbebea50f470373a89f77ad52cb94 Mon Sep 17 00:00:00 2001 From: Jon Griffiths Date: Wed, 26 Mar 2025 21:36:31 +1300 Subject: [PATCH 2/2] ccan: remove an impossible-to-reach abort() --- src/ccan/ccan/str/hex/hex.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/ccan/ccan/str/hex/hex.c b/src/ccan/ccan/str/hex/hex.c index 522580a6d..2b9f22b45 100644 --- a/src/ccan/ccan/str/hex/hex.c +++ b/src/ccan/ccan/str/hex/hex.c @@ -45,9 +45,7 @@ static char hexchar(unsigned int val) { if (val < 10) return '0' + val; - if (val < 16) - return 'a' + val - 10; - abort(); + return 'a' + val - 10; } bool hex_encode(const void *buf, size_t bufsize, char *dest, size_t destsize)