Skip to content

load tbb stub library on windows again#249

Merged
kevinushey merged 2 commits into
masterfrom
bugfix/windows-load-tbb-stub
Jul 23, 2026
Merged

load tbb stub library on windows again#249
kevinushey merged 2 commits into
masterfrom
bugfix/windows-load-tbb-stub

Conversation

@kevinushey

Copy link
Copy Markdown
Contributor

Problem

RcppParallel 6.0.0 (via #241) stopped loading any TBB library in .onLoad on Windows, on the grounds that TBB is statically linked there. However, we still ship a stub tbb.dll (see src/install.libs.R) for packages that link with -ltbb, e.g. via StanHeaders' LdFlags(). Those packages record a load-time dependency on tbb.dll in their DLL's import table, and the Windows loader can only resolve that against an already-loaded module -- RcppParallel's lib/x64 directory is not on the DLL search path (and -Wl,-rpath is a no-op in PE binaries).

As a result, with 6.0.0 on Windows, Stan-based packages fail their install-time load test with:

unable to load shared object '...WSPsignal/libs/x64/WSPsignal.dll':
  LoadLibrary failure:  The specified module could not be found.

Seen with e.g. WSPsignal on r-universe: https://github.com/r-universe/cran/actions/runs/30028540221/job/89334243681

Pre-built binaries that import tbb.dll (the original motivation for the stub, per the comment in src/install.libs.R) are affected the same way.

Verified against the r-universe RcppParallel_6.0.0.zip Windows binary: it ships only libs/x64/RcppParallel.dll (which exports the oneTBB r1 runtime symbols) and lib/x64/tbb.dll (the stub, self-contained), so -ltbb direct-links the stub and the resulting import can never resolve without a preload.

Fix

Restore the .onLoad preload of the stub on Windows. The stub is resolved directly via tbbRoot() rather than tbbLibraryPath(), since #241 repurposed the latter to report static library names on Windows.

Notes

RcppParallel 6.0.0 (via #241) stopped loading any TBB library in .onLoad
on Windows, on the grounds that TBB is statically linked there. However,
we still ship a stub tbb.dll (see src/install.libs.R) for packages that
link with '-ltbb', e.g. via StanHeaders' LdFlags(). Those packages record
a load-time dependency on 'tbb.dll' in their DLL's import table, and the
Windows loader can only resolve it against an already-loaded module --
RcppParallel's lib/x64 directory is not on the DLL search path.

As a result, with 6.0.0 on Windows, Stan-based packages fail to load with:

  LoadLibrary failure:  The specified module could not be found.

as seen with e.g. WSPsignal on r-universe:
https://github.com/r-universe/cran/actions/runs/30028540221/job/89334243681

Restore the preload, resolving the stub directly (tbbLibraryPath() now
reports static library names on Windows, so it cannot be used here).
@kevinushey
kevinushey merged commit 11ba91f into master Jul 23, 2026
5 checks passed
@kevinushey
kevinushey deleted the bugfix/windows-load-tbb-stub branch July 23, 2026 22:09
kevinushey added a commit that referenced this pull request Jul 23, 2026
The stub loader added in #249 resolved tbb.dll via tbbRoot(), which
prefers TBB_LIB when set -- and on Windows, configure always sets
TBB_LIB to the Rtools library directory, which contains only static
TBB libraries. As a result, the lookup silently failed and the stub
was never loaded.

Resolve against the package's own lib directory instead, which is
where install.libs.R places the stub.
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