Skip to content

Commit

Permalink
support aarch64 on Windows
Browse files Browse the repository at this point in the history
Adapted from a patch shared by Tomas Kalibera.
  • Loading branch information
kevinushey committed Feb 21, 2024
1 parent 02b86ca commit 7fcf9da
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions R/tbb.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ tbbLdFlags <- function() {
return(sprintf(fmt, asBuildPath(tbbLib)))
}

# on Aarch64 builds, use the version of TBB provided by Rtools
if (is_windows() && R.version$arch == "aarch64")
return("-ltbb12 -ltbbmalloc")

# on Mac, Windows and Solaris, we need to explicitly link (#206)
needsExplicitFlags <- is_mac() || is_windows() || (is_solaris() && !is_sparc())
if (needsExplicitFlags) {
Expand Down
6 changes: 5 additions & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,12 @@ loadTbbLibrary <- function(name) {

.onLoad <- function(libname, pkgname) {

tbbLibraryName <- "tbb"
if (is_windows() && R.version$arch == "aarch64")
tbbLibraryName <- "tbb12"

# load tbb, tbbmalloc
.tbbDllInfo <<- loadTbbLibrary("tbb")
.tbbDllInfo <<- loadTbbLibrary(tbbLibraryName)
.tbbMallocDllInfo <<- loadTbbLibrary("tbbmalloc")

# load tbbmalloc_proxy, but only if requested
Expand Down
8 changes: 8 additions & 0 deletions src/Makevars.in
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ ifeq ($(USE_TBB), Windows)
# Linker needs access to the tbb dll; otherwise you get errors such as:
# "undefined reference to `tbb::task_scheduler_init::terminate()'"
PKG_LIBS += -Ltbb/build/lib_release -ltbb -ltbbmalloc

# override for aarch64 (experimental) to use Rtools TBB
ARCH=$(shell "${R_HOME}/bin/R" --vanilla -s -e 'cat(R.version$$arch)')
ifeq "$(ARCH)" "aarch64"
TBB_LIB = ${R_TOOLS_SOFT}
TBB_INC = ${R_TOOLS_SOFT}
PKG_LIBS = -ltbb12 -ltbbmalloc
endif

endif

Expand Down

0 comments on commit 7fcf9da

Please sign in to comment.