Skip to content

getValue(0, "i64") returns a number even when building with WASM_BIGINT #16272

@merceyz

Description

@merceyz

When building with -s WASM_BIGINT the return value of getValue(0, "i64") is a number instead of a bigint.

Running the following Node.js script on the output of the provided build command shows that the return value isn't a bigint

const assert = require("assert");
const createModule = require("./build");

createModule().then((mod) => {
	const value = mod.getValue(0, "i64");
	assert.strictEqual(typeof value, "bigint");
});

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.3 (c06156773675b2cb437e41459c12d44bd9a8f235)
clang version 14.0.0 (https://github.com/llvm/llvm-project d8f929a567083a6b90264193f1e4476f6b77c5fe)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin

Full link command and output with -v appended:

$ touch test.c && docker run --rm -it -v "$(pwd):/src" emscripten/emsdk:3.1.3 emcc \
  -o ./build.js \
  -s WASM=1 \
  -s EXPORTED_RUNTIME_METHODS='["getValue"]' \
  -s ENVIRONMENT=node \
  -s MODULARIZE=1 \
  -s WASM_BIGINT \
  -s EXPORT_NAME="createModule" \
  -v \
  ./test.c

 "/emsdk/upstream/bin/clang" -target wasm32-unknown-emscripten -DEMSCRIPTEN -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -D__EMSCRIPTEN_major__=3 -D__EMSCRIPTEN_minor__=1 -D__EMSCRIPTEN_tiny__=3 -D_LIBCPP_ABI_VERSION=2 -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -v ./test.c -c -o /tmp/emscripten_temp_6k7fv05_/test_0.o
clang version 14.0.0 (https://github.com/llvm/llvm-project d8f929a567083a6b90264193f1e4476f6b77c5fe)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /emsdk/upstream/bin
 (in-process)
 "/emsdk/upstream/bin/clang-14" -cc1 -triple wasm32-unknown-emscripten -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -v -fcoverage-compilation-dir=/src -resource-dir /emsdk/upstream/lib/clang/14.0.0 -D EMSCRIPTEN -D __EMSCRIPTEN_major__=3 -D __EMSCRIPTEN_minor__=1 -D __EMSCRIPTEN_tiny__=3 -D _LIBCPP_ABI_VERSION=2 -isysroot /emsdk/upstream/emscripten/cache/sysroot -internal-isystem /emsdk/upstream/lib/clang/14.0.0/include -internal-isystem /emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten -internal-isystem /emsdk/upstream/emscripten/cache/sysroot/include -Werror=implicit-function-declaration -fdebug-compilation-dir=/src -ferror-limit 19 -fvisibility default -fgnuc-version=4.2.1 -fignore-exceptions -fcolor-diagnostics -iwithsysroot/include/SDL -iwithsysroot/include/compat -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -o /tmp/emscripten_temp_6k7fv05_/test_0.o -x c ./test.c
clang -cc1 version 14.0.0 based upon LLVM 14.0.0git default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/emsdk/upstream/emscripten/cache/sysroot/include/wasm32-emscripten"
#include "..." search starts here:
#include <...> search starts here:
 /emsdk/upstream/emscripten/cache/sysroot/include/SDL
 /emsdk/upstream/emscripten/cache/sysroot/include/compat
 /emsdk/upstream/lib/clang/14.0.0/include
 /emsdk/upstream/emscripten/cache/sysroot/include
End of search list.
 "/emsdk/upstream/bin/wasm-ld" -o ./build.wasm /tmp/emscripten_temp_6k7fv05_/test_0.o -L/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten -lGL -lal -lhtml5 -lstubs-debug -lnoexit -lc-debug -ldlmalloc -lcompiler_rt -lc++-noexcept -lc++abi-noexcept -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --import-undefined --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__stdio_exit --export=emscripten_stack_get_end --export=emscripten_stack_get_free --export=emscripten_stack_init --export=stackSave --export=stackRestore --export=stackAlloc --export=__wasm_call_ctors --export=__errno_location --export-table -z stack-size=5242880 --initial-memory=16777216 --no-entry --max-memory=16777216 --global-base=1024       
 "/emsdk/upstream/bin/wasm-emscripten-finalize" --minimize-wasm-changes --bigint --no-dyncalls --no-legalize-javascript-ffi ./build.wasm --detect-features
 "/emsdk/node/14.18.2_64bit/bin/node" /emsdk/upstream/emscripten/src/compiler.js /tmp/tmpu4c2dzy1.json
 "/emsdk/upstream/bin/llvm-objcopy" ./build.wasm ./build.wasm --remove-section=.debug* --remove-section=producers

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions