From aae4ee30bd2e18dad73ec3fe0335fba5a4efc00e Mon Sep 17 00:00:00 2001 From: Kevin Ushey Date: Thu, 23 Jul 2026 16:24:26 -0700 Subject: [PATCH] fix installation on windows without an rtools tbb On Windows systems whose Rtools does not provide TBB (R < 4.2.0), two code paths broke the install: - configure required cmake whenever TBB_LIB was empty, but the bundled TBB is never built on Windows; skip the cmake requirement there - the tbb stub library was built unconditionally on Windows, but tbb-compat.cpp references tbb::detail::r1::observe, which nothing provides when TBB is disabled, so the link (and thus the install) failed; the stub is also useless in that configuration, as RcppParallel.dll exports no TBB symbols for old binaries to bind --- NEWS.md | 4 ++++ src/install.libs.R | 7 +++++-- tools/config/configure.R | 4 +++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 536b3d0f..239f62cb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # RcppParallel (development version) +* Fixed installation on Windows systems whose Rtools does not provide TBB + (R < 4.2.0): configure no longer requires cmake there, and the tbb stub + library is no longer built when the TBB backend is disabled. + * RcppParallel now reports which TBB headers and libraries are installed with the package, and from where, during package installation. In addition, setting the `VERBOSE` environment variable to a value other diff --git a/src/install.libs.R b/src/install.libs.R index 48ce73be..67287413 100644 --- a/src/install.libs.R +++ b/src/install.libs.R @@ -76,8 +76,11 @@ } # on Windows, we create a stub library that links to us so that - # older binaries (like rstan) can still load - if (.Platform$OS.type == "windows") { + # older binaries (like rstan) can still load. this is only relevant + # when TBB is available: the stub cannot link without it, and old + # TBB-using binaries could not run against a TBB-less RcppParallel + # regardless + if (.Platform$OS.type == "windows" && TBB_ENABLED) { tbbDll <- file.path(tbbDest, "tbb.dll") if (file.exists(tbbDll)) { writeLines("** tbb.dll already exists; skipping tbb stub library") diff --git a/tools/config/configure.R b/tools/config/configure.R index a001e63b..544b39ad 100644 --- a/tools/config/configure.R +++ b/tools/config/configure.R @@ -267,8 +267,10 @@ if (.Platform$OS.type == "windows") { define(PKG_LIBS = paste(pkgLibs, collapse = " ")) # if we're going to build tbb from sources, check for cmake +# (not required on Windows, where the bundled TBB is never built; +# without an Rtools TBB, the tinythread fallback is used instead) define(CMAKE = "") -if (is.na(tbbLib)) { +if (is.na(tbbLib) && .Platform$OS.type != "windows") { cmake <- local({