Skip to content

Commit 0b136ce

Browse files
committed
Revert "bundle old version of tbb for now"
This reverts commit 9d63bbb.
1 parent 9d63bbb commit 0b136ce

File tree

609 files changed

+189
-190086
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

609 files changed

+189
-190086
lines changed

R/aaa.R

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11

22
# stubs that get overridden via configure script
33
TBB_ENABLED <- TRUE
4-
TBB_STATIC <- FALSE
54
TBB_LIB <- ""
65
TBB_INC <- ""
76

R/tbb-autodetected.R.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11

22
TBB_ENABLED <- @TBB_ENABLED@
3-
TBB_STATIC <- @TBB_STATIC@
43
TBB_LIB <- "@TBB_LIB@"
54
TBB_INC <- "@TBB_INC@"
65

R/tbb.R

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,14 @@ tbbCxxFlags <- function() {
5757
if (!TBB_ENABLED)
5858
return("-DRCPP_PARALLEL_USE_TBB=0")
5959

60-
flags <- c(
61-
"-DRCPP_PARALLEL_USE_TBB=1",
62-
"-DTBB_INTERFACE_NEW"
63-
)
60+
flags <- c("-DRCPP_PARALLEL_USE_TBB=1")
6461

6562
# TBB does not have assembly code for Windows ARM64
6663
# so we need to use compiler builtins
67-
if (is_windows() && R.version$arch == "aarch64") {
68-
flags <- c(flags, "-DTBB_USE_GCC_BUILTINS")
64+
if (TBB_ENABLED && is_windows()) {
65+
if (R.version$arch == "aarch64") {
66+
flags <- c(flags, "-DTBB_USE_GCC_BUILTINS")
67+
}
6968
}
7069

7170
# if TBB_INC is set, apply those library paths
@@ -76,7 +75,16 @@ tbbCxxFlags <- function() {
7675

7776
# add include path
7877
if (nzchar(tbbInc) && file.exists(tbbInc)) {
78+
79+
# prefer new interface if version.h exists -- we keep this
80+
# for compatibility with packages like StanHeaders, rstan
81+
versionPath <- file.path(tbbInc, "tbb/version.h")
82+
if (file.exists(versionPath))
83+
flags <- c(flags, "-DTBB_INTERFACE_NEW")
84+
85+
# now add the include path
7986
flags <- c(flags, paste0("-I", asBuildPath(tbbInc)))
87+
8088
}
8189

8290
# return flags as string
@@ -87,14 +95,16 @@ tbbCxxFlags <- function() {
8795
# Return the linker flags required for TBB on this platform
8896
tbbLdFlags <- function() {
8997

90-
# handle static linking
91-
if (TBB_STATIC) {
98+
# on Windows, we statically link to oneTBB
99+
if (is_windows()) {
100+
92101
libPath <- system.file("libs", package = "RcppParallel")
93102
if (nzchar(.Platform$r_arch))
94103
libPath <- file.path(libPath, .Platform$r_arch)
95104

96105
ldFlags <- sprintf("-L%s -lRcppParallel", asBuildPath(libPath))
97106
return(ldFlags)
107+
98108
}
99109

100110
# shortcut if TBB_LIB defined

R/zzz.R

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,24 @@ loadTbbLibrary <- function(name) {
2727

2828
.onLoad <- function(libname, pkgname) {
2929

30-
if (TBB_STATIC) {
30+
# on Windows, load RcppParallel first
31+
if (.Platform$OS.type == "windows") {
3132
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname)
32-
return()
3333
}
3434

35+
# load tbb, tbbmalloc
3536
.tbbDllInfo <<- loadTbbLibrary("tbb")
3637
.tbbMallocDllInfo <<- loadTbbLibrary("tbbmalloc")
3738

39+
# load tbbmalloc_proxy, but only if requested
3840
useTbbMallocProxy <- Sys.getenv("RCPP_PARALLEL_USE_TBBMALLOC_PROXY", unset = "FALSE")
3941
if (useTbbMallocProxy %in% c("TRUE", "True", "true", "1"))
4042
.tbbMallocProxyDllInfo <<- loadTbbLibrary("tbbmalloc_proxy")
4143

42-
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname)
44+
# load RcppParallel library if available
45+
if (.Platform$OS.type != "windows") {
46+
.dllInfo <<- library.dynam("RcppParallel", pkgname, libname)
47+
}
4348

4449
}
4550

src/Makevars.in

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
CMAKE = @CMAKE@
33
R = @R@
44

5-
TBB_ENABLED = @TBB_ENABLED@
6-
TBB_STATIC = @TBB_STATIC@
7-
TBB_SRC = @TBB_SRC@
85
TBB_LIB = @TBB_LIB@
96
TBB_INC = @TBB_INC@
10-
117
TBB_NAME = @TBB_NAME@
128
TBB_MALLOC_NAME = @TBB_MALLOC_NAME@
139

1410
PKG_CPPFLAGS = @PKG_CPPFLAGS@
11+
PKG_CXXFLAGS = @PKG_CXXFLAGS@
1512

1613
PKG_LIBS = @PKG_LIBS@ @PKG_LIBS_EXTRA@
1714

@@ -24,23 +21,11 @@ $(OBJECTS): tbb
2421
# NOTE: TBB libraries are installed via install.libs.R.
2522
# However, we need to copy headers here so that they are visible during compilation.
2623
tbb: tbb-clean
27-
@ \
28-
TBB_ENABLED="$(TBB_ENABLED)" \
29-
TBB_STATIC="$(TBB_STATIC)" \
30-
TBB_SRC="$(TBB_SRC)" \
31-
TBB_LIB="$(TBB_LIB)" \
32-
TBB_INC="$(TBB_INC)" \
33-
TBB_NAME="$(TBB_NAME)" \
34-
TBB_MALLOC_NAME="$(TBB_MALLOC_NAME)" \
35-
CC="$(CC)" \
36-
CFLAGS="$(CFLAGS)" \
37-
CPPFLAGS="$(CPPFLAGS)" \
38-
CXX="$(CXX)" \
39-
CXXFLAGS="$(CXXFLAGS)" \
40-
CXXPICFLAGS="$(CXXPICFLAGS)" \
41-
LDFLAGS="$(LDFLAGS)" \
42-
CMAKE="$(CMAKE)" \
43-
"@R@" -s -f install.libs.R --args build
24+
@TBB_LIB="$(TBB_LIB)" TBB_INC="$(TBB_INC)" \
25+
TBB_NAME="$(TBB_NAME)" TBB_MALLOC_NAME="$(TBB_MALLOC_NAME)" \
26+
CC="$(CC)" CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" \
27+
CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" LDFLAGS="$(LDFLAGS)" \
28+
CMAKE="$(CMAKE)" "@R@" -s -f install.libs.R --args build
4429

4530
# NOTE: we do not want to clean ../inst/lib or ../inst/libs here,
4631
# as we may be writing to those locations in multiarch builds

src/install.libs.R

Lines changed: 3 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,6 @@ useBundledTbb <- function() {
105105
cmake <- Sys.getenv("CMAKE", unset = "cmake")
106106
buildType <- Sys.getenv("CMAKE_BUILD_TYPE", unset = "Release")
107107
verbose <- Sys.getenv("VERBOSE", unset = "0")
108-
109-
cxxFlags <- paste(Sys.getenv("CPPFLAGS", "CXXFLAGS", "CXXPICFLAGS"), collapse = " ")
110-
Sys.setenv(CXXFLAGS = cxxFlags)
111108

112109
cmakeFlags <- c(
113110
sprintf("-DCMAKE_BUILD_TYPE=%s", buildType),
@@ -162,90 +159,20 @@ useBundledTbb <- function() {
162159

163160
}
164161

165-
useOldBundledTbb <- function() {
166-
167-
useTbbPreamble("tbb-2019/include")
168-
owd <- setwd("tbb-2019/src")
169-
on.exit(setwd(owd), add = TRUE)
170-
171-
makeArgs <- "stdver=c++11"
172-
cxxFlags <- c(
173-
"-DTBB_NO_LEGACY=1",
174-
"-DTBB_SUPPRESS_DEPRECATED_MESSAGES=1",
175-
Sys.getenv(c("CPPFLAGS", "CXXFLAGS"))
176-
)
177-
178-
cxxFlags <- paste(cxxFlags, collapse = " ")
179-
Sys.setenv(
180-
CONLY = Sys.getenv("CC", unset = "cc"),
181-
CPLUS = Sys.getenv("CXX", unset = "c++"),
182-
CXXFLAGS = paste(cxxFlags, collapse = " "),
183-
PIC_KEY = Sys.getenv("CXXPICFLAGS", unset = "-fPIC"),
184-
WARNING_SUPPRESS = ""
185-
)
186-
187-
if (.Platform$OS.type == "windows") {
188-
189-
Sys.setenv(
190-
MSYS2_ARG_CONV_EXCL = "*",
191-
CYGWIN = "nodosfilewarning",
192-
WINARM64_CLANG = "$(WINARM64_CLANG)"
193-
)
194-
195-
makeArgs <- "rtools=true compiler=gcc runtime=mingw"
196-
197-
}
198-
199-
writeLines("** configuring tbb")
200-
system("make info")
201-
writeLines("")
202-
203-
writeLines("** building tbb")
204-
makeTargets <- c("tbb_build_prefix=lib", "tbb_release", "tbbmalloc_release")
205-
output <- system2("make", c("-e", makeArgs, makeTargets), stdout = TRUE, stderr = TRUE)
206-
status <- attr(output, "status")
207-
if (!is.null(status) && status != 0) {
208-
writeLines(output, con = stderr())
209-
stop("error building tbb")
210-
}
211-
212-
shlibPattern <- switch(
213-
Sys.info()[["sysname"]],
214-
Windows = "^tbb.*\\.dll$",
215-
Darwin = "^libtbb.*\\.dylib$",
216-
"^libtbb.*\\.so.*$"
217-
)
218-
219-
setwd(owd)
220-
tbbFiles <- list.files(
221-
file.path(getwd(), "tbb-2019/build/lib_release"),
222-
pattern = shlibPattern,
223-
recursive = TRUE,
224-
full.names = TRUE
225-
)
226-
227-
dir.create("tbb/build/lib_release", recursive = TRUE, showWarnings = FALSE)
228-
file.copy(tbbFiles, "tbb/build/lib_release", overwrite = TRUE)
229-
unlink("tbb/build-tbb", recursive = TRUE)
230-
writeLines("** finished building tbb")
231-
232-
}
233-
234162

235163
# Main ----
236164

237-
tbbSrc <- Sys.getenv("TBB_SRC")
238165
tbbLib <- Sys.getenv("TBB_LIB")
239166
tbbInc <- Sys.getenv("TBB_INC")
240167

241168
args <- commandArgs(trailingOnly = TRUE)
242169
if (identical(args, "build")) {
243170
if (nzchar(tbbLib) && nzchar(tbbInc)) {
244171
useSystemTbb(tbbLib, tbbInc)
245-
} else if (tbbSrc == "tbb") {
172+
} else if (.Platform$OS.type == "windows") {
173+
writeLines("** building RcppParallel without tbb backend")
174+
} else {
246175
useBundledTbb()
247-
} else if (tbbSrc == "tbb-2019") {
248-
useOldBundledTbb()
249176
}
250177
} else {
251178
source("../R/tbb-autodetected.R")

0 commit comments

Comments
 (0)