diff --git a/NEWS.md b/NEWS.md index 600139ab..4bcdac2f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,12 @@ # RcppParallel (development version) +* On Windows, RcppParallel once again loads its compatibility stub library + (`tbb.dll`) when the package is loaded. Packages linking with `-ltbb` + (e.g. via StanHeaders) record a load-time dependency on `tbb.dll`, which + can only be resolved if RcppParallel has already loaded it; with + RcppParallel 6.0.0, such packages would fail to load with "LoadLibrary + failure: The specified module could not be found". + * The bundled oneTBB headers now guard against GCC's `` being included before `` on Windows (mingw). Previously, translation units including `` before any TBB header would fail to compile, diff --git a/R/zzz.R b/R/zzz.R index 54374e09..9637367a 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -11,10 +11,23 @@ .tbbMallocProxyDllInfo <- NULL loadTbbLibrary <- function(name) { - # TBB is statically linked on Windows + + # On Windows, TBB is statically linked into RcppParallel.dll, but we + # still ship a stub tbb.dll for compatibility with packages linking via + # '-ltbb' (e.g. through StanHeaders). Such packages record a load-time + # dependency on 'tbb.dll', which the Windows loader can only resolve if + # we've already loaded it -- the library directory itself is not on the + # DLL search path. if (is_windows()) { - return(NULL) + + path <- file.path(tbbRoot(), paste0(name, ".dll")) + if (!file.exists(path)) + return(NULL) + + return(dyn.load(path, local = FALSE, now = TRUE)) + } + path <- tbbLibraryPath(name) if (is.null(path)) return(NULL)