From d74424cb3780284a989b1784a984003bd68e4ed4 Mon Sep 17 00:00:00 2001 From: pat-s Date: Sun, 19 Jul 2026 08:39:53 +0000 Subject: [PATCH] fix(patches): build RcppParallel against system oneTBB instead of disabling TBB The disable-tbb patch skipped the bundled Intel TBB build by forcing the TinyThread backend, which also stripped RcppParallel's TBB linkage. That broke every dependent that links TBB through RcppParallelLibs() (rstan and the whole Stan cluster) with 'symbol not found: tbb::detail::r1::observe'. Replace it with system-tbb.patch: leave USE_TBB unset (so the bundled build is skipped on musl and g++ 15) but keep the TBB backend and link the system oneTBB that the build-env images now ship. RcppParallelLibs() then hands the system-TBB link flags to dependents, provided TBB_INC/TBB_LIB are exported in the images (added separately in build-env-images). Verified in the build-env-alpine:3.24 image: RcppParallel builds against oneTBB 2022 with no ABI errors, and rstan links (-ltbb -ltbbmalloc) and loads without the missing-symbol error. --- local/patches/RcppParallel/disable-tbb.patch | 16 ---------------- local/patches/RcppParallel/system-tbb.patch | 19 +++++++++++++++++++ local/patches/registry.json | 17 ++++++++++++----- 3 files changed, 31 insertions(+), 21 deletions(-) delete mode 100644 local/patches/RcppParallel/disable-tbb.patch create mode 100644 local/patches/RcppParallel/system-tbb.patch diff --git a/local/patches/RcppParallel/disable-tbb.patch b/local/patches/RcppParallel/disable-tbb.patch deleted file mode 100644 index 0fe8ad9..0000000 --- a/local/patches/RcppParallel/disable-tbb.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff --git a/src/Makevars.in b/src/Makevars.in -index be8445f..faee771 100644 ---- a/src/Makevars.in -+++ b/src/Makevars.in -@@ -60,7 +60,10 @@ else - endif - - ifeq ($(UNAME), Linux) -- USE_TBB=Linux -+ # bincraft patch: the bundled Intel TBB build hangs/fails on musl (Alpine) -+ # and newer toolchains (g++ 15). Skip it (leave USE_TBB unset) and force the -+ # TinyThread backend so RcppParallel still builds. -+ PKG_CXXFLAGS += -DRCPP_PARALLEL_USE_TBB=0 - endif - - ifeq ($(UNAME), SunOS) diff --git a/local/patches/RcppParallel/system-tbb.patch b/local/patches/RcppParallel/system-tbb.patch new file mode 100644 index 0000000..263a593 --- /dev/null +++ b/local/patches/RcppParallel/system-tbb.patch @@ -0,0 +1,19 @@ +diff --git a/src/Makevars.in b/src/Makevars.in +index be8445f..7cb6c9e 100644 +--- a/src/Makevars.in ++++ b/src/Makevars.in +@@ -60,7 +60,13 @@ else + endif + + ifeq ($(UNAME), Linux) +- USE_TBB=Linux ++ # bincraft patch: link the system oneTBB (installed in the build-env images) ++ # instead of building the bundled Intel TBB, which fails on musl (Alpine) and ++ # newer toolchains (g++ 15). Leaving USE_TBB unset skips the bundled build; ++ # -DRCPP_PARALLEL_USE_TBB=1 keeps the TBB backend so dependents (rstan, ...) ++ # link TBB, and -ltbb/-ltbbmalloc pull the system library from default paths. ++ PKG_CXXFLAGS += -DRCPP_PARALLEL_USE_TBB=1 -DTBB_SUPPRESS_DEPRECATED_MESSAGES=1 -DTBB_INTERFACE_NEW ++ PKG_LIBS += -ltbb -ltbbmalloc + endif + + ifeq ($(UNAME), SunOS) diff --git a/local/patches/registry.json b/local/patches/registry.json index e53f1c9..c446fda 100644 --- a/local/patches/registry.json +++ b/local/patches/registry.json @@ -2,17 +2,22 @@ { "package": "RcppParallel", "versions": "*", - "platforms": ["alpine", "ubuntu-2604"], + "platforms": [ + "alpine", + "ubuntu-2604" + ], "env": {}, "configure_args": [], "makevars": {}, - "patch": "RcppParallel/disable-tbb.patch", - "reason": "bundled Intel TBB build hangs/fails on musl (Alpine) and newer toolchains (g++ 15 on ubuntu-2604); patch unsets USE_TBB and forces -DRCPP_PARALLEL_USE_TBB=0 so RcppParallel skips the bundled build and uses the TinyThread backend" + "patch": "RcppParallel/system-tbb.patch", + "reason": "bundled Intel TBB build hangs/fails on musl (Alpine) and newer toolchains (g++ 15 on ubuntu-2604); link the system oneTBB (now in the build-env images) instead, keeping the TBB backend so dependents (rstan, ...) link TBB" }, { "package": "fs", "versions": "*", - "platforms": ["*"], + "platforms": [ + "*" + ], "env": {}, "configure_args": [], "makevars": {}, @@ -22,7 +27,9 @@ { "package": "rstan", "versions": "*", - "platforms": ["*"], + "platforms": [ + "*" + ], "env": {}, "configure_args": [], "makevars": { -- 2.54.0