Skip to content
Open
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
8 changes: 8 additions & 0 deletions openvaf/openvaf-driver/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ fn main() {
// Add rpath for LLVM on macOS
#[cfg(target_os = "macos")]
{
// Official LLVM release tarballs ship only static component libs (no
// libLLVM.dylib), so llvm-sys's `prefer-dynamic` falls back to static
// linking. Those archives are C++ and need libc++ for their runtime
// symbols (operator new, __cxa_guard_*, __cxa_pure_virtual). Homebrew's
// LLVM has libLLVM.dylib so it never hits this, but link libc++ here so
// building against a static LLVM works too.
println!("cargo:rustc-link-lib=dylib=c++");
println!("cargo:rustc-link-lib=dylib=c++abi");
Comment on lines +31 to +32

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

On macOS, libc++ (linked via c++) transitively links to libc++abi [16.1.1]. Therefore, explicitly linking c++abi is redundant and unnecessary, as the dynamic linker (dyld) will automatically load it and resolve all C++ runtime symbols (such as __cxa_guard_acquire and __cxa_pure_virtual). We can safely remove the explicit link to c++abi.

Suggested change
println!("cargo:rustc-link-lib=dylib=c++");
println!("cargo:rustc-link-lib=dylib=c++abi");
println!("cargo:rustc-link-lib=dylib=c++");

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();
Expand Down
Loading