How to stop rustc from merging static libs?


Imagine the situation: static library libR.a is written rust and it depends on libCXX0.a. Binary X depends on both libR.a and libCXX0.a and it is written in C++. Now we want to try clang++ X.o libR.a libCXX0.a -o X. Well, this will result in multiple definition because rustc is very happy to package all the objects referenced in libCXX0.a into libR.a. libR.a, libCXX0.a, and X can be written in separate projects; therefore, it is not handy for X's maintainers to customize libR.a's linkage.

An easy way to resolve this is to let rustc stop merging static archives just like common compilers. Is there any existing switch to control this behavior?

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.