r-universe-org / help

Support and bug tracker for R-universe
https://docs.r-universe.dev/
9 stars 2 forks source link

Errors compiling andrjohns/StanEstimators for wasm #335

Open StaffanBetner opened 9 months ago

StaffanBetner commented 9 months ago

I've been trying to get andrjohns/StanEstimators to compile for wasm. The error seems to be that clang is a bit too strict compared to gcc. I have tried several ways to shoehorn in -ferror-limit=0 just for the wasm compilation in Makevars, but no success.

Here is the log for my own fork: https://github.com/r-universe/staffanbetner/actions/runs/7324325268/job/19948119677

andrjohns commented 9 months ago

Specifically the issue appears to be caused by this TBB header in RcppParallel, which detects OS/machine capabilities - but fails because there is no __EMSCRIPTEN__ definition.

From testing locally, it builds successfully if I add the following include before including other headers:

#ifdef __EMSCRIPTEN__
    #define __linux__ 1
#endif
#include <tbb/tbb_machine.h>
#ifdef __EMSCRIPTEN__
    #undef __linux__
#endif

But naturally the better solution would be to have RcppParallel (or at least some version of the TBB) building for wasm

StaffanBetner commented 8 months ago

I think it might work if RcppParallel is built with libtbb, so that e.g. StanEstimators link to that. What do you think, @jeroen?