@@ -78,7 +78,7 @@ tbbLdFlags <- function() {
7878 tbbLib <- Sys.getenv(" TBB_LIB" , unset = NA )
7979 if (! is.na(tbbLib )) {
8080 fmt <- " -L%1$s -Wl,-rpath,%1$s -ltbb -ltbbmalloc"
81- return (sprintf(fmt , asBuildPath(tbbLib )))
81+ return (sprintf(fmt , shQuote( asBuildPath(tbbLib ) )))
8282 }
8383
8484 # on Windows and Solaris, we need to explicitly link
@@ -94,6 +94,12 @@ tbbLdFlags <- function() {
9494
9595}
9696
97+ tbbRoot <- function () {
98+ rArch <- .Platform $ r_arch
99+ libDir <- paste(c(" lib" , if (nzchar(rArch )) rArch ), collapse = " /" )
100+ system.file(libDir , package = " RcppParallel" )
101+ }
102+
97103# Determine the platform-specific path to the TBB library
98104tbbLibPath <- function (suffix = " " ) {
99105
@@ -106,36 +112,22 @@ tbbLibPath <- function(suffix = "") {
106112 " SunOS" = paste0(" libtbb" , suffix , " .so" ),
107113 " Linux" = paste0(" libtbb" , suffix , c(" .so" , " .so.2" ))
108114 )
109-
110- # shortcut if TBB_LIB is defined
111- tbbLib <- Sys.getenv(" TBB_LIB" , unset = NA )
112- if (! is.na(tbbLib )) {
113- libPaths <- file.path(tbbLib , tbbLibNames [[sysname ]])
114- for (libPath in libPaths )
115- if (file.exists(libPath ))
116- return (asBuildPath(libPath ))
117- }
118115
119- # otherwise, construct library path as appropriate for arch
116+ # skip systems that we know not to be compatible
120117 isCompatible <-
121118 ! is_sparc() &&
122119 ! is.null(tbbLibNames [[sysname ]])
123120
124121 if (! isCompatible )
125122 return (NULL )
126123
127- # construct library path
128- arch <- .Platform $ r_arch
129- components <- c(" lib" , if (nzchar(arch )) arch )
130- libDir <- paste(components , collapse = " /" )
131-
132- # form path to bundled tbb component
124+ # find root for TBB install
125+ tbbRoot <- Sys.getenv(" TBB_LIB" , unset = tbbRoot())
133126 libNames <- tbbLibNames [[sysname ]]
134127 for (libName in libNames ) {
135- tbbName <- file.path(libDir , libName )
136- tbbPath <- system.file(tbbName , package = " RcppParallel" )
137- if (file.exists(tbbPath ))
138- return (tbbPath )
128+ tbbName <- file.path(tbbRoot , libName )
129+ if (file.exists(tbbName ))
130+ return (tbbName )
139131 }
140132
141133}
0 commit comments