SCM

[#6842] issue with compiling package for webR / wasm

Date:
2024-03-10 16:29
Priority:
1
State:
Open
Submitted by:
Is Bool (isbool)
Assigned to:
Nobody (None)
Hardware:
None
Product:
None
Operating System:
None
Component:
None
Version:
None
Severity:
None
Resolution:
None
URL:
Summary:
issue with compiling package for webR / wasm

Detailed description
Hey im trying to compile the package for webR / wasm and get the following error:

> rwasm::build('./robustbase_local')

> Will install 1 package.
> Will download 2 packages with unknown size.
+ DEoptimR 1.1-3 [dl]

i Getting 1 pkg with unknown size
v Got DEoptimR 1.1-3 (x86_64-pc-linux-gnu-ubuntu-22.04) (72.16 kB)
v Downloaded 1 package (72.16 kB) in 2.5s
v Installed DEoptimR 1.1-3 (25ms)
v 1 dep: added 1, dld 1 (72.16 kB) [3.4s]
* installing *source* package 'robustbase' ...
** 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 R-rng4ftn.c -o R-rng4ftn.o
/opt/flang/host/bin/flang-new -fPIC -O2 -c eigen.f -o eigen.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
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 lmrob.c -o lmrob.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 mc.c -o mc.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 monitor.c -o monitor.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 qn_sn.c -o qn_sn.o
/opt/flang/host/bin/flang-new -fPIC -O2 -c rf-common.f -o rf-common.o
/opt/flang/host/bin/flang-new -fPIC -O2 -c rffastmcd.f -o rffastmcd.o
/opt/flang/host/bin/flang-new -fPIC -O2 -c rfltsreg.f -o rfltsreg.o
./rfltsreg.f:252:14: warning: Reference to the procedure 'intpr' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object types: CHARACTER(KIND=1,LEN=28_8) vs CHARACTER(KIND=1,LEN=18_8)
+ call intpr(' rftls.... minigr=',-1,[minigr],1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./rfltsreg.f:136:10: previous reference to 'intpr'
call intpr('Entering rfltsreg() - krep: ',-1, i_aux, 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./rfltsreg.f:337:11: warning: Reference to the procedure 'intpr' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object types: CHARACTER(KIND=1,LEN=28_8) vs CHARACTER(KIND=1,LEN=31_8)
+ call intpr(' rftls.... initialization ready',-1,[0],1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./rfltsreg.f:136:10: previous reference to 'intpr'
call intpr('Entering rfltsreg() - krep: ',-1, i_aux, 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./rfltsreg.f:417:10: warning: Reference to the procedure 'intpr' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object types: CHARACTER(KIND=1,LEN=28_8) vs CHARACTER(KIND=1,LEN=43_8)
call intpr('Main (number of trials nrep, kstep, nhalf):',
^
./rfltsreg.f:136:10: previous reference to 'intpr'
call intpr('Entering rfltsreg() - krep: ',-1, i_aux, 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./rfltsreg.f:446:15: warning: Reference to the procedure 'intpr' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object types: CHARACTER(KIND=1,LEN=28_8) vs CHARACTER(KIND=1,LEN=31_8)
+ call intpr(' rftls.... looping by group ii=',-1,[ii],1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./rfltsreg.f:136:10: previous reference to 'intpr'
call intpr('Entering rfltsreg() - krep: ',-1, i_aux, 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./rfltsreg.f:471:17: warning: Reference to the procedure 'intpr' has an implicit interface that is distinct from another reference: incompatible dummy argument #1: incompatible dummy data object types: CHARACTER(KIND=1,LEN=28_8) vs CHARACTER(KIND=1,LEN=30_8)
+ call intpr(' rftls.... for(i = 1,nrep): i=',-1,[i],1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
./rfltsreg.f:136:10: previous reference to 'intpr'
call intpr('Entering rfltsreg() - krep: ',-1, i_aux, 1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/opt/flang/host/bin/flang-new -fPIC -O2 -c rllarsbi.f -o rllarsbi.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 rob-utils.c -o rob-utils.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 rowMedians.c -o rowMedians.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 wgt_himed.c -o wgt_himed.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 robustbase.so R-rng4ftn.o eigen.o init.o lmrob.o mc.o monitor.o qn_sn.o rf-common.o rffastmcd.o rfltsreg.o rllarsbi.o rob-utils.o rowMedians.o wgt_himed.o -L/lib/R/lib -lRlapack -L/lib/R/lib -lRblas /opt/flang/wasm/lib/libFortranRuntime.a
wasm-ld: error: function signature mismatch: realloc
>>> defined as (i32, i64) -> i32 in rfltsreg.o
>>> defined as (i32, i32) -> i32 in /opt/flang/wasm/lib/libFortranRuntime.a(array-constructor.o)
emcc: error: '/opt/emsdk/upstream/bin/wasm-ld -o robustbase.so --whole-archive -L/opt/webr/wasm/lib -L/opt/webr/wasm/R-4.3.3/lib/R/lib R-rng4ftn.o eigen.o init.o lmrob.o mc.o monitor.o qn_sn.o rf-common.o rffastmcd.o rfltsreg.o rllarsbi.o rob-utils.o rowMedians.o wgt_himed.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: robustbase.so] Error 1
ERROR: compilation failed for package 'robustbase'
* removing '/tmp/RtmpFy5BE1/file141acad65/robustbase'
Error in wasm_build(pkg, tarball_path, out_dir) :
Building wasm binary for package 'robustbase' failed.

This issue seems to be the same as here: https://github.com/vegandevs/vegan/issues/623

meaning issues with Fortran dynamic memory allocation

Comments:

Message  ↓
Date: 2024-03-11 15:24
Sender: Is Bool

Yes that seems to be the case, the vegan dev (as you can see from the issue on github) said that it would be possible for this to get fixed from the package developer side by converting the dynamic memory allocation to static for the functions that causehttps://r-forge.r-project.org/tracker/?func=detail&atid=302&aid=6842&group_id=59#sort the issue (if its possible). Would that be something that you would be interested at looking at ?


Date: 2024-03-11 08:26
Sender: Martin Maechler

Well, that's of course a bug in webR / wasm
not in our package (nor in vegan) !!

Attached Files:

Changes

Field Old Value Date By
priority32024-03-11 08:26mmaechler
Thanks to:
Vienna University of Economics and Business Powered By FusionForge