r-wasm / webr

The statistical language R compiled to WebAssembly via Emscripten, for use in web browsers and Node.
https://docs.r-wasm.org/webr/latest/
Other
804 stars 54 forks source link

issue with compiling package: Rmpfr #453

Open isbool opened 1 week ago

isbool commented 1 week ago

Rmpfr-after-stubs32-config.log Rmpfr-stubs-32-config.log

Hey, im trying to compile the package to wasm using the latest docker image and I get the following error:

rwasm::build('./Rmpfr_local')

> Will install 1 package.
> Will download 2 packages with unknown size.
+ gmp 0.7-4 [dl] + x libgmp3-dev
> Will install 2 system packages:
+ libgmp3-dev - Rmpfr-deps, gmp
+ libmpfr-dev - Rmpfr-deps
i Getting 1 pkg with unknown size
v Got gmp 0.7-4 (x86_64-pc-linux-gnu-ubuntu-22.04) (321.17 kB)
v Downloaded 1 package (321.17 kB) in 4.6s
i Installing system requirements
i Executing `sh -c apt-get -y update`
i Executing `sh -c apt-get -y install libgmp3-dev libmpfr-dev`
v Installed gmp 0.7-4 (32ms)
v 1 dep: added 1, dld 1 (321.17 kB) [14s]
* installing *source* package 'Rmpfr' ...
** using non-staged installation
configure: sh -c "./configure.orig --build=x86_64-pc-linux-gnu --host=wasm32-unknown-emscripten"
checking for wasm32-unknown-emscripten-gcc... emcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether emcc accepts -g... yes
checking for emcc option to accept ISO C89... none needed
checking how to run the C preprocessor... emcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mpfr.h usability... yes
checking mpfr.h presence... yes
checking for mpfr.h... yes
checking gmp.h usability... yes
checking gmp.h presence... yes
checking for gmp.h... yes
checking for __gmpz_init in -lgmp... yes
checking for mpfr_init in -lmpfr... yes
checking for mpfr_digamma in -lmpfr... no
configure.orig: error: MPFR Library must be at least version 3.0.0, see README
emconfigure: error: 'sh -c "./configure.orig --build=x86_64-pc-linux-gnu --host=wasm32-unknown-emscripten"' failed (returned 1)
ERROR: configuration failed for package 'Rmpfr'
* removing '/tmp/RtmpFy5BE1/file12df5eb89/Rmpfr'
Error in wasm_build(pkg, tarball_path, out_dir) :
Building wasm binary for package 'Rmpfr' failed.

To fix the above error i did:

Sys.setenv(C_INCLUDE_PATH = "/usr/include:/usr/include/x86_64-linux-gnu:/usr/local/include") Sys.setenv(CPLUS_INCLUDE_PATH = "/usr/include:/usr/include/x86_64-linux-gnu:/usr/local/include") Sys.setenv(LD_LIBRARY_PATH = "/usr/lib:/usr/local/lib")

build('./build-output/Rmpfr_local')

> The package (0 B) is cached.
v All system requirements are already installed.

i No downloads are needed
v 1 dep: kept 1 [559ms]
* installing *source* package 'Rmpfr' ...
** using non-staged installation
configure: sh -c "./configure.orig --build=x86_64-pc-linux-gnu --host=wasm32-unknown-emscripten ac_cv_func_getrandom=no"
checking for wasm32-unknown-emscripten-gcc... emcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether emcc accepts -g... yes
checking for emcc option to accept ISO C89... unsupported
checking how to run the C preprocessor... /lib/cpp
configure.orig: error: in `/tmp/RtmpOn1t17/file13632aedd/Rmpfr':
configure.orig: error: C preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
emconfigure: error: 'sh -c "./configure.orig --build=x86_64-pc-linux-gnu --host=wasm32-unknown-emscripten ac_cv_func_getrandom=no"' failed (returned 1)
ERROR: configuration failed for package 'Rmpfr'
* removing '/tmp/RtmpOn1t17/file12a6f78a9/Rmpfr'
config.log copied to output directory.
config.log copied to output directory.
Error in wasm_build(pkg, tarball_path, out_dir) :
  Building wasm binary for package 'Rmpfr' failed.
>

By looking at the config.log (attached as Rmpfr-stubs-32-config.log) I see that a header file is missing:

/usr/include/x86_64-linux-gnu/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
    7 | # include <gnu/stubs-32.h>

So it seems we need to install: apt-get install libc6-dev-i386 when installing it and re running the R console and trying to build again, i get this again (attached as Rmpfr-after-stubs32-config.log)

build('./build-output/Rmpfr_local')

> The package (0 B) is cached.
v All system requirements are already installed.

i No downloads are needed
v 1 dep: kept 1 [583ms]
* installing *source* package 'Rmpfr' ...
** using non-staged installation
configure: sh -c "./configure.orig --build=x86_64-pc-linux-gnu --host=wasm32-unknown-emscripten ac_cv_func_getrandom=no"
checking for wasm32-unknown-emscripten-gcc... emcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether emcc accepts -g... yes
checking for emcc option to accept ISO C89... none needed
checking how to run the C preprocessor... emcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mpfr.h usability... yes
checking mpfr.h presence... yes
checking for mpfr.h... yes
checking gmp.h usability... yes
checking gmp.h presence... yes
checking for gmp.h... yes
checking for __gmpz_init in -lgmp... yes
checking for mpfr_init in -lmpfr... yes
checking for mpfr_digamma in -lmpfr... no
configure.orig: error: MPFR Library must be at least version 3.0.0, see README
emconfigure: error: 'sh -c "./configure.orig --build=x86_64-pc-linux-gnu --host=wasm32-unknown-emscripten ac_cv_func_getrandom=no"' failed (returned 1)
ERROR: configuration failed for package 'Rmpfr'
* removing '/tmp/RtmpOn1t17/file11b8b323b/Rmpfr'
config.log copied to output directory.
config.log copied to output directory.
Error in wasm_build(pkg, tarball_path, out_dir) :
  Building wasm binary for package 'Rmpfr' failed.
>