bh1xuw / rust-rocks

Make RocksDB really rocks! The Rust style API.
Apache License 2.0
46 stars 7 forks source link

Link with circular reference among 2 crates under Linux in Rust? #13

Closed bh1xuw closed 4 years ago

bh1xuw commented 4 years ago

This issue is to track how to solve circular reference link error under Linux.

MacOS(llvm-lld) is OK to handle the circular references while linking.

GCC reuqire that you put the object files and libraries in the order that they depend on each other.

ld accepts the following options:

-( archives -)
--start-group archives --end-group

The specified archives are searched repeatedly until no new undefined references are created.

Yet, rust won't wrap user-defined in repeated search group.

Option 1

Use lld under Linux:

RUSTFLAGS="-C link-arg=-fuse-ld=lld" cargo test

Option 2

Use shell wrapper: #12

bh1xuw commented 4 years ago

lld works. never mind.