@@ -46,35 +46,37 @@ tbbLibraryPath <- function(name = NULL) {
4646
4747tbbCxxFlags <- function () {
4848
49- flags <- character ()
49+ if (! TBB_ENABLED )
50+ return (" -DRCPP_PARALLEL_USE_TBB=0" )
5051
51- # opt-in to TBB on Windows
52- if (is_windows()) {
53- enabled <- if (TBB_ENABLED ) " 1" else " 0"
54- flags <- c(flags , sprintf(" -DRCPP_PARALLEL_USE_TBB=%s" , enabled ))
52+ flags <- c(" -DRCPP_PARALLEL_USE_TBB=1" )
53+
54+ # TBB does not have assembly code for Windows ARM64
55+ # so we need to use compiler builtins
56+ if (TBB_ENABLED && is_windows()) {
5557 if (R.version $ arch == " aarch64" ) {
56- # TBB does not have assembly code for Windows ARM64
57- # so we need to use compiler builtins
5858 flags <- c(flags , " -DTBB_USE_GCC_BUILTINS" )
5959 }
6060 }
6161
6262 # if TBB_INC is set, apply those library paths
6363 tbbInc <- Sys.getenv(" TBB_INC" , unset = TBB_INC )
6464 if (! file.exists(tbbInc )) {
65- tbbInc <- system.file(" include" , package = " Rcpp " )
65+ tbbInc <- system.file(" include" , package = " RcppParallel " )
6666 }
6767
68- if (nzchar(tbbInc )) {
69-
70- # add include path
71- flags <- c(flags , paste0(" -I" , asBuildPath(tbbInc )))
68+ # add include path
69+ if (nzchar(tbbInc ) && file.exists(tbbInc )) {
7270
73- # prefer new interface if version.h exists
71+ # prefer new interface if version.h exists -- we keep this
72+ # for compatibility with packages like StanHeaders, rstan
7473 versionPath <- file.path(tbbInc , " tbb/version.h" )
7574 if (file.exists(versionPath ))
7675 flags <- c(flags , " -DTBB_INTERFACE_NEW" )
7776
77+ # now add the include path
78+ flags <- c(flags , paste0(" -I" , asBuildPath(tbbInc )))
79+
7880 }
7981
8082 # return flags as string
0 commit comments