Skip to content

Add recipe for oneTBB - #618

Open
andrjohns wants to merge 2 commits into
r-wasm:mainfrom
andrjohns:onetbb
Open

Add recipe for oneTBB#618
andrjohns wants to merge 2 commits into
r-wasm:mainfrom
andrjohns:onetbb

Conversation

@andrjohns

Copy link
Copy Markdown

Adds oneTBB as one of the container libraries, for use by the development/next version of RcppParallel and its dependencies.

Verified via:

# TBB_INC="/opt/webr/wasm/include" TBB_LIB="/opt/webr/wasm/lib" R

R version 4.6.0 (2026-04-24) -- "Because it was There"
Copyright (C) 2026 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> rwasm::add_pkg("RcppCore/RcppParallel")
! Using bundled GitHub PAT. Please add your own PAT using `gitcreds::gitcreds_set()`.
Processing 1 package(s).
v Loading metadata database ... done
trying URL 'https://api.github.com/repos/RcppCore/RcppParallel/zipball/e4e33f47ef069cd16bfd8eaa3c68fad3ba09ea7b'
downloaded 987 KB

gzip: stdin has more than one entry--rest ignored
/usr/bin/tar: Child returned status 2
/usr/bin/tar: Error is not recoverable: exiting now
                                                                                                             
> Package library at /root/R/x86_64-pc-linux-gnu-library/4.6.
> The package (0 B) is cached.
v All system requirements are already installed.
  
i No downloads are needed
v :  [2.4s]  
* installing *source* package 'RcppParallel' ...
** this is package 'RcppParallel' version '5.1.10.9000'
** using non-staged installation
emconfigure: sh -c './configure.orig --build=x86_64-pc-linux-gnu --host=wasm32-unknown-emscripten ac_cv_func_getrandom=no' in directory /tmp/Rtmp6EJTNm/file4d28688fe122/RcppParallel
** preparing to configure package 'RcppParallel' ...
'config' variable 'CXX11' is defunct
*** configured file: 'R/tbb-autodetected.R.in' => 'R/tbb-autodetected.R'
*** configured file: 'src/Makevars.in' => 'src/Makevars'
** finished configure for package 'RcppParallel'
** libs
using C++ compiler: 'emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 5.0.7 (263db4cffa6f9fc2ec514a70abac81362ea41849)'
WARNING: ignoring environment value of R_HOME
em++ -std=gnu++17 -DNDEBUG -I../inst/include -I"/opt/webr/wasm/include"  -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.6.0/build/include -I/opt/webr/R/build/R-4.6.0/src/include -s USE_BZIP2=1 -s USE_ZLIB=1 -DRCPP_PARALLEL_USE_TBB=1 -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -DRCPP_DEMANGLER_ENABLED=0 -D__STRICT_ANSI__  -c init.cpp -o init.o
em++ -std=gnu++17 -DNDEBUG -I../inst/include -I"/opt/webr/wasm/include"  -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.6.0/build/include -I/opt/webr/R/build/R-4.6.0/src/include -s USE_BZIP2=1 -s USE_ZLIB=1 -DRCPP_PARALLEL_USE_TBB=1 -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -DRCPP_DEMANGLER_ENABLED=0 -D__STRICT_ANSI__  -c options.cpp -o options.o
em++ -std=gnu++17 -DNDEBUG -I../inst/include -I"/opt/webr/wasm/include"  -I/opt/webr/wasm/include -I/opt/webr/R/build/R-4.6.0/build/include -I/opt/webr/R/build/R-4.6.0/src/include -s USE_BZIP2=1 -s USE_ZLIB=1 -DRCPP_PARALLEL_USE_TBB=1 -fpic  -Oz -fPIC -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -DRCPP_DEMANGLER_ENABLED=0 -D__STRICT_ANSI__  -c tbb.cpp -o tbb.o
em++ -std=gnu++17 -s SIDE_MODULE=1 -s WASM_BIGINT -s ASSERTIONS=1 -L/opt/webr/wasm/lib -L/opt/webr/wasm/R-4.6.0/lib/R/lib -s USE_BZIP2=1 -s USE_ZLIB=1 -fwasm-exceptions -s SUPPORT_LONGJMP=wasm -Oz -o RcppParallel.so init.o options.o tbb.o -Wl,-L/opt/webr/wasm/lib -Wl,-rpath,/opt/webr/wasm/lib -ltbb -ltbbmalloc -Wl,-rpath,$ORIGIN/../lib
installing via 'install.libs.R' to /tmp/Rtmp6EJTNm/file4d282755c433/RcppParallel
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
* SHA256 sums
* creating tarball
packaged installation of 'RcppParallel' as 'RcppParallel_5.1.10.9000_R_x86_64-pc-linux-gnu.tar.gz'
* DONE (RcppParallel)
Appending virtual filesystem metadata for: repo/bin/emscripten/contrib/4.6/RcppParallel_5.1.10.9000.tgz
Processing packages:
  /opt/webr/repo/src/contrib/RcppParallel_5.1.10.9000_e4e33f4.tar.gz
done
Processing packages:
  /opt/webr/repo/bin/emscripten/contrib/4.6/RcppParallel_5.1.10.9000.tgz
done
> 

@andrjohns

Copy link
Copy Markdown
Author

Can also confirm with the above recipe and the github RcppParallel, that rstan-based packages (e.g., rstanarm) can now be built for webr 🎉

@andrjohns

Copy link
Copy Markdown
Author

@jeroen would you mind testing this addition of oneTBB and the associated rwasm PR against some of the r-universe infrastructure/workflows when you have the time? My main goal is unbreaking the WASM builds for all of the rstan downstream packages. Thanks!

jeroen added a commit to r-universe-org/build-wasm that referenced this pull request Jul 20, 2026
@jeroen

jeroen commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

OK I have cherry-picked this PR into the r-universe build container. But if I understand you correctly, you need to add the git version of RcppParallel to your universe (https://github.com/stan-dev/stan-dev.r-universe.dev/tree/main) to test buliding rstan against that.

jeroen added a commit to r-universe-org/build-wasm that referenced this pull request Jul 20, 2026
@andrjohns

andrjohns commented Jul 20, 2026

Copy link
Copy Markdown
Author

OK I have cherry-picked this PR into the r-universe build container. But if I understand you correctly, you need to add the git version of RcppParallel to your universe (https://github.com/stan-dev/stan-dev.r-universe.dev/tree/main) to test buliding rstan against that.

Fantastic! Would you also be able to switch the rwasm version to the one from this PR: r-wasm/rwasm#61 or set the TBB_INC & TBB_LIB environment variables for the container? I don't think there's a way to set environment variables in the bootstrap.R/.prepare.sh scripts is there?

jeroen added a commit to r-universe-org/build-wasm that referenced this pull request Jul 20, 2026
@jeroen

jeroen commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

OK I have done so here: r-universe-org/build-wasm@8b64c47

However the build still seems to fail. Is this because of the RcppParallel version? https://github.com/r-universe-org/build-wasm/actions/runs/29726260090/job/88299949297

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants