Skip to content

Commit

Permalink
[bug] Force CMAKE_OSX_ARCHITECTURES in sync with host processor's arc…
Browse files Browse the repository at this point in the history
…hitecture to avoid ABI issues on Mac m1 (taichi-dev#5952)
  • Loading branch information
jim19930609 authored Sep 2, 2022
1 parent 4bfb569 commit bf1fc7d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ cmake_minimum_required(VERSION 3.17)

project(taichi)

# Taichi does not set target architecture explicitly,
# but rather rely on CMake to detect the host arch.
#
# However on Mac m1, there are two available architectures namely x86_64 and arm64.
# On some combination of "OSX version" and "CMake version", CMake will use x86_64 as default architecture even if it's on m1 chip.
# This causes conflicts with the precompiled LLVM/Clang binaries downloaded from Taichi's repo (pre-built for arm64)
#
# Therefore we force CMake to choose arm64 architecture on arm64 chips.
if (APPLE)
if( "${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "arm64" )
set(CMAKE_OSX_ARCHITECTURES ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()
endif()

if (NOT DEFINED TI_VERSION_MAJOR)
message(WARNING "It seems that you are running cmake manually, which may cause issues. Please use setup.py to build taichi from source, see https://docs.taichi-lang.org/docs/dev_install for more details.")
set(TI_VERSION_MAJOR 0)
Expand Down

0 comments on commit bf1fc7d

Please sign in to comment.