When I unpack a .a file generated for a staticlib I get lots of rcgu files with the same name, things like
blah-cgu.15.rcgu.o. What do "cgu" and "rcgu" here mean? I'm guessing cgu stands for "code gen unit" but I'm not sure.
Yes, cgu is "code gen unit". rcgu is "rust code gen unit".
Thanks. I thought a crate is a single compilation for rustc, is this not correct anymore? Why and how does rustc split a crate into multiple compilation units?
A crate is split into multiple codegen units just before codegen so multiple codegen units can be optimized in parallel. You can the control amount using
Thanks! By "codegen" do you mean when generating LLVM modules of even before that? (maybe when generating MIR?) I just started passing
-Ccodege-units to core, std, compiler_builtins and the main crate and it's much easier to find symbols I'm looking for now.
"codegen" is generating and optimizing LLVM modules.
So MIR optimizations applied to the whole crate, right?
MIR optimizations normally look at a single MIR body at a time. Only MIR inlining looks at multiple MIR bodies at a time, but even in that case it can only change a single MIR body at a time and it needs a hackish scheme to prevent cycle errors, as it looks at the already optimized MIR of callees.
MIR optimizations are per-function, but this can require pulling info from the rest of the crate or even other crates
since MIR opts can trigger e.g. const eval, which itself can require the MIR for some const fns, there is a dependency tree here, but as bjorn3 said, only in inlining do you get cycle errors that are problematic. All other cycle errors that you get are legitly cycles in your code
oh so there are no full-program mir opts?
full-program mir opts don't go very well with the query system.