Skip to content

Conversation

@lightsing
Copy link
Member

@lightsing lightsing commented Nov 27, 2025

Purpose or design rationale of this PR

This PR enables building the project on macOS by addressing platform-specific library and code signing requirements. The changes add support for macOS's .dylib library format and implement automatic code signing for binaries on Darwin systems.

Deployment tag versioning

Has tag in common/version.go been updated or have you added bump-version label to this PR?

  • No, this PR doesn't involve a new deployment, git tag, docker image tag
  • Yes

Breaking change label

Does this PR have the breaking-change label?

  • No, this PR is not a breaking change
  • Yes

Summary by CodeRabbit

  • New Features

    • macOS support with automated code‑signing of built binaries
    • Native dylib library format support on macOS
  • Documentation

    • Build instructions updated to recommend Go 1.22
  • Chores

    • Consolidated shared build logic for cross‑platform handling and library naming
    • Added code‑signing step to test and coordinator build targets

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds Darwin/macOS detection to shared Makefile, selects platform-appropriate shared library extension/name, introduces a macOS codesign macro, updates Makefiles and cgo linker flags to use the platform-aware library name, adds cdylib output for the Rust crate, and signs macOS-built binaries.

Changes

Cohort / File(s) Summary
Build infrastructure (Darwin support)
build/common.mk
Add UNAME_S, IS_DARWIN; set SHLIB_EXT default so and dylib on Darwin; define LIB_ZKP_NAME = libzkp.$(SHLIB_EXT); add macos_codesign macro that runs codesign and verification when on macOS.
Coordinator build & lib packaging
coordinator/Makefile, coordinator/internal/logic/libzkp/Makefile
Include shared build/common.mk; replace hard-coded library path with ./internal/logic/libzkp/lib/$(LIB_ZKP_NAME); run $(call macos_codesign,...) on build/bin/coordinator_api; update clean/copy targets to use $(LIB_ZKP_NAME); add extra cargo clippy invocation.
cgo linker flags
coordinator/internal/logic/libzkp/lib.go
Replace single #cgo LDFLAGS: with OS-specific cgo blocks: Linux uses -Wl,-rpath=${SRCDIR}/lib; Darwin uses -Wl,-rpath,${SRCDIR}/lib.
Rust crate output types
crates/libzkp/Cargo.toml
Add [lib] section with crate-type = ["rlib", "cdylib"] to produce both rlib and cdylib outputs.
Tests / e2e tool build
tests/prover-e2e/Makefile
Include ../../build/common.mk; add macos_codesign step for the built e2e_tool binary; minor newline adjustments.
Ignore rules
coordinator/.gitignore
Broaden ignore to root-level libzkp.so and libzkp.dylib patterns.
Docs
coordinator/README.md
Add Using Go version 1.22 line in Build instructions above the build block.

Sequence Diagram(s)

sequenceDiagram
  participant Dev as Developer
  participant Make as Makefile (includes build/common.mk)
  participant Toolchain as Build Toolchain
  participant Codesign as macOS codesign

  Note over Make: determine SHLIB_EXT & LIB_ZKP_NAME\ndefine macos_codesign macro
  Dev->>Make: invoke target (e.g., coordinator_api / test_tool)
  Make->>Toolchain: build binary (and produce lib/$(LIB_ZKP_NAME))
  alt IS_DARWIN == true
    Make->>Codesign: call macos_codesign(<binary>)
    Codesign-->>Make: codesign --force --sign -\ncodesign --verify --deep --verbose
  else IS_DARWIN == false
    Note right of Make: codesign step skipped
  end
  Make->>Dev: artifact(s) produced
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect build/common.mk for correct OS detection and SHLIB_EXT logic.
  • Verify macos_codesign macro condition and flags (force/sign and verify).
  • Validate cgo LDFLAGS syntax for both Linux and Darwin in lib.go.
  • Confirm Cargo.toml crate-type change won't interfere with existing Rust build/integration.
  • Check all Makefile substitutions for $(LIB_ZKP_NAME) and .gitignore pattern coverage.

Poem

