r-wasm / rwasm

Build R packages for WebAssembly and create a CRAN-like repo for distribution.
https://r-wasm.github.io/rwasm/
Other
54 stars 4 forks source link

Default `--configure-args` for packages using autoconf #5

Closed jeroen closed 9 months ago

jeroen commented 10 months ago

Some R packages that are using autoconf scripts are failing in my docker/linux builds:

checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
configure: error: in `/tmp/tmp.T91b410ZyL/RcppArmadillo':
configure: error: cannot run C++ compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details

The fix (confirmed) is to default --configure-args to something like:

R CMD INSTALL --configure-args="--build=x86_64-pc-linux-gnu --host=wasm32-unknown-emscripten"

But I also noticed you already have this package on https://repo.r-wasm.org/ so perhaps I am doing something else wrong.

georgestagg commented 9 months ago

In 6a614a0 I've tweaked the configure script override to add --host=wasm32-unknown-emscripten in addition to the existing wrapping with Emscripten's emconfigure helper.

That should hopefully fix autoconf-based configure scripts, at the cost of potentially breaking custom configure scripts that don't support --host, if any exist. We can deal with those if and when the time comes.

This is now how things look for RcppArmadillo on my machine with this change:

Expand log ``` > rwasm::build("RcppArmadillo", out_dir="/tmp") ⸨████████████ ⸩ Found 75 deps for 18/19 pkgs [⠦] Resolving r-wasm/LiblineaR… trying URL 'https://packagemanager.posit.co/cran/latest/src/contrib/RcppArmadillo_0.12.6.6.0.tar.gz' Content type 'binary/octet-stream' length 1403106 bytes (1.3 MB) ================================================== downloaded 1.3 MB Found 1 deps for 0/1 pkgs [⠋] Resolving deps::/var/folders/wx/qv_075m16yx5… Found 6 deps for 1/1 pkgs [⠙] Resolving standard (CRAN/BioC) packages → The package (0 B) is cached. ℹ No downloads are needed Installing... ✔ 1 dep: kept 1 [6.6s] * installing *source* package ‘RcppArmadillo’ ... file ‘configure’ has the wrong MD5 checksum ** using non-staged installation configure: ./configure.orig --host=wasm32-unknown-emscripten checking whether the C++ compiler works... yes checking for C++ compiler default output file name... a.out checking whether we are cross compiling... yes o checking whether the compiler supports GNU C++... yes checking whether em++ accepts -g... yes checking for em++ option to enable C++11 features... none needed em++ -E checking whether the compiler supports GNU C++... (cached) yes checking whether em++ accepts -g... (cached) yes checking for em++ option to enable C++11 features... (cached) none needed /var/folders/wx/qv_075m16yx5lqwvjfwswfqm0000gn/T checking whether R CMD SHLIB can already compile programs using OpenMP... no almost configure.orig: WARNING: Compiler self-identifies as being compliant with GNUC extensions but is not g++. checking for macOS... found not found checking for clang compiler... not found configure.orig: WARNING: unsupported macOS build detected; if anything breaks, you keep the pieces. checking LAPACK_LIBS... R-supplied partial LAPACK found configure.orig: WARNING: Some complex-valued LAPACK functions may not be available configure.orig: creating ./config.status config.status: creating inst/include/RcppArmadillo/config/RcppArmadilloConfigGenerated.h config.status: creating src/Makevars ** libs using C++ compiler: ‘emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.37 (d02c29f95e9e68f2f50c2b0432c56a671814d5c8)’ using SDK: ‘MacOSX14.0.sdk’ em++ -DNDEBUG -I../inst/include -I'/Users/georgestagg/Library/R/arm64/4.3/library/Rcpp/include' -I/Users/georgestagg/work/webr/wasm/include -I/Users/georgestagg/work/webr/R/build/R-4.3.0/build/include -I/Users/georgestagg/work/webr/R/build/R-4.3.0/src/include -s USE_BZIP2=1 -s USE_ZLIB=1 -fPIC -std=gnu++11 -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -DRCPP_DEMANGLER_ENABLED=0 -D__STRICT_ANSI__ -c RcppArmadillo.cpp -o RcppArmadillo.o em++ -DNDEBUG -I../inst/include -I'/Users/georgestagg/Library/R/arm64/4.3/library/Rcpp/include' -I/Users/georgestagg/work/webr/wasm/include -I/Users/georgestagg/work/webr/R/build/R-4.3.0/build/include -I/Users/georgestagg/work/webr/R/build/R-4.3.0/src/include -s USE_BZIP2=1 -s USE_ZLIB=1 -fPIC -std=gnu++11 -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -DRCPP_DEMANGLER_ENABLED=0 -D__STRICT_ANSI__ -c RcppExports.cpp -o RcppExports.o em++ -DNDEBUG -I../inst/include -I'/Users/georgestagg/Library/R/arm64/4.3/library/Rcpp/include' -I/Users/georgestagg/work/webr/wasm/include -I/Users/georgestagg/work/webr/R/build/R-4.3.0/build/include -I/Users/georgestagg/work/webr/R/build/R-4.3.0/src/include -s USE_BZIP2=1 -s USE_ZLIB=1 -fPIC -std=gnu++11 -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -DRCPP_DEMANGLER_ENABLED=0 -D__STRICT_ANSI__ -c fastLm.cpp -o fastLm.o em++ -s SIDE_MODULE=1 -s WASM_BIGINT -s ASSERTIONS=1 -L/Users/georgestagg/work/webr/wasm/lib -L/Users/georgestagg/work/webr/wasm/R-4.3.0/lib/R/lib -s USE_BZIP2=1 -s USE_ZLIB=1 -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -Oz -o RcppArmadillo.so RcppArmadillo.o RcppExports.o fastLm.o -L/lib/R/lib -lRlapack -L/lib/R/lib -lRblas -L/Users/georgestagg/work/webr/wasm/lib -lFortranRuntime installing to /private/var/folders/wx/qv_075m16yx5lqwvjfwswfqm0000gn/T/RtmppilQRi/fileb0755b56ca00/RcppArmadillo/libs ** R ** inst ** preparing package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes * creating tarball packaged installation of ‘RcppArmadillo’ as ‘RcppArmadillo_0.12.6.6.0_R_aarch64-apple-darwin20.tar.gz’ * DONE (RcppArmadillo) Packaging: RcppArmadillo_0.12.6.6.0.data ```