How do I compile Rust code without linking, i.e. produce object files?

Viewed 1629

Due to how the LGPL works, compiling Rust code to an object file without linking would be useful to be able to do. However, I cannot find any documentation on how to do this. I checked rustc's help section and searched, but couldn't find anything, which brings me to my question: How do I tell rustc to not link and produce object files that later can be linked?

1 Answers

Use the compiler flag --emit=obj.

cargo rustc -- --emit=obj

The compiled object files will be sitting in target/debug/deps.

See also:

Related