Skip to content

Commit 11ba91f

Browse files
authored
load tbb stub library on windows again (#249)
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).
1 parent 4426b8c commit 11ba91f

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

NEWS.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# RcppParallel (development version)
22

3+
* On Windows, RcppParallel once again loads its compatibility stub library
4+
(`tbb.dll`) when the package is loaded. Packages linking with `-ltbb`
5+
(e.g. via StanHeaders) record a load-time dependency on `tbb.dll`, which
6+
can only be resolved if RcppParallel has already loaded it; with
7+
RcppParallel 6.0.0, such packages would fail to load with "LoadLibrary
8+
failure: The specified module could not be found".
9+
310
* The bundled oneTBB headers now guard against GCC's `<cpuid.h>` being
411
included before `<intrin.h>` on Windows (mingw). Previously, translation
512
units including `<cpuid.h>` before any TBB header would fail to compile,

R/zzz.R

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,23 @@
1111
.tbbMallocProxyDllInfo <- NULL
1212

1313
loadTbbLibrary <- function(name) {
14-
# TBB is statically linked on Windows
14+
15+
# On Windows, TBB is statically linked into RcppParallel.dll, but we
16+
# still ship a stub tbb.dll for compatibility with packages linking via
17+
# '-ltbb' (e.g. through StanHeaders). Such packages record a load-time
18+
# dependency on 'tbb.dll', which the Windows loader can only resolve if
19+
# we've already loaded it -- the library directory itself is not on the
20+
# DLL search path.
1521
if (is_windows()) {
16-
return(NULL)
22+
23+
path <- file.path(tbbRoot(), paste0(name, ".dll"))
24+
if (!file.exists(path))
25+
return(NULL)
26+
27+
return(dyn.load(path, local = FALSE, now = TRUE))
28+
1729
}
30+
1831
path <- tbbLibraryPath(name)
1932
if (is.null(path))
2033
return(NULL)

0 commit comments

Comments
 (0)