Skip to content

Conversation

@afbjorklund
Copy link
Contributor

The install_name is supposed to be an absolute path, and use the soname rather than the developer symlink.

Avoids using DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib. Homebrew changes the install_name downstream, in /opt.

The default is the absolute path of the build directory (not wanted)

Typical error: dyld[36629]: Library not loaded: libkrun-efi.dylib

The install_name is supposed to be an absolute path,
and use the soname rather than the developer symlink.

Avoids using DYLD_FALLBACK_LIBRARY_PATH=/usr/local/lib
Homebrew changes the install_name downstream, in /opt.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Copy link
Collaborator

@slp slp left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I think that we should fix this the same way we did in Linux, by using rustc-cdylib-link-arg to pass -install_name, -current_version, and -compatibility_version.

@afbjorklund
Copy link
Contributor Author

Added the linker flags. We still need to rename and relocate the library, though.

#[cfg(target_os = "macos")]
println!(
"cargo:rustc-cdylib-link-arg=-Wl,-install_name,libkrun.{}.dylib,-compatibility_version,1.0.0,-current_version,{}.0.0",
std::env::var("CARGO_PKG_VERSION_MAJOR").unwrap(), std::env::var("CARGO_PKG_VERSION_MINOR").unwrap()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Reading ld's manual, I'd say compatibility_version should be MAJOR.0.0, and current_version MAJOR.MINOR.RELEASE.

Signed-off-by: Anders F Björklund <anders.f.bjorklund@gmail.com>
Copy link
Collaborator

@slp slp left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@slp slp merged commit e1bb605 into containers:main Jun 20, 2025
6 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.

3 participants