Skip to content

fix(nix): set @rpath install_name for librln.dylib on mac#406

Open
plopezlpz wants to merge 1 commit into
masterfrom
fix/rpath
Open

fix(nix): set @rpath install_name for librln.dylib on mac#406
plopezlpz wants to merge 1 commit into
masterfrom
fix/rpath

Conversation

@plopezlpz
Copy link
Copy Markdown

@plopezlpz plopezlpz commented Apr 15, 2026

Description

To fix:

  Failed to load plugin: dlopen(.../delivery_module_plugin.dylib):
    Library not loaded: /nix/var/nix/builds/nix-34915-1828854082/source/target/release/deps/librln.dylib

Changes

Pass -Wl,-install_name,@rpath/librln.dylib via RUSTFLAGS during the Cargo build so the correct relocatable reference is set at link time. Linux is unaffected

Testing

  • nix build on macOS produces librln.dylib with @rpath/librln.dylib as install_name
  • otool -L $out/lib/librln.dylib shows @rpath/librln.dylib

PR Lifecycle

Important

Draft PRs signal that work is still in progress and will not trigger CI.
Only mark your PR as Ready for review when you believe it is complete.
All CI checks must pass before requesting a review.

Code Guidelines

Please keep the following in mind (see CONTRIBUTING.md for full details):

Commits

  • Follow Conventional Commits (feat(rln):, fix(utils):, chore:, etc.)
  • Use the appropriate scope: rln, rln-cli, rln-wasm, utils, ci
  • GPG-sign your commits

Error Handling

  • No panics in library code. Do not use unwrap(), expect(), or panic!()
    in production paths inside rln/src/ or utils/src/.
    The only acceptable exception is an internal invariant that is statically guaranteed - and even then, prefer returning an error.
  • Use the project's thiserror-based error types (RLNError, ProtocolError, UtilsError, etc.)
    and propagate errors with ?.
  • Provide context in error variants (e.g., InsufficientData { expected, actual }).
  • unwrap() is fine in tests.

Code Style

  • Run cargo make fmt at the root of the repository to auto-format the entire codebase with rules defined in rustfmt.toml.
  • Run cargo make fmt_check to verify formatting (CI enforces this on stable).
  • Group imports: std first, then external crates, then local modules (see rustfmt.toml).
  • Use pub(crate) for items that should not be part of the public API.
  • Apply Zeroize / ZeroizeOnDrop to any struct holding secret material.

Linting (mirrors CI)

CI runs clippy across multiple crate/feature combinations. Run the relevant checks locally before pushing:

# Default features - workspace root (rln + utils)
cargo clippy --all-targets --tests --release -- -D warnings

# Stateless feature - from rln/
cd rln && cargo clippy --all-targets --tests --release \
  --features=stateless --no-default-features -- -D warnings

# WASM target - from rln-wasm/
cd rln-wasm && cargo clippy --target wasm32-unknown-unknown \
  --tests --release -- -D warnings

At minimum, run the default-features check. If your changes touch stateless or rln-wasm, run those checks as well.

Checklist

  • My PR title follows Conventional Commits format
  • I have linked the related issue(s)
  • I have run cargo +nightly fmt --all to apply all rustfmt.toml rules (including import grouping)
  • cargo fmt --all -- --check produces no changes
  • Clippy passes for all affected crate/feature combinations (see Linting above)
  • make test passes locally
  • No new unwrap() / expect() / panic!() in library code
  • New code includes appropriate tests (unit / integration / WASM where applicable)
  • I have run the CI coverage report - add the run-coverage label to enable it
  • All CI checks pass and the PR is marked Ready for review

Copy link
Copy Markdown

@NagyZoltanPeter NagyZoltanPeter left a comment

Choose a reason for hiding this comment

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

Oh, it's great thanks!
I just added this postinstall fix for logos-delivery-module :-D
logos-co/logos-delivery-module#5

@github-actions
Copy link
Copy Markdown

Benchmark for c16fd32

Click to view benchmark
Test Base PR %
FullMerkleTree::::full_depth_gen 10.8±0.23ms 11.8±0.10ms +9.26%
OptimalMerkleTree::::full_depth_gen 690.3±12.75µs 692.3±6.72µs +0.29%
Pmtree::delete 50.3±1.08µs 50.6±0.65µs +0.60%
Pmtree::get 293.7±5.99ns 294.9±8.53ns +0.41%
Pmtree::get_empty_leaves_indices 8.2±0.25ns 8.4±0.16ns +2.44%
Pmtree::get_subtree_root 358.7±10.94ns 370.7±8.05ns +3.35%
Pmtree::override_range 102.3±2.11µs 105.0±1.23µs +2.64%
Pmtree::set 50.6±0.85µs 50.7±0.80µs +0.20%
Set/FullMerkleTree::::set/1 510.6±10.75µs 517.3±6.70µs +1.31%
Set/FullMerkleTree::::set/10 5.2±0.08ms 5.2±0.07ms 0.00%
Set/FullMerkleTree::::set/100 51.5±0.96ms 51.9±0.76ms +0.78%
Set/FullMerkleTree::::set_range/1 512.1±10.01µs 516.7±9.12µs +0.90%
Set/FullMerkleTree::::set_range/10 701.4±13.04µs 702.8±13.73µs +0.20%
Set/FullMerkleTree::::set_range/100 1887.6±43.37µs 1885.5±25.00µs -0.11%
Set/OptimalMerkleTree::::set/1 516.0±8.45µs 514.8±8.70µs -0.23%
Set/OptimalMerkleTree::::set/10 5.2±0.05ms 5.2±0.10ms 0.00%
Set/OptimalMerkleTree::::set/100 51.6±0.99ms 52.0±0.80ms +0.78%
Set/OptimalMerkleTree::::set_range/1 511.0±11.95µs 513.4±6.90µs +0.47%
Set/OptimalMerkleTree::::set_range/10 712.6±13.45µs 722.0±14.04µs +1.32%
Set/OptimalMerkleTree::::set_range/100 1813.3±45.21µs 1827.6±30.32µs +0.79%
rln_finish_partial_proof 66.7±1.17ms 66.7±1.18ms 0.00%
rln_full_proof 183.9±2.65ms 185.4±6.89ms +0.82%
rln_partial_proof_generation 127.8±1.61ms 128.2±3.39ms +0.31%

