fix: pass -undefined dynamic_lookup via CARGO_ENCODED_RUSTFLAGS on macOS#3083
Merged
fix: pass -undefined dynamic_lookup via CARGO_ENCODED_RUSTFLAGS on macOS#3083
-undefined dynamic_lookup via CARGO_ENCODED_RUSTFLAGS on macOS#3083Conversation
…n macOS Pass `-C link-arg=-undefined` and `-C link-arg=dynamic_lookup` via `CARGO_ENCODED_RUSTFLAGS` instead of `cargo rustc` args so they apply to all crates in the dependency graph, not just the top-level crate. This fixes link errors on macOS when a dependency also uses pyo3 with a `cdylib` crate-type target. The `install_name` flag remains in `cargo rustc` args since it is specific to the final output artifact. Closes PyO3#1080
Contributor
There was a problem hiding this comment.
Pull request overview
Adjust macOS PyO3 linking configuration so -undefined dynamic_lookup is applied across the entire dependency graph via CARGO_ENCODED_RUSTFLAGS, while keeping install_name scoped to the final artifact via cargo rustc args (fixing macOS link errors when dependencies also build PyO3 cdylib crates).
Changes:
- Thread
rustflagsinto the macOS PyO3 linker configuration helper. - Add
-C link-arg=-undefinedand-C link-arg=dynamic_lookupviaCARGO_ENCODED_RUSTFLAGS. - Keep
install_nameas acargo rustcargument and improve related debug logging.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pass
-C link-arg=-undefinedand-C link-arg=dynamic_lookupviaCARGO_ENCODED_RUSTFLAGSinstead ofcargo rustcargs so they apply to all crates in the dependency graph, not just the top-level crate.This fixes link errors on macOS when a dependency also uses pyo3 with a
cdylibcrate-type target.The
install_nameflag remains incargo rustcargs since it is specific to the final output artifact.Closes #1080