Skip to content

Commit a5ac14b

Browse files
temp fix for mac M1 compile issues
1 parent 38c8b72 commit a5ac14b

File tree

5 files changed

+35
-4
lines changed

5 files changed

+35
-4
lines changed

barretenberg/CMakeLists.txt

+8-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ option(MULTITHREADING "Enable multi-threading" ON)
1616
option(TESTING "Build tests" ON)
1717
option(BENCHMARKS "Build benchmarks" ON)
1818
option(PROFILING "Build profiling" ON)
19+
option(APPLE_M1 "Compile for Apple M1 CPUs" OFF)
20+
21+
if(APPLE_M1)
22+
set(MULTITHREADING OFF)
23+
set(DISABLE_ASM ON)
24+
set(DISABLE_ADX ON)
25+
add_definitions(-DNDEBUG)
26+
endif()
1927

2028
if(ARM)
2129
message(STATUS "Compiling for ARM.")
@@ -43,7 +51,6 @@ include(cmake/arch.cmake)
4351
include(cmake/threading.cmake)
4452
include(cmake/gtest.cmake)
4553
include(cmake/benchmark.cmake)
46-
include(cmake/build.cmake)
4754
include(cmake/module.cmake)
4855

4956
add_subdirectory(src/aztec)

barretenberg/README.md

+8
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ Just run the bootstrap script.
4040
./bootstrap.sh
4141
```
4242

43+
N.B. FOR M1 MACS RUN THE FOLLOWING:
44+
45+
```
46+
./bootstrap.sh APPLE_M1
47+
```
48+
49+
The current build for M1 macs disables multithreading, which will affect performance.
50+
4351
### Parallelise the build
4452

4553
Make sure your MAKEFLAGS environment variable is set to run jobs equal to number of cores. e.g. `MAKEFLAGS=-j32`.

barretenberg/bootstrap.sh

+10
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,21 @@ if [ ! -d ./srs_db/ignition ]; then
1616
cd ..
1717
fi
1818

19+
appleM1="APPLE_M1"
20+
input=${1:foo}
21+
1922
# Build native.
23+
if [ "$input" == "$appleM1" ]; then
24+
mkdir -p build && cd build
25+
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .. -DAPPLE_M1=1
26+
cmake --build . --parallel
27+
cd ..
28+
else
2029
mkdir -p build && cd build
2130
cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ ..
2231
cmake --build . --parallel
2332
cd ..
33+
fi
2434

2535
# Install the webassembly toolchain and patch runtime.
2636
if [ ! -d ./src/wasi-sdk-12.0 ]; then

barretenberg/cmake/arch.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ if(WASM)
55
add_compile_options(-fno-exceptions -fno-slp-vectorize)
66
endif()
77

8-
if(NOT WASM)
8+
if(NOT WASM AND NOT APPLE_M1)
99
add_compile_options(-march=native)
1010
endif()
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
1-
set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++")
2-
set(CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang")
1+
if(APPLE_M1)
2+
set(CMAKE_CXX_COMPILER "/opt/homebrew/opt/llvm/bin/clang++")
3+
set(CMAKE_C_COMPILER "/opt/homebrew/opt/llvm/bin/clang")
4+
set(DISABLE_ASM ON)
5+
else()
6+
set(CMAKE_CXX_COMPILER "/usr/local/opt/llvm/bin/clang++")
7+
set(CMAKE_C_COMPILER "/usr/local/opt/llvm/bin/clang")
8+
endif()

0 commit comments

Comments
 (0)