Skip to content

Commit 1912736

Browse files
committed
load tbb stub library on windows again
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 fbaeabb commit 1912736

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
* When building the bundled copy of oneTBB, RcppParallel no longer searches
411
for hwloc, and so no longer tries to build the optional 'tbbbind' library.
512
This fixes build failures on machines where a static hwloc library is

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)