Hi,
I am trying to build swi-prolog from swipl repo for wasm32 but I am getting this error:
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
I am using ubuntu 22.04 and emcc 3.1.69.
Any help would be appreciated.
Hi,
I am trying to build swi-prolog from swipl repo for wasm32 but I am getting this error:
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
I am using ubuntu 22.04 and emcc 3.1.69.
Any help would be appreciated.
Just upgraded emcc to 3.1.69 and rebuild. Works fine. That is, using the current development git and the following to configure:
WASM_HOME=$HOME/wasm
source $WASM_HOME/emsdk/emsdk_env.sh
TOOLCHAIN=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake
[ -f $TOOLCHAIN ] || echo "Could not find emscripten toolchain"
LDFLAGS="-s STACK_SIZE=1048576" \
cmake -DCMAKE_TOOLCHAIN_FILE=$TOOLCHAIN \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_FIND_ROOT_PATH=$HOME/wasm \
-DUSE_GMP=OFF \
-DINSTALL_DOCUMENTATION=OFF \
-G Ninja .. $@
In $HOME/wasm
are the builds of the dependencies (zlib is needed, pcre2 is there as well, but this is not required for building).
hi Jan,
Thank you for your quick reply.
I tested build using your configuration and got the same result.
Then I have tested with npm-swipl-wasm and it builds OK on my machine. Based on the Dockerfile I have made a build script to replicate build steps from the command line. Well, result is exactly the same as before when building either swipl-devel of swipl see below. Now I am at loss because docker build is also based on ubuntu 22.04.
Here is a log from build
[189/600] Building C object src/CMakeFiles/swiplobjs.dir/pl-rsort.c.o
/prolog/build-wasm/swipl-devel/src/pl-rsort.c:110:31: warning: incompatible pointer types passing 'struct sort_r_data *' to parameter of type 'int (*)(const void *, const void *, void *)' [-Wincompatible-pointer-types]
110 | qsort_r(base, nel, width, &tmp, &sort_r_arg_swap);
| ^~~~
/home/pawel/sda4/home/pawel/src/Emscripten/emsdk/upstream/emscripten/cache/sysroot/include/stdlib.h:151:45: note: passing argument to parameter here
151 | void qsort_r (void *, size_t, size_t, int (*)(const void *, const void *, void *), void *);
| ^
1 warning generated.
[571/600] Linking C executable src/swipl.js
FAILED: src/swipl.js
: && /home/pawel/sda4/home/pawel/src/Emscripten/emsdk/upstream/emscripten/emcc -O3 -DNDEBUG -s NODERAWFS=1 -s EXIT_RUNTIME=1 -s WASM_BIGINT=1 -s ALLOW_MEMORY_GROWTH=1 -s STACK_SIZE=1048576 -s STACK_OVERFLOW_CHECK=1 src/CMakeFiles/swipl.dir/pl-main.c.o -o src/swipl.js src/libswipl.a -lm -lrt packages/clib/memfile.a packages/clib/files.a packages/clib/uri.a packages/clib/readutil.a packages/clib/prolog_stream.a packages/clib/md54pl.a packages/clib/crypt.a packages/clib/hashstream.a packages/clib/sha4pl.a packages/http/json.a packages/http/http_stream.a packages/semweb/turtle.a packages/semweb/ntriples.a packages/pcre/pcre4pl.a /prolog/build-wasm/wasm/lib/libpcre2-8.a packages/sgml/sgml2pl.a packages/nlp/double_metaphone.a packages/nlp/porter_stem.a packages/nlp/isub.a packages/nlp/snowball.a packages/nlp/libstemmer_c/liblibstemmer.a packages/zlib/zlib4pl.a /prolog/build-wasm/wasm/lib/libz.a && :
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
wasm-ld: error: src/libswipl.a(pl-alloc.c.o): undefined symbol: PL_dlsym
I have no clue. Possibly something is wrong with your emsdk installation, possibly something in the environment that breaks the cmake configuration, … Hard to say.
Thank you!