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

Propagate linker args upwards in the dependency graph. #7612

Closed
wants to merge 1 commit into from

Conversation

jeff-davis
Copy link

Suggestion from @froydnj to enable a build script to pass linker args
relevant for dependencies of a crate.

The use case is to allow specifying "-Wl,-undefined,dynamic_lookup" on
MacOS for dynamic library crates with undefined symbols, such as a
symbol defined in the program loading the library.

We can consider supporting this case in rustc itself to avoid the need
for platform-specific flags in typical cdylib cases. But this seems
like an independently-useful mechanism that could enable workaround
for other linking problems, as well.

Enables workaround for #62874

Suggestion from @froydnj to enable a build script to pass linker args
relevant for dependencies of a crate.

The use case is to allow specifying "-Wl,-undefined,dynamic_lookup" on
MacOS for dynamic library crates with undefined symbols, such as a
symbol defined in the program loading the library.

We can consider supporting this case in rustc itself to avoid the need
for platform-specific flags in typical cdylib cases. But this seems
like an independently-useful mechanism that could enable workaround
for other linking problems, as well.

Enables workaround for #62874
@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Eh2406 (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 20, 2019
@jeff-davis
Copy link
Author

@alexcrichton @froydnj

@alexcrichton
Copy link
Member

Thanks for the PR!

I would unfortunately though have similar concerns for this as I would for rust-lang/rust#66204. Linker arguments are really hard, and this is unfortunately likely to cause regressions by changing the behavior of link argument propagation.

I think to fix this we'd likely want to add a new directive for Cargo which specifically requests the transitive propagation of link arguments.

Additionally this will need tests. For example link arguments from proc macros should not be propagated.

@froydnj
Copy link
Contributor

froydnj commented Nov 25, 2019

Alex or somebody else is the right person to handle this.

@jeff-davis
Copy link
Author

Are you really sure this is the right direction? I feel like this is getting more complex and fraught; not less. Even if we make this cargo PR acceptable, it still leaves a potential trap for any developer that doesn't test on MacOS.

@bors
Copy link
Contributor

bors commented Nov 18, 2020

☔ The latest upstream changes (presumably #8441) made this pull request unmergeable. Please resolve the merge conflicts.

Note that reviewers usually do not review pull requests until merge conflicts are resolved! Once you resolve the conflicts, you should change the labels applied by bors to indicate that your PR is ready for review. Post this as a comment to change the labels:

@rustbot modify labels: +S-waiting-on-review -S-waiting-on-author

@ehuss
Copy link
Contributor

ehuss commented Jan 12, 2021

Closing due to inactivity. Larger features like this probably should go through the RFC process to determine what the fundamental use cases and design considerations are.

@ehuss ehuss closed this Jan 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants