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

Using rustc as the linker driver for mixed C++/Rust binaries #83282

Closed
hlopko opened this issue Mar 18, 2021 · 3 comments
Closed

Using rustc as the linker driver for mixed C++/Rust binaries #83282

hlopko opened this issue Mar 18, 2021 · 3 comments

Comments

@hlopko
Copy link
Contributor

hlopko commented Mar 18, 2021

This is an opening of a very likely very short design discussion for #81490.

Hi @petrochenkov, thanks so much for pushing for this! I just filed bazelbuild/rules_rust#637 to document what and why we need to be able to link mixed C++/Rust binaries with rustc as the linker driver. I believe what you propose will solve all our problems, but just to be sure I'd like to reiterate:

  • we'd like to control bundling (whether or not a library is wrapped in --whole-archive/--no-whole-archive
  • we'd like to be able to pass --start-lib/--end-lib with object files instead of a static archive. I believe we will be able to do that using --codegen=link-arg after the proposed change to keep relative order of -l: flags and --codegen=link-arg respected
  • we'd like to pass libraries verbatim

My questions:

  1. Do all 3 points make sense to you and do you agree that native_link_modifiers aim to solve them?
  2. Do you have a timeline in which this could be implemented? Do you seek contributions for this effort?

Thank you!

@petrochenkov
Copy link
Contributor

petrochenkov commented Mar 18, 2021

Hi.

Do all 3 points make sense to you and do you agree that native_link_modifiers aim to solve them?

Yes, all 3 points make sense to me and they (together with static-nobundle) are the main reasons why the RFC was written.

Do you have a timeline in which this could be implemented?

Implementation effort required to support all the parts of the RFC is relatively small, or at least not large.
Someone just needs to focus on it and do the work, I've been unable to do that in the recent months due to other tasks.

Do you seek contributions for this effort?

Yes!
Submitting a PR with some working prototype would be enough for a start, I'll be able to review and give feedback on it after that.
The work can clearly be split into orthogonal parts, which may be easier for both implementation and review.

  • Preserving relative order of -l and -Clink-arg(s).
  • Supporting the modifier syntax at command line.
  • Supporting the modifier syntax in attributes.
  • Supporting specific modifiers, all can be done independently.

For each item I can provide a starting point to read-understand-modify the code from, if necessary.

@petrochenkov
Copy link
Contributor

Implementation is started in #83507.

@hlopko
Copy link
Contributor Author

hlopko commented Mar 29, 2021

Oh great! Thank you so much!

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

No branches or pull requests

2 participants