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

rules_rust: make it possible to use non-staticlib rust_library targets in c++ deps #603

Merged
merged 4 commits into from
Feb 25, 2021

Conversation

durin42
Copy link
Contributor

@durin42 durin42 commented Feb 23, 2021

ld can handle .rlib archives, since they're really just standard ar(1)
archives like a .a file with some extra metadata. As a result, we can avoid
using staticlib crates when building mixed C++/Rust binaries.

This doesn't correctly handle libstd et al (yet), or deal with some generated
symbols that rustc produces when it drives the linking step, but it's a start.

@google-cla google-cla bot added the cla: yes label Feb 23, 2021
@hlopko hlopko self-requested a review February 23, 2021 19:05
My editor is configured to clean up trailing whitespace, and I'm tired
of having to back out these changes when I commit.
…s in c++ deps

ld can handle .rlib archives, since they're really just standard ar(1)
archives like a .a file with some extra metadata. As a result, we can avoid
using staticlib crates when building mixed C++/Rust binaries.

This doesn't correctly handle libstd et al (yet), or deal with some generated
symbols that rustc produces when it drives the linking step, but it's a start.
On most platforms the default output from rustc is PIC code[0], so
this should be safe.

0: https://doc.rust-lang.org/rustc/codegen-options/index.html#relocation-model
@hlopko hlopko merged commit a37adb7 into bazelbuild:main Feb 25, 2021
@durin42 durin42 deleted the ccinfo branch January 12, 2022 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants