r-wasm / webr

The statistical language R compiled to WebAssembly via Emscripten, for use in web browsers and Node.

Home Page:https://docs.r-wasm.org/webr/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot compile vegan package for wasm

isbool opened this issue · comments

Hey, when im trying to compile the vegan package for webr we get the following log: (see also this issue here)

> build("vegan")
v Updated metadata database: 6.19 MB in 4 files.
v Updating metadata database ... done
trying URL 'https://packagemanager.posit.co/cran/latest/src/contrib/vegan_2.6-4.tar.gz'
Content type 'binary/octet-stream' length 1490861 bytes (1.4 MB)
==================================================
downloaded 1.4 MB


> Will install 1 package.
> Will download 2 packages with unknown size.
+ permute   0.9-7 [dl]

i Getting 1 pkg with unknown size
v Got permute 0.9-7 (x86_64-pc-linux-gnu-ubuntu-22.04) (219.60 kB)
v Downloaded 1 package (219.60 kB) in 2s
v Installed permute 0.9-7  (18ms)
v 7 deps: added 1, dld 1 (219.60 kB) [2.7s]
* installing *source* package 'vegan' ...
** package 'vegan' successfully unpacked and MD5 sums checked
** using non-staged installation
** libs
using C compiler: 'emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.47 (431685f05c67f0424c11473cc16798b9587bb536)'
using Fortran compiler: 'flang-new version 17.0.6 (https://github.com/r-wasm/llvm-project 49f8a443424a6111bc055f349c9bfad0aa619c22)'
emcc -DNDEBUG   -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.3.3/build/include -I/opt/webr/R/build/R-4.3.3/src/include -s USE_BZIP2=1 -s USE_ZLIB=1  -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -std=gnu11 -c data2hill.c -o data2hill.o
/opt/flang/host/bin/flang-new  -fPIC  -O2 -c decorana.f -o decorana.o
emcc -DNDEBUG   -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.3.3/build/include -I/opt/webr/R/build/R-4.3.3/src/include -s USE_BZIP2=1 -s USE_ZLIB=1  -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -std=gnu11 -c getF.c -o getF.o
emcc -DNDEBUG   -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.3.3/build/include -I/opt/webr/R/build/R-4.3.3/src/include -s USE_BZIP2=1 -s USE_ZLIB=1  -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -std=gnu11 -c goffactor.c -o goffactor.o
emcc -DNDEBUG   -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.3.3/build/include -I/opt/webr/R/build/R-4.3.3/src/include -s USE_BZIP2=1 -s USE_ZLIB=1  -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -std=gnu11 -c init.c -o init.o
/opt/flang/host/bin/flang-new  -fPIC  -O2 -c monoMDS.f -o monoMDS.o
emcc -DNDEBUG   -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.3.3/build/include -I/opt/webr/R/build/R-4.3.3/src/include -s USE_BZIP2=1 -s USE_ZLIB=1  -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -std=gnu11 -c nestedness.c -o nestedness.o
/opt/flang/host/bin/flang-new  -fPIC  -O2 -c ordering.f -o ordering.o
emcc -DNDEBUG   -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.3.3/build/include -I/opt/webr/R/build/R-4.3.3/src/include -s USE_BZIP2=1 -s USE_ZLIB=1  -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -std=gnu11 -c pnpoly.c -o pnpoly.o
emcc -DNDEBUG   -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.3.3/build/include -I/opt/webr/R/build/R-4.3.3/src/include -s USE_BZIP2=1 -s USE_ZLIB=1  -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -std=gnu11 -c stepacross.c -o stepacross.o
emcc -DNDEBUG   -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.3.3/build/include -I/opt/webr/R/build/R-4.3.3/src/include -s USE_BZIP2=1 -s USE_ZLIB=1  -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -std=gnu11 -c vegdist.c -o vegdist.o
emcc -s SIDE_MODULE=1 -s WASM_BIGINT -s ASSERTIONS=1 -L/opt/webr/wasm/lib -L/opt/webr/wasm/R-4.3.3/lib/R/lib -s USE_BZIP2=1 -s USE_ZLIB=1 -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -Oz -o vegan.so data2hill.o decorana.o getF.o goffactor.o init.o monoMDS.o nestedness.o ordering.o pnpoly.o stepacross.o vegdist.o -L/lib/R/lib -lRlapack -L/lib/R/lib -lRblas /opt/flang/wasm/lib/libFortranRuntime.a
wasm-ld: error: function signature mismatch: malloc
>>> defined as (i64) -> i32 in monoMDS.o
>>> defined as (i32) -> i32 in /opt/flang/wasm/lib/libFortranRuntime.a(ISO_Fortran_binding.o)
emcc: error: '/opt/emsdk/upstream/bin/wasm-ld -o vegan.so --whole-archive -L/opt/webr/wasm/lib -L/opt/webr/wasm/R-4.3.3/lib/R/lib data2hill.o decorana.o getF.o goffactor.o init.o monoMDS.o nestedness.o ordering.o pnpoly.o stepacross.o vegdist.o -L/lib/R/lib /opt/webr/wasm/R-4.3.3/lib/R/lib/libRlapack.so -L/lib/R/lib /opt/webr/wasm/R-4.3.3/lib/R/lib/libRblas.so /opt/flang/wasm/lib/libFortranRuntime.a -L/opt/emsdk/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/pic --no-whole-archive -mllvm -combiner-global-alias-analysis=false -mllvm -wasm-enable-sjlj -mllvm -disable-lsr -mllvm -wasm-enable-eh -mllvm -exception-model=wasm --import-memory --strip-debug --export-dynamic --export-if-defined=main --export-if-defined=__get_exception_message --export-if-defined=free --export-if-defined=__cpp_exception --export-if-defined=__cxa_increment_exception_refcount --export-if-defined=__cxa_decrement_exception_refcount --export-if-defined=__thrown_object_from_unwind_exception --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export-if-defined=__wasm_apply_data_relocs --export-if-defined=fflush --export=__wasm_call_ctors --experimental-pic -shared' failed (returned 1)
make: *** [/opt/R/4.3.2/lib/R/share/make/shlib.mk:10: vegan.so] Error 1
ERROR: compilation failed for package 'vegan'
* removing '/tmp/RtmpyRTq6H/file19f246e3/vegan'
Error in wasm_build(pkg, tarball_path, out_dir) :
  Building wasm binary for package 'vegan' failed.

the issue seems to be a mismatch between 32bit integers and 64 bit integers

This should now work, see vegandevs/vegan#623 for details.