Skip to content

Commit 53103ab

Browse files
committed
refine resolution of TBB root
1 parent c4adc01 commit 53103ab

File tree

2 files changed

+14
-28
lines changed

2 files changed

+14
-28
lines changed

R/build.R

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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
98104
tbbLibPath <- 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
}

src/Makevars.in

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,13 +125,7 @@ else
125125
rm -Rf ../inst/include/tbb_local/; \
126126
cp -R tbb/include/* ../inst/include/; \
127127
cd tbb/src; \
128-
if [ -n "$(shell echo $(CC) | grep clang)" ]; then \
129-
$(MAKE_CMD) stdver=@STDVER@ compiler=clang $(MAKE_ARGS); \
130-
elif [ -n "$(shell echo $(CC) | grep gcc)" ]; then \
131-
$(MAKE_CMD) stdver=@STDVER@ compiler=gcc $(MAKE_ARGS); \
132-
else \
133-
$(MAKE_CMD) stdver=@STDVER@ $(MAKE_ARGS); \
134-
fi; \
128+
$(MAKE_CMD) stdver=@STDVER@ $(MAKE_ARGS); \
135129
cd ../..; \
136130
mkdir -p ../inst/lib/$(ARCH_DIR); \
137131
cp tbb/build/lib_release/$(TBB_COPY_PATTERN) ../inst/lib/$(ARCH_DIR)

0 commit comments

Comments
 (0)