summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Rowe <mark@vector35.com>2025-07-29 16:20:49 -0700
committerMark Rowe <mark@vector35.com>2025-08-14 15:43:38 -0700
commit0c572b1343d1e98574b7bc46169947f2dd5a257d (patch)
tree586668986db0ce2e5e73a4977f2efa8b5832b19c
parent5957643780031478927457215296267592446286 (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.
-rw-r--r--arch/msp430/build.rs9
-rw-r--r--arch/riscv/build.rs9
-rw-r--r--plugins/dwarf/dwarf_export/build.rs9
-rw-r--r--plugins/dwarf/dwarf_import/build.rs9
-rw-r--r--plugins/efi_resolver/CMakeLists.txt2
-rw-r--r--plugins/idb_import/build.rs9
-rw-r--r--plugins/pdb-ng/build.rs9
-rw-r--r--plugins/svd/build.rs9
-rw-r--r--plugins/warp/build.rs9
-rw-r--r--plugins/workflow_objc/CMakeLists.txt1
-rw-r--r--rust/README.md9
-rw-r--r--view/kernelcache/CMakeLists.txt2
-rw-r--r--view/kernelcache/ui/CMakeLists.txt2
-rw-r--r--view/sharedcache/CMakeLists.txt2
-rw-r--r--view/sharedcache/ui/CMakeLists.txt2
15 files changed, 83 insertions, 9 deletions
diff --git a/arch/msp430/build.rs b/arch/msp430/build.rs
index ed6cec7d..97e3e7f5 100644
--- a/arch/msp430/build.rs
+++ b/arch/msp430/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/arch/riscv/build.rs b/arch/riscv/build.rs
index ed6cec7d..97e3e7f5 100644
--- a/arch/riscv/build.rs
+++ b/arch/riscv/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_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);
+ }
}
diff --git a/plugins/efi_resolver/CMakeLists.txt b/plugins/efi_resolver/CMakeLists.txt
index 90f30960..684cae6e 100644
--- a/plugins/efi_resolver/CMakeLists.txt
+++ b/plugins/efi_resolver/CMakeLists.txt
@@ -25,6 +25,8 @@ file(
add_library(efi_resolver SHARED ${SOURCE_FILES})
target_link_libraries(efi_resolver binaryninjaapi)
+
+plugin_rpath(efi_resolver)
target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_compile_features(efi_resolver PRIVATE cxx_std_20 c_std_99)
diff --git a/plugins/idb_import/build.rs b/plugins/idb_import/build.rs
index ed6cec7d..97e3e7f5 100644
--- a/plugins/idb_import/build.rs
+++ b/plugins/idb_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);
+ }
}
diff --git a/plugins/pdb-ng/build.rs b/plugins/pdb-ng/build.rs
index ed6cec7d..97e3e7f5 100644
--- a/plugins/pdb-ng/build.rs
+++ b/plugins/pdb-ng/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/svd/build.rs b/plugins/svd/build.rs
index 637f4779..bfb84d94 100644
--- a/plugins/svd/build.rs
+++ b/plugins/svd/build.rs
@@ -7,7 +7,7 @@ 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}",
@@ -15,6 +15,13 @@ fn main() {
);
}
+ #[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);
+ }
+
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR specified");
let out_dir_path = PathBuf::from(out_dir);
diff --git a/plugins/warp/build.rs b/plugins/warp/build.rs
index a9d6dd1d..4afc410f 100644
--- a/plugins/warp/build.rs
+++ b/plugins/warp/build.rs
@@ -7,7 +7,7 @@ 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}",
@@ -15,6 +15,13 @@ fn main() {
);
}
+ #[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);
+ }
+
let out_dir = std::env::var("OUT_DIR").expect("OUT_DIR specified");
let out_dir_path = PathBuf::from(out_dir);
diff --git a/plugins/workflow_objc/CMakeLists.txt b/plugins/workflow_objc/CMakeLists.txt
index 61ba4962..a16a5519 100644
--- a/plugins/workflow_objc/CMakeLists.txt
+++ b/plugins/workflow_objc/CMakeLists.txt
@@ -28,6 +28,7 @@ set(PLUGIN_SOURCE
add_library(workflow_objc SHARED ${PLUGIN_SOURCE})
target_link_libraries(workflow_objc binaryninjaapi)
target_compile_features(workflow_objc PRIVATE cxx_std_20 c_std_99)
+plugin_rpath(workflow_objc)
# Library targets linking against the Binary Ninja API need to be compiled with
# position-independent code on Linux.
diff --git a/rust/README.md b/rust/README.md
index 9aa3a81c..1edd1d90 100644
--- a/rust/README.md
+++ b/rust/README.md
@@ -73,13 +73,20 @@ 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/view/kernelcache/CMakeLists.txt b/view/kernelcache/CMakeLists.txt
index 5bd46370..aa52d2a3 100644
--- a/view/kernelcache/CMakeLists.txt
+++ b/view/kernelcache/CMakeLists.txt
@@ -66,6 +66,8 @@ target_include_directories(kernelcache PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMA
target_link_libraries(kernelcache PUBLIC kernelcacheapi binaryninjaapi kernelcachecore) # kernelcacheworkflow)
+plugin_rpath(kernelcache)
+
set(COMPILE_DEFS "")
diff --git a/view/kernelcache/ui/CMakeLists.txt b/view/kernelcache/ui/CMakeLists.txt
index e2f04d0d..cac2010e 100644
--- a/view/kernelcache/ui/CMakeLists.txt
+++ b/view/kernelcache/ui/CMakeLists.txt
@@ -93,3 +93,5 @@ target_include_directories(kernelcacheui PRIVATE ${INCLUDES})
target_link_libraries(kernelcacheui kernelcacheapi kernelcache binaryninjaui Qt6::Core Qt6::Gui Qt6::Widgets)
+ui_plugin_rpath(kernelcacheui)
+
diff --git a/view/sharedcache/CMakeLists.txt b/view/sharedcache/CMakeLists.txt
index e84ada5e..b49f8df7 100644
--- a/view/sharedcache/CMakeLists.txt
+++ b/view/sharedcache/CMakeLists.txt
@@ -68,6 +68,8 @@ target_include_directories(sharedcache PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMA
target_link_libraries(sharedcache PUBLIC sharedcacheapi binaryninjaapi sharedcachecore sharedcacheworkflow)
+plugin_rpath(sharedcache)
+
set(COMPILE_DEFS "")
diff --git a/view/sharedcache/ui/CMakeLists.txt b/view/sharedcache/ui/CMakeLists.txt
index 4fc1a5d4..0de89f60 100644
--- a/view/sharedcache/ui/CMakeLists.txt
+++ b/view/sharedcache/ui/CMakeLists.txt
@@ -94,3 +94,5 @@ target_include_directories(sharedcacheui PRIVATE ${INCLUDES})
target_link_libraries(sharedcacheui sharedcacheapi sharedcache binaryninjaui Qt6::Core Qt6::Gui Qt6::Widgets)
+ui_plugin_rpath(sharedcacheui)
+