Skip to content

Commit

Permalink
[cmake] Patch tbb for Apple M1 (issue root-project#6903).
Browse files Browse the repository at this point in the history
Apply patch from uxlfoundation/oneTBB#258
  • Loading branch information
Axel-Naumann committed Jan 12, 2021
1 parent d368ae0 commit 15f3ad2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
32 changes: 32 additions & 0 deletions builtins/tbb/patches/apple-m1.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
From 86f6dcdc17a8f5ef2382faaef860cfa5243984fe Mon Sep 17 00:00:00 2001
From: Yining Karl Li <betajippity@gmail.com>
Date: Fri, 3 Jul 2020 06:23:18 -0700
Subject: [PATCH] Add detection of arm64 architecture for macos builds

This commit adds detection of arm64 for macos builds on arm64 hardware.
The only change necessary is an additional case in the code where
macos.inc queries and detects the system architecture.
---
build/macos.inc | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/build/macos.inc b/build/macos.inc
index dde93216..2bdcde7e 100644
--- a/build/macos.inc
+++ b/build/macos.inc
@@ -36,11 +36,15 @@ ifndef arch
export arch:=ppc32
endif
else
+ ifeq ($(shell /usr/sbin/sysctl -n hw.machine),arm64)
+ export arch:=arm64
+ else
ifeq ($(shell /usr/sbin/sysctl -n hw.optional.x86_64 2>/dev/null),1)
export arch:=intel64
else
export arch:=ia32
endif
+ endif
endif
endif

6 changes: 6 additions & 0 deletions cmake/modules/SearchInstalledSoftware.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1214,6 +1214,11 @@ if(builtin_tbb)
elseif(CMAKE_CXX_COMPILER_ID STREQUAL GNU)
set(_tbb_compiler compiler=gcc)
endif()
if(${ROOT_ARCHITECTURE} MATCHES "macosxarm64")
set(tbb_command "patch -p1 -i ${CMAKE_SOURCE_DIR}/builtins/tbb/patches/apple-m1.patch")
else()
set(tbb_command "")
endif()
if(MSVC)
set(vsdir "vs2013")
set(TBB_LIBRARIES ${CMAKE_BINARY_DIR}/lib/tbb.lib)
Expand Down Expand Up @@ -1256,6 +1261,7 @@ if(builtin_tbb)
URL_HASH SHA256=${tbb_sha256}
INSTALL_DIR ${CMAKE_BINARY_DIR}
PATCH_COMMAND sed -i -e "/clang -v/s@-v@--version@" build/macos.inc
COMMAND ${tbb_command}
CONFIGURE_COMMAND ""
BUILD_COMMAND make ${_tbb_compiler} cpp0x=1 "CXXFLAGS=${_tbb_cxxflags}" CPLUS=${CMAKE_CXX_COMPILER} CONLY=${CMAKE_C_COMPILER} "LDFLAGS=${_tbb_ldflags}"
INSTALL_COMMAND ${CMAKE_COMMAND} -Dinstall_dir=<INSTALL_DIR> -Dsource_dir=<SOURCE_DIR>
Expand Down

0 comments on commit 15f3ad2

Please sign in to comment.