diff options
| author | Mark Rowe <mark@vector35.com> | 2025-07-29 16:20:49 -0700 |
|---|---|---|
| committer | Mark Rowe <mark@vector35.com> | 2025-08-14 15:43:38 -0700 |
| commit | 0c572b1343d1e98574b7bc46169947f2dd5a257d (patch) | |
| tree | 586668986db0ce2e5e73a4977f2efa8b5832b19c /plugins/dwarf | |
| parent | 5957643780031478927457215296267592446286 (diff) | |
[Mac] Consistently specify rpaths for plug-ins
C++ plug-ins now consistently use the `plugin_rpath` or
`ui_plugin_rpath` macros to ensure they have `SKIP_BUILD_RPATH` set when
building on Mac (i.e., no `LC_RPATH` is added).
Rust plug-ins have their build.rs updated to only specify `-Wl,-rpath`
when building for Linux. It is not needed on macOS. On macOS we instead
explicitly specify an `@rpath`-relative install name. This doesn't
change any behavior, but avoids leaving an absolute path as the
library's install name and is consistent with CMake's behavior for C++
plug-ins.
Diffstat (limited to 'plugins/dwarf')
| -rw-r--r-- | plugins/dwarf/dwarf_export/build.rs | 9 | ||||
| -rw-r--r-- | plugins/dwarf/dwarf_import/build.rs | 9 |
2 files changed, 16 insertions, 2 deletions
diff --git a/plugins/dwarf/dwarf_export/build.rs b/plugins/dwarf/dwarf_export/build.rs index ed6cec7d..97e3e7f5 100644 --- a/plugins/dwarf/dwarf_export/build.rs +++ b/plugins/dwarf/dwarf_export/build.rs @@ -5,11 +5,18 @@ fn main() { println!("cargo::rustc-link-lib=dylib=binaryninjacore"); println!("cargo::rustc-link-search={}", link_path.to_str().unwrap()); - #[cfg(not(target_os = "windows"))] + #[cfg(target_os = "linux")] { println!( "cargo::rustc-link-arg=-Wl,-rpath,{0},-L{0}", link_path.to_string_lossy() ); } + + #[cfg(target_os = "macos")] + { + let crate_name = std::env::var("CARGO_PKG_NAME").expect("CARGO_PKG_NAME not set"); + let lib_name = crate_name.replace('-', "_"); + println!("cargo::rustc-link-arg=-Wl,-install_name,@rpath/lib{}.dylib", lib_name); + } } diff --git a/plugins/dwarf/dwarf_import/build.rs b/plugins/dwarf/dwarf_import/build.rs index ed6cec7d..97e3e7f5 100644 --- a/plugins/dwarf/dwarf_import/build.rs +++ b/plugins/dwarf/dwarf_import/build.rs @@ -5,11 +5,18 @@ fn main() { println!("cargo::rustc-link-lib=dylib=binaryninjacore"); println!("cargo::rustc-link-search={}", link_path.to_str().unwrap()); - #[cfg(not(target_os = "windows"))] + #[cfg(target_os = "linux")] { println!( "cargo::rustc-link-arg=-Wl,-rpath,{0},-L{0}", link_path.to_string_lossy() ); } + + #[cfg(target_os = "macos")] + { + let crate_name = std::env::var("CARGO_PKG_NAME").expect("CARGO_PKG_NAME not set"); + let lib_name = crate_name.replace('-', "_"); + println!("cargo::rustc-link-arg=-Wl,-install_name,@rpath/lib{}.dylib", lib_name); + } } |
