I'm trying to get a single LLVM IR file from compiler-builtins:
RUSTFLAGS='-C codegen-units=1' rustc +local -C codegen-units=1 --crate-name compiler_builtins /Users/shep/.cargo/registry/src/github.com-1ecc6299db9ec823/compiler_builtins-0.1.32/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=llvm-ir -C opt-level=z -Clinker-plugin-lto -C debuginfo=2 --cfg 'feature="compiler-builtins"' --cfg 'feature="core"' --cfg 'feature="default"' --cfg 'feature="rustc-dep-of-std"' -C metadata=b55ef319712ad5b4 -C extra-filename=-b55ef319712ad5b4 --out-dir /Users/shep/Projects/arduino-blink/target/avr-atmega328p-new/release/deps --target /Users/shep/Projects/arduino-blink/avr-atmega328p-new.json -Zforce-unstable-if-unmarked -L dependency=/Users/shep/Projects/arduino-blink/target/avr-atmega328p-new/release/deps -L dependency=/Users/shep/Projects/arduino-blink/target/release/deps --extern core=/Users/shep/Projects/arduino-blink/target/avr-atmega328p-new/release/deps/librustc_std_workspace_core-2751de715382db4b.rmeta --cap-lints allow --cfg 'feature="unstable"' -C codegen-units=1
However, I still have many files:
% ls ./target/avr-atmega328p-new/release/deps/compiler_builtins-b55ef319712ad5b4.compiler_builtins.45srv8bc-cgu.*ll | wc 116 116 13694
What am I missing?
see https://github.com/rust-lang/rust/pull/73136 as well
@simulacrum am I reading the current code correctly — the compiler hard codes the CGU amount for a crate with the name compiler-builtins?
you mean before or after that PR?
The new code would only affect the rustc build process, so I see how that shouldn’t affect me.
Before (“current” IMO since the pr hasn’t been merged)
I think no, it uses the
#![compiler_builtins] attribute IIRC
I also have the related question of how would I get the “infinite CGU setting” when I’m compiling compiler built-ins myself for my own third tier target
on current master? I'm not sure you can without modifying the crate
and maybe not possible at all
yeah so is_compiler_builtins returns true if the crate has a crate-level
Sorry, I’m not being clear. After this PR lands, the rust build system will set a very large CGU setting for that one crate, regardless of the passed-in value, correct?
passed-in by who?
Now, switch to my embedded use case. I use Cargo to build my crate and libcore and whatever.
I’m not using the rust build system.
How do I get “infinite CGU” for that crate when I don’t want it for other crates?
you basically have to do the same rustc wrapper trick rustbuild does I think
note though that afaict this may not really be necessary for more esoteric systems where you don't need to worry about symbol conflicts
(e.g. if you're "pure rust" then you almost certainly don't need to care about CGU count AFAICT)
That was going to be my next question, thank you :sweat_smile:
So, for today, I can just steal the deletion from that PR and rebuild Rust.
Then the compiler won’t set CGU behind my back.
yes, that's probably the way to go