Skip to content

Conversation

@aryehlev
Copy link
Owner

@aryehlev aryehlev commented Nov 9, 2025

Summary by CodeRabbit

  • Chores

    • Version bumped to 0.3.6.
  • Bug Fixes

    • Improved platform-specific build behavior to ensure runtime libraries are found on macOS and Linux, including enhanced post-build adjustments and rpath handling for more reliable cross-platform loading.

@coderabbitai
Copy link

coderabbitai bot commented Nov 9, 2025

Walkthrough

Bumps package version to 0.3.6 and extends build.rs with platform-specific post-copy adjustments: macOS uses install_name_tool to set library ids and additional @loader_path rpaths; Linux uses patchelf (best-effort) to set soname and preserves/adds $ORIGIN-based rpaths for debug/release targets.

Changes

Cohort / File(s) Change Summary
Version Bump
Cargo.toml
Package version incremented from 0.3.5 to 0.3.6.
Build Script Platform Adjustments
build.rs
Added macOS post-copy steps using install_name_tool to set library IDs and extra @loader_path rpath entries; added Linux best-effort patchelf steps to set soname and preserve/add $ORIGIN-based rpaths (including conditional target/debug and target/release entries). No Windows-specific changes.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Cargo as Cargo/build
  participant buildrs as build.rs
  participant FS as FileSystem
  participant mac as macOS(tooling)
  participant linux as Linux(tooling)

  Cargo->>buildrs: invoke build script
  buildrs->>FS: copy catboost lib to OUT_DIR
  alt target is macOS
    buildrs->>mac: run install_name_tool on source lib (set id `@loader_path/`...)
    buildrs->>FS: copy adjusted lib to final location
    buildrs->>mac: run install_name_tool on copied lib (set id & rpath entries)
  else target is Linux
    buildrs->>linux: check for patchelf
    opt patchelf available
      buildrs->>linux: run patchelf on source lib (set soname)
      buildrs->>FS: copy adjusted lib to final location
      buildrs->>linux: run patchelf on copied lib (set soname & rpath entries)
    end
    opt patchelf unavailable
      buildrs->>FS: leave rpath/soname unchanged (best-effort)
    end
  end
  buildrs->>Cargo: emit link flags and rpath settings
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Files/areas to focus on:
    • build.rs — verify correctness of shell/command invocations, quoting, and error handling for missing tools.
    • rpath and id/soname values — confirm paths (@loader_path, $ORIGIN, target/debug, target/release) are correct for common build layouts.
    • Cross-platform branches — ensure Linux best-effort fallback behaves safely when patchelf is absent.

Poem

🐰 From point-five to point-six I leap so quick,

I tweak the paths where shared libs pick,
On mac I whisper id with a gentle tool,
On Linux I patch where RPATHs rule,
A tiny hop — the build runs smooth and slick. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title mentions 'debugger' support for 'max' (macOS) and Linux, which aligns with the build.rs changes adding platform-specific runtime library handling for macOS and Linux, though 'debugger' is not the most precise description of the technical changes.
✨ 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 debugger

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.

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 3d53349 and 467decc.

📒 Files selected for processing (2)
  • Cargo.toml (1 hunks)
  • build.rs (3 hunks)

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 (1)
build.rs (1)

182-211: Excellent fix for the Linux SONAME issue!

The critical issue from the previous review has been resolved. The SONAME is now correctly set to the plain library filename (lines 203, 208) instead of the problematic $ORIGIN/... prefix. The best-effort approach using .output() to silently handle missing patchelf is appropriate.

Minor optional refinements:

  • Consider moving use std::process::Command; to the top of the function to avoid duplicate imports (lines 185, 198)
  • For consistency, macOS uses .status() (lines 190, 196) while Linux uses .output() (lines 205, 210). Both work, but .output() is slightly better for suppressing stderr/stdout when silently ignoring failures
Optional: Consolidate Command import
+    use std::process::Command;
+
     // On macOS/Linux, change the install name/soname to use @loader_path/$ORIGIN
     // This needs to be done on the source library in OUT_DIR before linking
     if os == "darwin" {
-        use std::process::Command;
         let _ = Command::new("install_name_tool")
             .arg("-id")
             .arg(format!("@loader_path/{}", lib_filename))
             .arg(&lib_source_path)
             .status();
         // Also update the copy
         let _ = Command::new("install_name_tool")
             .arg("-id")
             .arg(format!("@loader_path/{}", lib_filename))
             .arg(&lib_dest_path)
             .status();
     } else if os == "linux" {
-        use std::process::Command;
         // Use patchelf to set soname to just the library filename on Linux (if available)
         // This is optional - if patchelf is not installed, we just skip it
         let _ = Command::new("patchelf")
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 467decc and 5113d3d.

📒 Files selected for processing (1)
  • build.rs (3 hunks)
⏰ 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). (1)
  • GitHub Check: Build Docker image
🔇 Additional comments (2)
build.rs (2)

226-227: Good addition for debugger support on macOS.

Adding @loader_path and @loader_path/../.. rpaths complements the existing @executable_path entries and helps the dynamic loader locate the library in debugger scenarios where the loading context may differ.


240-244: Good parity with macOS rpath handling.

Adding the target/debug and target/release directories to Linux rpaths mirrors the macOS behavior and ensures consistent library discovery across build configurations, supporting the PR's debugger objectives.

@aryehlev aryehlev merged commit f731ab1 into publish Nov 9, 2025
2 checks passed
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.

2 participants