Skip to content

build tbb stub from static library on older toolchains#258

Merged
kevinushey merged 1 commit into
masterfrom
bugfix/stub-old-tbb
Jul 23, 2026
Merged

build tbb stub from static library on older toolchains#258
kevinushey merged 1 commit into
masterfrom
bugfix/stub-old-tbb

Conversation

@kevinushey

Copy link
Copy Markdown
Contributor

Discovered testing on R 4.2 / Rtools42, which provides an older (non-oneTBB) TBB (libtbb_static.a, interface5 headers). Three issues:

  1. Stale stub reuse (correctness): R CMD SHLIB -o tbb-compat/tbb.dll considers a leftover tbb.dll up-to-date and re-ships it -- observed shipping an Rtools45/oneTBB-built stub into an Rtools42/R 4.2 installation. The stub outputs are now deleted before building, and cleanup.R removes them too.
  2. Fresh installs on old-TBB toolchains failed: tbb-compat.cpp wraps the oneTBB runtime (tbb::detail::r1::observe), which doesn't exist in old TBB, so the stub link (and the install) would fail. Skipping the stub isn't an option either: downstream -ltbb (StanHeaders) needs a tbb.dll to link, since Rtools42 ships only libtbb_static.a. Instead, build the stub by re-exporting the static library wholesale (-Wl,--whole-archive) -- old TBB already provides the old ABI, no shim needed. Dispatch is by presence of <TBB_INC>/oneapi.
  3. Cosmetic: useTbbPreamble() now returns invisibly (a stray NULL was printed via R -f auto-printing), and logging messages standardize on lowercase 'tbb'.

The whole-archive path needs validation on a real Rtools42 setup (in progress).

Rtools42-era toolchains provide an older (non-oneTBB) copy of TBB, so
tbb-compat.cpp -- which wraps the oneTBB runtime -- cannot build there,
and the install would fail at the stub link. But the old static library
already provides the old ABI, so re-export it wholesale instead.

Also:

- remove stale tbb-compat build artifacts before building the stub;
  'make' would otherwise consider a tbb.dll built by a different
  toolchain (or against a different TBB) up-to-date and re-ship it

- clean tbb-compat artifacts in cleanup.R

- return invisibly from useTbbPreamble(), so 'NULL' is no longer
  printed when install.libs.R is run via R -f

- standardize on lowercase 'tbb' in logging messages
@kevinushey
kevinushey merged commit b26d7cd into master Jul 23, 2026
5 checks passed
@kevinushey
kevinushey deleted the bugfix/stub-old-tbb branch July 23, 2026 23:30
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.

1 participant