Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion openvaf/linker/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ fn get_linker<'a>(
let path = path.unwrap_or_else(|| {
if is_msys2_environment() {
"gcc".into()
} else if cfg!(target_os = "macos") {
"clang".into()
} else {
"ld".into()
}
Expand Down Expand Up @@ -251,7 +253,8 @@ impl<'a> LdLinker<'a> {
fn build_dylib(&mut self) {
// On mac we need to tell the linker to let this library be rpathed
if self.target.options.is_like_osx {
self.linker_arg("-dylib");
self.linker_arg("-dynamiclib");
// clang automatically handles -lSystem
} else {
self.linker_arg("-shared");
}
Expand Down
17 changes: 17 additions & 0 deletions openvaf/openvaf-driver/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// build.rs for openvaf-driver

fn main() {
// Add rpath for LLVM on macOS
#[cfg(target_os = "macos")]
{
if let Ok(output) = std::process::Command::new("llvm-config")
.arg("--libdir")
.output()
{
if output.status.success() {
let libdir = String::from_utf8_lossy(&output.stdout).trim().to_string();
println!("cargo:rustc-link-arg=-Wl,-rpath,{}", libdir);
}
}
Comment on lines +7 to +15

Choose a reason for hiding this comment

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

medium

Consider adding a warning or error message if llvm-config fails to execute or returns a non-successful status. Currently, if llvm-config is not found or fails, the rpath is silently skipped, which might lead to confusing runtime errors later. Explicit feedback here would improve debuggability for users, especially during initial setup or when LLVM is not correctly configured on their system.

}
}