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

Mechanism to override `AC_CHECK_FUNCS` in Autoconf #32

Closed georgestagg closed 5 months ago

georgestagg commented 5 months ago

For R packages using Autoconf, we'll sometimes need to be able to force the result of AC_CHECK_FUNCS.

For example, in the uuid package Autoconf sets HAVE_GETRANDOM. Despite compiling OK, using getrandom() at the time of writing fails for R packages compiled using Emscripten, due to a missing symbol. Autoconf missed this because we compile R packages with the SIDE_MODULE=1 flag. With this flag, Emscripten does not complain about the missing symbols at compile time, but the result fails at runtime.

So, using this mechanism we can force Autoconf to return "no" when checking for getrandom(), fixing the issue with uuid. We can also extend the mechanism in the future to force other AC_CHECK_FUNCS results if we find other R packages with similar runtime issues.

TODO: In the case of non-autoconf-based configure scripts we already pass extra arguments --build and --host, but in principle we should add something so that we don't pass these Autoconf flags to generic configure scripts not expecting them.