Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set a more reasonable LC_ID_DYLIB entry on macOS #433

Merged
merged 1 commit into from
Feb 24, 2021
Merged
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
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

* Change manylinux default version based on target arch by messense in [#424](https://github.com/PyO3/maturin/pull/424)
* Support local path dependencies in source distribution (i.e. you can now package a workspace into an sdist)
* Set a more reasonable LC_ID_DYLIB entry on macOS by messense [#433](https://github.com/PyO3/maturin/pull/433)

## 0.9.4 - 2021-02-18

Expand Down
22 changes: 21 additions & 1 deletion src/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,30 @@ fn compile_target(
}
}

let module_name = &context.module_name;
let so_filename = match python_interpreter {
Some(python_interpreter) => python_interpreter.get_library_name(module_name),
// abi3
None => {
format!("{base}.abi3.so", base = module_name)
}
};
// Change LC_ID_DYLIB to the finaly .so name for macOS targets to avoid linking with
// non-existent library.
// See https://github.com/PyO3/setuptools-rust/issues/106 for detail
let macos_dylib_install_name = format!("link-args=-Wl,-install_name,@rpath/{}", so_filename);
messense marked this conversation as resolved.
Show resolved Hide resolved

// https://github.com/PyO3/pyo3/issues/88#issuecomment-337744403
if context.target.is_macos() {
if let BridgeModel::Bindings(_) | BridgeModel::BindingsAbi3(_, _) = bindings_crate {
let mac_args = &["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"];
let mac_args = &[
"-C",
"link-arg=-undefined",
"-C",
"link-arg=dynamic_lookup",
"-C",
&macos_dylib_install_name,
];
rustc_args.extend(mac_args);
}
}
Expand Down