Open
Description
Emscripten build of a C library (liquid-dsp) mysteriously fails when the parent directory has package.json
containing {"type":"module"}
.
There is a similar bug #13551, from February 2021, with different library and different symptoms. But with exactly the same core reason of {"type":"module"}
changing Emscripten behaviour in a subdirectory.
I spent two hours debugging this problem. It breaks the fundamental assumption that nothing outside of the project directory should matter during the build.
Any ideas about why it could be happening? I would love to help fix it in Emscripten.
Failing command line in full:
mkdir emscripten-bug
cd emscripten-bug/
# removing this line fixes the build 🤯
echo '{"type":"module"}' > package.json
git clone https://github.com/jgaeddert/liquid-dsp
cd liquid-dsp
emmake make clean # if repeating this process
./bootstrap.sh
emconfigure ./configure --host=wasm32
emmake make VERBOSE=1
Build mysteriously fails with:
/Users/shamrin/src/emsdk/upstream/emscripten/emcc -g -O2 -Wall -fPIC -Wno-deprecated -Wno-deprecated-declarations -I. -Iinclude -c -o src/audio/src/cvsd.o src/audio/src/cvsd.c
src/audio/src/cvsd.c:70:21: error: call to undeclared function 'rpl_malloc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
cvsd q = (cvsd) malloc(sizeof(struct cvsd_s));
^
./config.h:217:16: note: expanded from macro 'malloc'
#define malloc rpl_malloc
^
1 error generated.
emcc: error: '/Users/shamrin/src/emsdk/upstream/bin/clang -target wasm32-unknown-emscripten -DEMSCRIPTEN -D__EMSCRIPTEN_major__=3 -D__EMSCRIPTEN_minor__=1 -D__EMSCRIPTEN_tiny__=15 -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/SDL --sysroot=/Users/shamrin/src/emsdk/upstream/emscripten/cache/sysroot -Xclang -iwithsysroot/include/compat -g3 -O2 -Wall -fPIC -Wno-deprecated -Wno-deprecated-declarations -I. -Iinclude -c src/audio/src/cvsd.c -o src/audio/src/cvsd.o' failed (returned 1)
make: *** [src/audio/src/cvsd.o] Error 1
emmake: error: 'make VERBOSE=1' failed (returned 2)
Version of emscripten/emsdk:
$ emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.15 (8b4443a87f5eab5dbb9adb690f9ebed0a9da4bd9)
clang version 15.0.0 (https://github.com/llvm/llvm-project 27abff670bc7ad9702c4f9fc8b82aae6b530bf0f)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /Users/shamrin/src/emsdk/upstream/bin