Skip to content

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

Merged
hlopko merged 4 commits intobazelbuild:mainfrom
durin42:ccinfo
Feb 25, 2021
Merged

rules_rust: make it possible to use non-staticlib rust_library targets in c++ deps#603
hlopko merged 4 commits intobazelbuild:mainfrom
durin42:ccinfo

Conversation

@durin42
Copy link
Copy Markdown
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
Comment thread rust/private/rustc.bzl
Comment thread rust/private/rustc.bzl
Comment thread rust/private/rustc.bzl
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.

4 participants