Skip to content

Commit

Permalink
Merge pull request #1069 from bsilver8192/link-order-note
Browse files Browse the repository at this point in the history
Add a note about linking order
  • Loading branch information
dtolnay committed Oct 11, 2023
2 parents a6ca025 + f2fa8bd commit 32c22ab
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions book/src/build/other.md
Expand Up @@ -48,6 +48,12 @@ When linking a binary which contains mixed Rust and C++ code, you will have to
choose between using the Rust toolchain (`rustc`) or the C++ toolchain which you
may already have extensively tuned.

The generated C++ code and the Rust code generated by the procedural macro both
depend on each other. Simple examples may only require one or the other, but in
general your linking will need to handle both directions. For some linkers, such
as llvm-ld, this is not a problem at all. For others, such as GNU ld, flags like
`--start-lib`/`--end-lib` may help.

Rust does not generate simple standalone `.o` files, so you can't just throw the
Rust-generated code into your existing C++ toolchain linker. Instead you need to
choose one of these options:
Expand Down

0 comments on commit 32c22ab

Please sign in to comment.