From 0e17d978a0cc6805b72646a8e36fd5267cbd6bcd Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 3 Sep 2023 22:21:19 +0100 Subject: [PATCH] fix: Adds Mac cross compile flags into barretenberg (#1954) When fixing https://github.com/AztecProtocol/aztec-packages/issues/1841 the flags were put in the cmake toolchains file for circuits which does not get inherited by the barretenberg toolchain files. --- cpp/cmake/toolchains/aarch64-darwin.cmake | 9 +++++++++ cpp/cmake/toolchains/x86_64-darwin.cmake | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/cpp/cmake/toolchains/aarch64-darwin.cmake b/cpp/cmake/toolchains/aarch64-darwin.cmake index a3b8d52fa7..5cf7898048 100644 --- a/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/cpp/cmake/toolchains/aarch64-darwin.cmake @@ -1,2 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR aarch64) + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang allows us to cross compile on Mac + # so we explicitly specify the arch to the compiler + # If you just select the arch toolchain and are on an + # x86_64, it will compile for x86_64 mac. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") +endif() \ No newline at end of file diff --git a/cpp/cmake/toolchains/x86_64-darwin.cmake b/cpp/cmake/toolchains/x86_64-darwin.cmake index 0aa93407fb..47b58dcc85 100644 --- a/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/cpp/cmake/toolchains/x86_64-darwin.cmake @@ -1,2 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR x86_64) + +if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang allows us to cross compile on Mac + # so we explicitly specify the arch to the compiler + # If you just select the x86_64 toolchain and are on an + # M1/arm64 mac, it will compile for arm64. + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") +endif()