From 7f1332d4155431875a3352508ac9cfc6cc4be5e3 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 3 Sep 2023 10:42:30 +0000 Subject: [PATCH 1/3] add flags for mac cross compile --- .../cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake | 2 ++ .../cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake | 2 ++ 2 files changed, 4 insertions(+) diff --git a/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake b/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake index a3b8d52fa72..8899c4b1c00 100644 --- a/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake @@ -1,2 +1,4 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR aarch64) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") \ No newline at end of file diff --git a/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake b/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake index 0aa93407fbd..128ab8fb814 100644 --- a/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake @@ -1,2 +1,4 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR x86_64) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") \ No newline at end of file From af5908943b5ad9bdffd909a1b9ee6549bbc5e974 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 3 Sep 2023 18:17:26 +0000 Subject: [PATCH 2/3] set flags only for clang --- .../cpp/cmake/toolchains/aarch64-darwin.cmake | 11 +++++++++-- .../cpp/cmake/toolchains/x86_64-darwin.cmake | 11 +++++++++-- circuits/cpp/cmake/toolchains/aarch64-darwin.cmake | 11 +++++++++-- circuits/cpp/cmake/toolchains/x86_64-darwin.cmake | 11 +++++++++-- 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake b/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake index 8899c4b1c00..20bd1ee2d0a 100644 --- a/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake @@ -1,4 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR aarch64) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") \ No newline at end of file + +if(CMAKE_CXX_COMPILER_ID STREQUAL "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/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake b/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake index 128ab8fb814..ef2236dae42 100644 --- a/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake @@ -1,4 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR x86_64) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") \ No newline at end of file + +if(CMAKE_CXX_COMPILER_ID STREQUAL "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() diff --git a/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake b/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake index 8899c4b1c00..8e5f3963e97 100644 --- a/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake @@ -1,4 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR aarch64) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch arm64") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch arm64") \ No newline at end of file + +if(CMAKE_CXX_COMPILER_ID STREQUAL "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() diff --git a/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake b/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake index 535814275ba..ef2236dae42 100644 --- a/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake @@ -1,4 +1,11 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR x86_64) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -arch x86_64") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64") + +if(CMAKE_CXX_COMPILER_ID STREQUAL "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() From 3ada49f5fec622dc6b64076345c91ddba4181f0f Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 3 Sep 2023 18:25:14 +0000 Subject: [PATCH 3/3] use matches to match both llvm and apple clang --- .../cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake | 2 +- .../cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake | 2 +- circuits/cpp/cmake/toolchains/aarch64-darwin.cmake | 2 +- circuits/cpp/cmake/toolchains/x86_64-darwin.cmake | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake b/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake index 20bd1ee2d0a..5cf78980483 100644 --- a/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/circuits/cpp/barretenberg/cpp/cmake/toolchains/aarch64-darwin.cmake @@ -1,7 +1,7 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR aarch64) -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +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 diff --git a/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake b/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake index ef2236dae42..47b58dcc854 100644 --- a/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/circuits/cpp/barretenberg/cpp/cmake/toolchains/x86_64-darwin.cmake @@ -1,7 +1,7 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR x86_64) -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +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 diff --git a/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake b/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake index 8e5f3963e97..227680938b4 100644 --- a/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake @@ -1,7 +1,7 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR aarch64) -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +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 diff --git a/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake b/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake index ef2236dae42..47b58dcc854 100644 --- a/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake @@ -1,7 +1,7 @@ set(CMAKE_SYSTEM_NAME Darwin) set(CMAKE_SYSTEM_PROCESSOR x86_64) -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +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