From 5fcaa2916ae0182cf6883c2d5aefc011216c55b4 Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Thu, 21 May 2026 13:10:33 +0200 Subject: [PATCH] Install llvm on macos. --- .github/actions/compile-witness-generator/action.yml | 6 ++++-- .github/resources/witness-generator/Makefile | 2 ++ CONTRIBUTING.md | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/actions/compile-witness-generator/action.yml b/.github/actions/compile-witness-generator/action.yml index 5aa0e32..c3f3d15 100644 --- a/.github/actions/compile-witness-generator/action.yml +++ b/.github/actions/compile-witness-generator/action.yml @@ -104,10 +104,12 @@ runs: if [ "$OS" = "macos" ]; then SED_I="sed -i ''"; fi $SED_I ':a;N;$!ba;s/\n}\n\n*$/\n return 0;\n}/' "${CIRCUIT_CPP_PATH}/main.cpp" - - name: Set up LLVM tools (macOS) + - name: Install llvm-objcopy (macOS) if: ${{ inputs.os == 'macos' }} shell: bash - run: echo "$(brew --prefix llvm)/bin" >> "$GITHUB_PATH" + run: | + brew install llvm + echo "$(brew --prefix llvm)/bin" >> "$GITHUB_PATH" # TODO: Instead of insertion, make a fork that includes the appropriate patch (or the actual fix) - name: Patch MacOS GMP diff --git a/.github/resources/witness-generator/Makefile b/.github/resources/witness-generator/Makefile index 12068e9..4727b49 100644 --- a/.github/resources/witness-generator/Makefile +++ b/.github/resources/witness-generator/Makefile @@ -59,6 +59,8 @@ windows-lib: $(LIB) # section" errors that GNU objcopy causes. On Windows/COFF: GNU objcopy suffices # because COFF COMDAT is per-section (not group-based) and is already deduplicated # automatically by the linker — the ELF GRP_COMDAT problem does not apply. +# On macOS/Mach-O: llvm-objcopy (from brew install llvm) is used — it supports +# --keep-global-symbol for Mach-O since LLVM 12. PUBLIC_SYMS := $(PROJECT)_generate_witness $(PROJECT)_generate_witness_from_files LOCAL_OBJ := $(PROJECT)_local.o OBJCOPY := $(if $(filter windows,$(OS)),objcopy,llvm-objcopy) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 871ceb3..d2d4c02 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -77,6 +77,9 @@ regular non-COMDAT sections that are simply kept as-is rather than deduplicated. `fr.o` is excluded from the merge because it contains only field arithmetic (`Fr_*`) with no circuit-specific calls. It is safe to deduplicate across circuits — the linker picks one copy, which is correct since the code is identical. +On macOS/Mach-O, `llvm-objcopy` (from `brew install llvm`) is used — it supports `--keep-global-symbol` for +Mach-O since LLVM 12. It is not available in Xcode's toolchain and must be installed separately. + On Windows, GNU `objcopy` (from MinGW binutils) is used instead of `llvm-objcopy`. `llvm-objcopy --keep-global-symbol` is not supported for COFF objects, but GNU `objcopy --keep-global-symbol` works correctly on COFF — it maps the local binding to COFF storage class `C_STAT`. The ELF `GRP_COMDAT` problem that required `llvm-objcopy` on Linux does not