How to build a monolithic rlib?

I see libstd.rlib is shipped monolithically (not sure whether it's the right word) on my x86_64 laptop. It only contains a .rmeta file and a single .o file (which is presumably generated by partial linking or incremental linking). I wonder whether this can be done for a normal rlib built from user's code.

I find that some code is omitted even with -C link-dead-code. I'm thinking maybe if my rlibs were all monolithic, link-dead-code would work as I expected so that I can find all symbol definitions in my final executable.

That's due to -C codegen-units=1, which you can also set in Cargo profiles.

1 Like

Thank you so much! This is super helpful!

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.