@github-actions
Copy link
Copy Markdown

Benchmark for c16fd32

Click to view benchmark
Test Base PR %
FullMerkleTree::delete 18.0±0.21µs 18.1±0.22µs +0.56%
FullMerkleTree::get 0.8±0.01ns 0.8±0.01ns 0.00%
FullMerkleTree::get_empty_leaves_indices 981.9±5.62µs 983.9±12.75µs +0.20%
FullMerkleTree::get_subtree_root 9.9±0.14ns 9.9±0.06ns 0.00%
FullMerkleTree::override_range 1902.5±23.79µs 1896.1±43.72µs -0.34%
FullMerkleTree::set 8.9±0.09µs 9.0±0.12µs +1.12%
OptimalMerkleTree::delete 20.7±0.27µs 20.8±0.21µs +0.48%
OptimalMerkleTree::get 50.6±0.47ns 50.4±0.56ns -0.40%
OptimalMerkleTree::get_empty_leaves_indices 983.1±9.05µs 982.5±7.54µs -0.06%
OptimalMerkleTree::get_subtree_root 26.2±0.35ns 26.4±2.07ns +0.76%
OptimalMerkleTree::override_range 4.0±0.47ms 3.9±0.35ms -2.50%
OptimalMerkleTree::set 10.6±0.22µs 10.4±0.18µs -1.89%
poseidon Fr/Array hash/10 140.7±0.18µs 69.4 KElem/sec N/A N/A
poseidon Fr/Array hash/100 1508.3±1.34µs 64.7 KElem/sec N/A N/A
poseidon Fr/Array hash/1000 15.2±0.01ms 64.2 KElem/sec N/A N/A
poseidon Fr/Single hash 13.9±0.02µs 68.4 MElem/sec N/A N/A
validate_override_range/FullMerkleTree/override_range/1024 473.1±11.66µs 475.2±19.88µs +0.44%
validate_override_range/FullMerkleTree/override_range/64 68.9±3.20µs 69.6±3.96µs +1.02%
validate_override_range/FullMerkleTree/override_range/65536 436.6±3.19ms 441.9±2.63ms +1.21%
validate_override_range/FullMerkleTree/override_range/8192 8.5±0.05ms 8.7±0.03ms +2.35%
validate_override_range/OptimalMerkleTree/override_range/1024 641.8±13.23µs 698.5±34.43µs +8.83%
validate_override_range/OptimalMerkleTree/override_range/64 93.1±6.45µs 92.9±4.74µs -0.21%
validate_override_range/OptimalMerkleTree/override_range/65536 459.7±4.28ms 461.1±3.36ms +0.30%
validate_override_range/OptimalMerkleTree/override_range/8192 9.9±0.05ms 9.9±0.04ms 0.00%
validate_override_range/validate_only/1024 8.3±0.12µs 8.3±0.08µs 0.00%
validate_override_range/validate_only/64 358.9±5.06ns 359.9±4.57ns +0.28%
validate_override_range/validate_only/65536 869.7±10.45µs 869.5±5.44µs -0.02%
validate_override_range/validate_only/8192 105.9±1.23µs 105.9±1.07µs 0.00%

Comment thread nix/default.nix
Comment on lines 35 to +41
buildPhase = ''
export CARGO_HOME=$TMPDIR/cargo
'' + pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
# Set install_name to @rpath at link time so consumers can dlopen
# librln.dylib from any location without post-build fixups.
export RUSTFLAGS="''${RUSTFLAGS:-} -C link-arg=-Wl,-install_name,@rpath/librln.dylib"
'' + ''
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If you grep nixpkgs you can see in most cases RUSTFLAGS is just set directly with needing previous value of RUSTFLAGS.

Suggested change
buildPhase = ''
export CARGO_HOME=$TMPDIR/cargo
'' + pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isDarwin ''
# Set install_name to @rpath at link time so consumers can dlopen
# librln.dylib from any location without post-build fixups.
export RUSTFLAGS="''${RUSTFLAGS:-} -C link-arg=-Wl,-install_name,@rpath/librln.dylib"
'' + ''
# Set install_name to @rpath at link time so consumers can dlopen
# librln.dylib from any location without post-build fixups.
env.RUSTFLAGS = lib.optionalString stdenv.hostPlatform.isDarwin "-C link-arg=-Wl,-install_name,@rpath/librln.dylib";
buildPhase = ''
export CARGO_HOME=$TMPDIR/cargo

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.

3 participants