From 27a4f6e20002705cc9c4101b0564c2ab83f3a3af Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 26 Aug 2023 19:57:36 +0000 Subject: [PATCH 1/8] add mac arm build --- .../.github/workflows/publish.yml | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/circuits/cpp/barretenberg/.github/workflows/publish.yml b/circuits/cpp/barretenberg/.github/workflows/publish.yml index 28062a1b00f..1604e117170 100644 --- a/circuits/cpp/barretenberg/.github/workflows/publish.yml +++ b/circuits/cpp/barretenberg/.github/workflows/publish.yml @@ -98,43 +98,45 @@ jobs: bb-ubuntu.tar.gz build-mac: - name: Build on Mac + name: Build on Mac (${{ matrix.target }}) runs-on: macos-13 + strategy: + matrix: + target: [x86_64-apple-darwin, aarch64-apple-darwin] steps: - name: Checkout uses: actions/checkout@v3 with: ref: ${{ inputs.tag || env.GITHUB_REF }} - - # We need clang 14.0.3 or higher, as lower versions do not seem - # to be spec conformant. In particular std::span does not seem - # to follow the specifications. + # We need clang 14.0.3 or higher, as lower versions do not seem + # to be spec conformant. In particular std::span does not seem + # to follow the specifications. + # We need clang 15 because barretenberg uses concepts. + # clang 15 is the similar to Apple clang 14. - name: Select Xcode version - run: | - sudo xcode-select -switch /Applications/Xcode_14.3.1.app + run: sudo xcode-select -switch /Applications/Xcode_14.3.1.app - name: Create Mac Build Environment - run: | - brew install cmake ninja + run: brew install cmake ninja - name: Compile Barretenberg working-directory: cpp run: | cmake --preset default -DCMAKE_BUILD_TYPE=RelWithAssert cmake --build --preset default --target bb - + - name: Package barretenberg artifact working-directory: cpp/build/bin run: | mkdir dist cp ./bb ./dist/bb - 7z a -ttar -so -an ./dist/* | 7z a -si ./barretenberg-x86_64-apple-darwin.tar.gz + 7z a -ttar -so -an ./dist/* | 7z a -si ./barretenberg-${{ matrix.target }}.tar.gz - name: Upload artifact uses: actions/upload-artifact@v3 with: - name: barretenberg-x86_64-apple-darwin - path: ./cpp/build/bin/barretenberg-x86_64-apple-darwin.tar.gz + name: barretenberg-${{ matrix.target }} + path: ./cpp/build/bin/barretenberg-${{ matrix.target }}.tar.gz retention-days: 3 release: @@ -147,11 +149,16 @@ jobs: with: name: release-linux-wasm - - name: Download files from Mac Runner + - name: Download files from x86_64 Mac Runner uses: actions/download-artifact@v2 with: name: barretenberg-x86_64-apple-darwin + - name: Download files from aarch64 Mac Runner + uses: actions/download-artifact@v2 + with: + name: barretenberg-aarch64-apple-darwin + - name: Publish to GitHub uses: softprops/action-gh-release@v1 if: ${{ inputs.publish || github.event_name == 'schedule' }} @@ -162,3 +169,4 @@ jobs: barretenberg.wasm.tar.gz bb-ubuntu.tar.gz barretenberg-x86_64-apple-darwin.tar.gz + barretenberg-aarch64-apple-darwin.tar.gz From 678ee7b2ed2a8c4d3c203fb9c8b415c8c337dff5 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 26 Aug 2023 20:19:11 +0000 Subject: [PATCH 2/8] rename linux binary to be named properly --- circuits/cpp/barretenberg/.github/workflows/publish.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/circuits/cpp/barretenberg/.github/workflows/publish.yml b/circuits/cpp/barretenberg/.github/workflows/publish.yml index 1604e117170..d4deae6327a 100644 --- a/circuits/cpp/barretenberg/.github/workflows/publish.yml +++ b/circuits/cpp/barretenberg/.github/workflows/publish.yml @@ -87,7 +87,7 @@ jobs: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - name: Tar and GZip bb Binary (Ubuntu) - run: tar -cvzf bb-ubuntu.tar.gz cpp/build/bin/bb + run: tar -cvzf barretenberg-x86_64-linux-gnu.tar.gz cpp/build/bin/bb - name: Upload artifacts uses: actions/upload-artifact@v2 @@ -95,7 +95,7 @@ jobs: name: release-linux-wasm path: | barretenberg.wasm.tar.gz - bb-ubuntu.tar.gz + barretenberg-x86_64-linux-gnu.tar.gz build-mac: name: Build on Mac (${{ matrix.target }}) @@ -167,6 +167,6 @@ jobs: prerelease: true files: | barretenberg.wasm.tar.gz - bb-ubuntu.tar.gz + barretenberg-x86_64-linux-gnu.tar.gz barretenberg-x86_64-apple-darwin.tar.gz barretenberg-aarch64-apple-darwin.tar.gz From b406cc99b46d116e959ba88c5b81a920b72e1308 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sat, 26 Aug 2023 20:25:17 +0000 Subject: [PATCH 3/8] remove directory structure from tar artifact --- .../cpp/barretenberg/.github/workflows/publish.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/circuits/cpp/barretenberg/.github/workflows/publish.yml b/circuits/cpp/barretenberg/.github/workflows/publish.yml index d4deae6327a..71f690c9026 100644 --- a/circuits/cpp/barretenberg/.github/workflows/publish.yml +++ b/circuits/cpp/barretenberg/.github/workflows/publish.yml @@ -71,7 +71,8 @@ jobs: yarn install && yarn && yarn build - name: Tar and GZip barretenberg.wasm - run: tar -cvzf barretenberg.wasm.tar.gz cpp/build-wasm/bin/barretenberg.wasm + working-directory: cpp/build-wasm/bin + run: tar -cvzf barretenberg.wasm.tar.gz barretenberg.wasm - name: Setup Node.js uses: actions/setup-node@v2 @@ -87,15 +88,16 @@ jobs: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - name: Tar and GZip bb Binary (Ubuntu) - run: tar -cvzf barretenberg-x86_64-linux-gnu.tar.gz cpp/build/bin/bb + working-directory: cpp/build/bin + run: tar -cvzf barretenberg-x86_64-linux-gnu.tar.gz bb - name: Upload artifacts uses: actions/upload-artifact@v2 with: name: release-linux-wasm path: | - barretenberg.wasm.tar.gz - barretenberg-x86_64-linux-gnu.tar.gz + ./cpp/build-wasm/bin/barretenberg.wasm + ./cpp/build/bin/barretenberg-x86_64-linux-gnu.tar.gz build-mac: name: Build on Mac (${{ matrix.target }}) From f3bf09adfd99fe7bd1563a78285a9fe2d526c335 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 27 Aug 2023 12:47:28 +0100 Subject: [PATCH 4/8] publish .tar.gz not raw wasm --- circuits/cpp/barretenberg/.github/workflows/publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/circuits/cpp/barretenberg/.github/workflows/publish.yml b/circuits/cpp/barretenberg/.github/workflows/publish.yml index 71f690c9026..eac68c0b759 100644 --- a/circuits/cpp/barretenberg/.github/workflows/publish.yml +++ b/circuits/cpp/barretenberg/.github/workflows/publish.yml @@ -96,7 +96,7 @@ jobs: with: name: release-linux-wasm path: | - ./cpp/build-wasm/bin/barretenberg.wasm + ./cpp/build-wasm/bin/barretenberg.wasm.tar.gz ./cpp/build/bin/barretenberg-x86_64-linux-gnu.tar.gz build-mac: From 8a9c85482c454971ff9a42ddcd8f8941c0d45a91 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Sun, 27 Aug 2023 13:29:20 +0000 Subject: [PATCH 5/8] split up wasm and linux build --- .../.github/workflows/publish.yml | 76 ++++++++++++++----- 1 file changed, 58 insertions(+), 18 deletions(-) diff --git a/circuits/cpp/barretenberg/.github/workflows/publish.yml b/circuits/cpp/barretenberg/.github/workflows/publish.yml index eac68c0b759..f65899f9298 100644 --- a/circuits/cpp/barretenberg/.github/workflows/publish.yml +++ b/circuits/cpp/barretenberg/.github/workflows/publish.yml @@ -19,8 +19,8 @@ permissions: contents: write jobs: - build-linux: - name: Build on Linux + build-x86_64-linux-gnu: + name: Build on Linux GNU runs-on: ubuntu-20.04 steps: - name: Checkout Code @@ -36,7 +36,7 @@ jobs: - name: Create Build Environment run: | sudo apt-get update - sudo apt-get -y install ninja-build yarn + sudo apt-get -y install ninja-build - name: Install Clang16 run: | @@ -46,12 +46,7 @@ jobs: sudo cp -r clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/include/* /usr/local/include/ sudo cp -r clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/* /usr/local/lib/ sudo cp -r clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/share/* /usr/local/share/ - - - name: Install yarn - run: | - curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list - sudo apt -y update && sudo apt -y install yarn + - name: Compile Barretenberg run: | cd cpp @@ -59,6 +54,50 @@ jobs: cmake --preset default -DCMAKE_BUILD_TYPE=RelWithAssert cmake --build --preset default --target bb + - name: Tar and GZip bb Binary (Ubuntu) + working-directory: cpp/build/bin + run: tar -cvzf barretenberg-x86_64-linux-gnu.tar.gz bb + + - name: Upload artifacts + uses: actions/upload-artifact@v2 + with: + name: release-linux + path: | + ./cpp/build/bin/barretenberg-x86_64-linux-gnu.tar.gz + + build-wasm-ts: + name: Build WASM and deploy to TS + runs-on: ubuntu-20.04 + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + ref: ${{ inputs.tag || env.GITHUB_REF }} + + - name: Install bleeding edge cmake + run: | + sudo apt -y remove --purge cmake + sudo snap install cmake --classic + + - name: Create Build Environment + run: | + sudo apt-get update + sudo apt-get -y install ninja-build yarn + + - name: Install Clang16 + run: | + wget https://github.com/llvm/llvm-project/releases/download/llvmorg-16.0.0/clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz + tar -xvf clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz + sudo cp clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/* /usr/local/bin/ + sudo cp -r clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/include/* /usr/local/include/ + sudo cp -r clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/lib/* /usr/local/lib/ + sudo cp -r clang+llvm-16.0.0-x86_64-linux-gnu-ubuntu-18.04/share/* /usr/local/share/ + + - name: Install yarn + run: | + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - + echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list + sudo apt -y update && sudo apt -y install yarn - name: Install WASI-SDK run: | cd cpp @@ -81,23 +120,19 @@ jobs: registry-url: "https://registry.npmjs.org" - name: Deploy Typescript to NPM + if: github.event.inputs.tag != 'nightly' && github.event.inputs.tag != '' # Do not deploy to npm if it is a nightly build run: | cd ts yarn deploy env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} - - name: Tar and GZip bb Binary (Ubuntu) - working-directory: cpp/build/bin - run: tar -cvzf barretenberg-x86_64-linux-gnu.tar.gz bb - - name: Upload artifacts uses: actions/upload-artifact@v2 with: - name: release-linux-wasm + name: release-wasm path: | ./cpp/build-wasm/bin/barretenberg.wasm.tar.gz - ./cpp/build/bin/barretenberg-x86_64-linux-gnu.tar.gz build-mac: name: Build on Mac (${{ matrix.target }}) @@ -143,13 +178,18 @@ jobs: release: name: Publish - needs: [build-linux, build-mac] + needs: [build-x86_64-linux-gnu, build-mac, build-wasm-ts] runs-on: ubuntu-latest steps: - name: Download files from Linux Runner uses: actions/download-artifact@v2 with: - name: release-linux-wasm + name: release-linux + + - name: Download files for WASM + uses: actions/download-artifact@v2 + with: + name: release-wasm - name: Download files from x86_64 Mac Runner uses: actions/download-artifact@v2 @@ -171,4 +211,4 @@ jobs: barretenberg.wasm.tar.gz barretenberg-x86_64-linux-gnu.tar.gz barretenberg-x86_64-apple-darwin.tar.gz - barretenberg-aarch64-apple-darwin.tar.gz + barretenberg-aarch64-apple-darwin.tar.gz \ No newline at end of file From 5b1240870893a96b5c253ed49deedb2d09821a4a Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 28 Aug 2023 13:37:54 +0000 Subject: [PATCH 6/8] add acvm_backend.wasm --- circuits/cpp/barretenberg/.github/workflows/publish.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/circuits/cpp/barretenberg/.github/workflows/publish.yml b/circuits/cpp/barretenberg/.github/workflows/publish.yml index f65899f9298..fe2132eb54c 100644 --- a/circuits/cpp/barretenberg/.github/workflows/publish.yml +++ b/circuits/cpp/barretenberg/.github/workflows/publish.yml @@ -113,6 +113,10 @@ jobs: working-directory: cpp/build-wasm/bin run: tar -cvzf barretenberg.wasm.tar.gz barretenberg.wasm + - name: Tar and GZip acvm_backend.wasm + working-directory: cpp/build-wasm/bin + run: tar -cvzf acvm_backend.wasm.tar.gz acvm_backend.wasm + - name: Setup Node.js uses: actions/setup-node@v2 with: @@ -133,6 +137,7 @@ jobs: name: release-wasm path: | ./cpp/build-wasm/bin/barretenberg.wasm.tar.gz + ./cpp/build-wasm/bin/acvm_backend.wasm.tar.gz build-mac: name: Build on Mac (${{ matrix.target }}) @@ -209,6 +214,7 @@ jobs: prerelease: true files: | barretenberg.wasm.tar.gz + acvm_backend.wasm.tar.gz barretenberg-x86_64-linux-gnu.tar.gz barretenberg-x86_64-apple-darwin.tar.gz barretenberg-aarch64-apple-darwin.tar.gz \ No newline at end of file From 7de82f56db7204a91263368d189742ffec54ae9c Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 28 Aug 2023 15:05:11 +0000 Subject: [PATCH 7/8] explicitly set compiler flags --- circuits/cpp/cmake/toolchains/aarch64-darwin.cmake | 2 ++ circuits/cpp/cmake/toolchains/x86_64-darwin.cmake | 2 ++ 2 files changed, 4 insertions(+) diff --git a/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake b/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake index a3b8d52fa72..8899c4b1c00 100644 --- a/circuits/cpp/cmake/toolchains/aarch64-darwin.cmake +++ b/circuits/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/cmake/toolchains/x86_64-darwin.cmake b/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake index 0aa93407fbd..535814275ba 100644 --- a/circuits/cpp/cmake/toolchains/x86_64-darwin.cmake +++ b/circuits/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") From 8f45f093e5da8e856b03bc5308e0dce8d0029fd5 Mon Sep 17 00:00:00 2001 From: kevaundray Date: Mon, 28 Aug 2023 15:07:43 +0000 Subject: [PATCH 8/8] modify yml to cross compile on mac --- .../cpp/barretenberg/.github/workflows/publish.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/circuits/cpp/barretenberg/.github/workflows/publish.yml b/circuits/cpp/barretenberg/.github/workflows/publish.yml index fe2132eb54c..a162603f0aa 100644 --- a/circuits/cpp/barretenberg/.github/workflows/publish.yml +++ b/circuits/cpp/barretenberg/.github/workflows/publish.yml @@ -161,11 +161,19 @@ jobs: - name: Create Mac Build Environment run: brew install cmake ninja - - name: Compile Barretenberg + - name: Compile Barretenberg (x86_64) + if: matrix.target == 'x86_64-apple-darwin' working-directory: cpp run: | cmake --preset default -DCMAKE_BUILD_TYPE=RelWithAssert cmake --build --preset default --target bb + + - name: Compile Barretenberg (ARM) + if: matrix.target == 'aarch64-apple-darwin' + working-directory: cpp + run: | + cmake --toolchain ./cmake/toolchains/aarch64-darwin.cmake --preset default -DCMAKE_BUILD_TYPE=RelWithAssert + cmake --build --preset default --target bb - name: Package barretenberg artifact working-directory: cpp/build/bin