@@ -21,16 +21,28 @@ ifeq ($(OS), Windows_NT)
2121 USE_TBB=Windows
2222 TBB_COPY_PATTERN=tbb*.dll
2323
24+ ARCH=$(shell "${R_HOME}/bin/R" --vanilla -s -e 'cat(R.version$$arch)')
25+ TBB_CXXFLAGS = @CXX11FLAGS@ -DTBB_NO_LEGACY=1
26+ ifeq "$(ARCH)" "aarch64"
27+ PKG_CPPFLAGS += -DTBB_USE_GCC_BUILTINS
28+ TBB_CXXFLAGS += -DTBB_USE_GCC_BUILTINS
29+ CLANG_CHECK := $(shell echo | $(CC) -E -dM - | findstr __clang__)
30+ ifneq ($(CLANG_CHECK), )
31+ WINARM64_CLANG=true
32+ endif
33+ endif
34+
2435 MAKE = make
2536 MAKEFLAGS = -e -j1
2637 MAKE_CMD = \
2738 MSYS2_ARG_CONV_EXCL="*" \
2839 CYGWIN=nodosfilewarning \
2940 CONLY="@WINDOWS_CC@" \
3041 CPLUS="@WINDOWS_CXX11@" \
31- CXXFLAGS="@CXX11FLAGS@ -DTBB_NO_LEGACY=1" \
42+ CXXFLAGS="$(TBB_CXXFLAGS)" \
3243 PIC_KEY="@CXX11PICFLAGS@" \
3344 WARNING_SUPPRESS="" \
45+ WINARM64_CLANG="$(WINARM64_CLANG)" \
3446 $(MAKE)
3547
3648else
@@ -77,26 +89,21 @@ ifeq ($(USE_TBB), Windows)
7789 # rtools: turn on hacks to compensate for make and shell differences rtools<=>MinGW
7890 # compiler: overwrite default (which is cl = MS compiler)
7991 MAKE_ARGS += rtools=true compiler=gcc
80- ifeq ($(WIN), 64)
81- MAKE_ARGS += arch=intel64 runtime=mingw
82- ARCH_DIR=x64/
83- else
84- MAKE_ARGS += arch=ia32 runtime=mingw
85- ARCH_DIR=i386/
92+ # TBB configure will detect mingw runtime with unknown arch on WINARM64_CLANG but not an
93+ # issue as we are using compiler built-ins instead of arch-specific code
94+ ifneq ($(WINARM64_CLANG), true)
95+ ifeq ($(WIN), 64)
96+ MAKE_ARGS += arch=intel64 runtime=mingw
97+ ARCH_DIR=x64/
98+ else
99+ MAKE_ARGS += arch=ia32 runtime=mingw
100+ ARCH_DIR=i386/
101+ endif
86102 endif
87103
88104 # Linker needs access to the tbb dll; otherwise you get errors such as:
89105 # "undefined reference to `tbb::task_scheduler_init::terminate()'"
90106 PKG_LIBS += -Ltbb/build/lib_release -ltbb -ltbbmalloc
91-
92- # override for aarch64 (experimental) to use Rtools TBB
93- ARCH=$(shell "${R_HOME}/bin/R" --vanilla -s -e 'cat(R.version$$arch)')
94- ifeq "$(ARCH)" "aarch64"
95- TBB_LIB = ${R_TOOLS_SOFT}
96- TBB_INC = ${R_TOOLS_SOFT}
97- PKG_LIBS = -ltbb12 -ltbbmalloc
98- endif
99-
100107endif
101108
102109# write compiler if set
0 commit comments