🐰 I hopped into the build tonight,
Found libs that change with moonlight,
dylib or so, chosen right,
Signed with care, then tucked in tight —
A tiny hop, a happy byte.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is incomplete and missing the required 'Purpose or design rationale' section details. Add a clear explanation of what the PR does, why it does it, and how it does it in the 'Purpose or design rationale' section. Also confirm the PR title follows Conventional Commits format.
✅ Passed checks (2 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title 'fix(build): build on macos' accurately and concisely describes the main objective of the changeset—enabling macOS build support through OS detection, platform-specific configurations, and code signing.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/macos

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lightsing lightsing marked this pull request as ready for review November 27, 2025 04:29
@lightsing lightsing requested review from Copilot, lispc and noel2004 and removed request for lispc and noel2004 November 27, 2025 04:32
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
coordinator/.gitignore (1)

4-5: Darwin artifact ignore looks good; consider a wildcard for future extensions

Adding libzkp.dylib keeps macOS build artifacts out of git. You might also consider a single pattern like internal/libzkp/lib/libzkp.* to cover both .so and .dylib (and any future variants) instead of two separate lines.

coordinator/README.md (1)

13-18: Clarify Go version requirement in a tool-agnostic way

The gvm use go1.22 hint is helpful, but a brief preceding comment like “Go 1.22 is required (example using gvm below)” would make it clearer that any version manager (or system install) satisfying 1.22 is fine, not just gvm.

coordinator/internal/logic/libzkp/Makefile (1)

1-2: Keep clean in sync with LIB_ZKP_NAME for Darwin builds

Including common.mk and switching the copy step to $(LIB_ZKP_NAME) is the right direction for cross‑platform builds. The clean target still hardcodes lib/libzkp.so, though, so on macOS the libzkp.dylib will survive a make clean.

Consider updating the rule to use the same variable:

 clean:
-	@cargo clean --release -p libzkp -p libzkp-c -p l2geth
-	@rm -f lib/libzkp.so
+	@cargo clean --release -p libzkp -p libzkp-c -p l2geth
+	@rm -f lib/$(LIB_ZKP_NAME)

or, if you want to be extra safe across historical layouts:

	@rm -f lib/libzkp.so lib/libzkp.dylib

Also applies to: 5-9, 13-16

coordinator/Makefile (1)

1-2: Common lib naming and macOS codesign hook look good; please verify ignore paths

Using ../build/common.mk plus LIBZKP_PATH=./internal/logic/libzkp/lib/$(LIB_ZKP_NAME) ties the coordinator build cleanly into the shared SHLIB_EXT/LIB_ZKP_NAME logic, and the macos_codesign call on coordinator_api is correctly guarded by the Darwin check in common.mk.

One thing to double‑check: coordinator/.gitignore is still ignoring internal/libzkp/lib/libzkp.{so,dylib} (without the logic segment), while this Makefile now expects the library under internal/logic/libzkp/lib. If the old path is no longer used, updating the ignore patterns to match the actual output directory would avoid accidentally tracking built libs.

Also applies to: 5-8, 30-33

build/common.mk (1)

1-16: Shared Darwin handling and macos_codesign helper are well-structured

Centralizing UNAME_S, SHLIB_EXT, and LIB_ZKP_NAME here, plus the macos_codesign macro guarded by IS_DARWIN, is a clean way to unify platform behavior across Makefiles. This should fix straightforward macOS local builds without impacting Linux.

If you ever need cross‑compilation (e.g., building Linux artifacts on macOS), you might later consider making UNAME_S/SHLIB_EXT overridable via the environment, but that can easily be deferred.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2ecc42e and 226d32f.

📒 Files selected for processing (8)
  • build/common.mk (1 hunks)
  • coordinator/.gitignore (1 hunks)
  • coordinator/Makefile (2 hunks)
  • coordinator/README.md (1 hunks)
  • coordinator/internal/logic/libzkp/Makefile (1 hunks)
  • coordinator/internal/logic/libzkp/lib.go (1 hunks)
  • crates/libzkp/Cargo.toml (1 hunks)
  • tests/prover-e2e/Makefile (3 hunks)
🧰 Additional context used
🪛 checkmake (0.2.2)
coordinator/internal/logic/libzkp/Makefile

[warning] 3-3: Missing required phony target "all"

(minphony)


[warning] 3-3: Missing required phony target "clean"

(minphony)

coordinator/Makefile

[warning] 3-3: Missing required phony target "all"

(minphony)


[warning] 3-3: Missing required phony target "test"

(minphony)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
🔇 Additional comments (3)
crates/libzkp/Cargo.toml (1)

6-8: Enabling both rlib and cdylib looks appropriate

Declaring crate-type = ["rlib", "cdylib"] aligns with using this crate both as a Rust dependency and as a C‑compatible shared library backing the coordinator/libzkp bindings. No further changes needed from my perspective.

tests/prover-e2e/Makefile (1)

1-2: macOS codesign integration for e2e_tool is wired correctly

Including ../../build/common.mk and then calling $(call macos_codesign,$(PWD)/build/bin/e2e_tool) cleanly reuses the shared Darwin logic while remaining a no‑op on non‑macOS hosts. The coordinator_setup copy into ../../coordinator/build/bin/conf also matches what localsetup prepares, so this target’s flow looks sound.

Also applies to: 55-58, 75-77

coordinator/internal/logic/libzkp/lib.go (1)

3-6: I'll verify the review comment by examining the actual file and checking whether the concerns about macOS compatibility and -ldl linking are valid.
<function_calls>

#!/bin/bash

First, let's read the actual file to see the current state

cat -n coordinator/internal/logic/libzkp/lib.go | head -20

</function_calls>

I need to check the file first. Let me use the appropriate capability:
<function_calls>

#!/bin/bash

Find the file and read it

find . -name "lib.go" -path "/libzkp/" | head -5


</function_calls>

Let me search more carefully for this file:
<function_calls>

#!/bin/bash

Search for the file

fd "lib.go" | grep -i libzkp


</function_calls>

Let me try a broader search:
<function_calls>

#!/bin/bash

List files in the coordinator directory

find . -type d -name "libzkp" 2>/dev/null
find . -path "coordinator" -name "lib.go" 2>/dev/null | head -10


</function_calls>

<function_calls>

#!/bin/bash

Search for any cgo comments with LDFLAGS

rg -l "#cgo LDFLAGS" --type go


</function_calls>

<function_calls>

#!/bin/bash

Look for cgo directives with -ldl

rg "-ldl" --type go -B2 -A2


</function_calls>

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables building the project on macOS by addressing platform-specific library and code signing requirements. The changes add support for macOS's .dylib library format and implement automatic code signing for binaries on Darwin systems.

Key Changes

  • Introduced platform detection and conditional library extension handling (.so vs .dylib)
  • Added automated macOS code signing for built binaries
  • Updated Rust library configuration to support dynamic library builds

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
build/common.mk New shared makefile with platform detection, library extension selection, and macOS code signing function
coordinator/Makefile Includes common.mk and applies dynamic library naming and code signing to coordinator_api binary
coordinator/internal/logic/libzkp/Makefile Uses dynamic library name from common.mk instead of hardcoded .so extension
coordinator/internal/logic/libzkp/lib.go Fixed LDFLAGS syntax for rpath to be macOS-compatible
coordinator/.gitignore Added .dylib to ignored files for macOS library builds
crates/libzkp/Cargo.toml Added cdylib crate type to support dynamic library generation
tests/prover-e2e/Makefile Includes common.mk and applies code signing to test tool binary
coordinator/README.md Added optional Go version comment for build instructions

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lightsing lightsing requested a review from Copilot November 27, 2025 04:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88066d7 and 5d378a0.

📒 Files selected for processing (2)
  • coordinator/README.md (1 hunks)
  • coordinator/internal/logic/libzkp/Makefile (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • coordinator/README.md
🧰 Additional context used
🪛 checkmake (0.2.2)
coordinator/internal/logic/libzkp/Makefile

[warning] 3-3: Missing required phony target "all"

(minphony)


[warning] 3-3: Missing required phony target "clean"

(minphony)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: tests
  • GitHub Check: check
  • GitHub Check: tests
🔇 Additional comments (3)
coordinator/internal/logic/libzkp/Makefile (3)

1-1: Platform-aware library naming infrastructure is properly initialized.

The inclusion of the shared build/common.mk enables platform detection for macOS and other operating systems.


8-8: Platform-aware library naming correctly replaces hardcoded .so extension.

Using $(LIB_ZKP_NAME) instead of the hardcoded libzkp.so allows the build system to select the appropriate library extension (.dylib on macOS, .so on Linux, etc.) consistently across build and clean targets.

Also applies to: 15-15


1-1: The variable LIB_ZKP_NAME is properly defined in build/common.mk and correctly used.

Verification confirms that LIB_ZKP_NAME is defined at line 9 of build/common.mk as libzkp.$(SHLIB_EXT), with SHLIB_EXT correctly set to so for Linux (line 4) and dylib for macOS (lines 5-7). The variable is actively used in both the build target (line 8) and clean target (line 15) of the included Makefile. No issues found.

@lightsing lightsing changed the title fix: build on macos fix(build): build on macos Nov 27, 2025
@codecov-commenter
Copy link

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 36.47%. Comparing base (2ecc42e) to head (8a05300).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1770      +/-   ##
===========================================
- Coverage    36.53%   36.47%   -0.07%     
===========================================
  Files          247      247              
  Lines        21188    21188              
===========================================
- Hits          7742     7728      -14     
- Misses       12616    12637      +21     
+ Partials       830      823       -7     
Flag Coverage Δ
coordinator 32.23% <ø> (-0.37%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants