Skip to content

Commit c009a41

Browse files
thewildtreelu-zero
authored andcommitted
Fix wrong dylib install name on macOS
Fixes #532 As mentioned in the issue above, the file would be installed in the correct dir, but its embedded install name would be missing the last subdirectory.
1 parent 67b9d25 commit c009a41

2 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -923,10 +923,11 @@ fn compile_with_exec(
923923
let capi_config = load_manifest_capi_config(pkg, rustc_target)?;
924924
let name = &capi_config.library.name;
925925
let install_paths = InstallPaths::new(name, rustc_target, args, &capi_config);
926+
let install_path_lib = install_paths.lib_install_dir(&capi_config);
926927
let pkg_rustflags = &capi_config.library.rustflags;
927928

928929
let mut leaf_args: Vec<String> = rustc_target
929-
.shared_object_link_args(&capi_config, &install_paths.libdir, root_output)
930+
.shared_object_link_args(&capi_config, &install_path_lib, root_output)
930931
.into_iter()
931932
.flat_map(|l| ["-C".to_string(), format!("link-arg={l}")])
932933
.collect();

src/install.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,9 @@ pub fn cinstall(ws: &Workspace, packages: &[CPackage]) -> anyhow::Result<()> {
201201

202202
let destdir = &paths.destdir;
203203

204-
let mut install_path_lib = paths.libdir.clone();
205-
if let Some(subdir) = &capi_config.library.install_subdir {
206-
install_path_lib.push(subdir);
207-
}
208-
209204
let install_path_bin = append_to_destdir(destdir.as_deref(), &paths.bindir);
210-
let install_path_lib = append_to_destdir(destdir.as_deref(), &install_path_lib);
205+
let install_path_lib =
206+
append_to_destdir(destdir.as_deref(), &paths.lib_install_dir(capi_config));
211207
let install_path_pc = append_to_destdir(destdir.as_deref(), &paths.pkgconfigdir);
212208
let install_path_include = append_to_destdir(destdir.as_deref(), &paths.includedir);
213209
let install_path_data = append_to_destdir(destdir.as_deref(), &paths.datadir);
@@ -357,6 +353,15 @@ fn get_path_or(args: &ArgMatches, id: &str, f: impl FnOnce() -> PathBuf) -> Path
357353
}
358354

359355
impl InstallPaths {
356+
pub fn lib_install_dir(&self, capi_config: &CApiConfig) -> PathBuf {
357+
let mut lib_install_dir = self.libdir.clone();
358+
if let Some(subdir) = &capi_config.library.install_subdir {
359+
lib_install_dir.push(subdir);
360+
}
361+
362+
lib_install_dir
363+
}
364+
360365
pub fn new(
361366
_name: &str,
362367
rustc_target: &Target,

0 commit comments

Comments
 (0)