japaric / cargo-call-stack

Whole program static stack analysis
Apache License 2.0
579 stars 52 forks source link

Analyze stack usage of `compiler_builtins` #41

Closed jonas-schievink closed 3 years ago

jonas-schievink commented 3 years ago

This removes the hardcoded "ad-hoc" stack information for compiler_builtins, and instead obtains the actual stack usage by building compiler_builtins from source via -Zbuild-std.

Because setting RUSTFLAGS for passing arguments to rustc for use by -Zbuild-std would interfere with flags set in .cargo/config, we now use cargo-call-stack as a rustc wrapper and inject -Zemit-stack-usage there. Additionally, we use the wrapper to determine the location of the compiler_builtins.rlib in use (Cargo does not include sysroot crates in cargo metadata, even when passing -Zbuild-std, so we don't have other reliable ways of finding that path). This is reported to the parent cargo call-stack invocation by printing it to stderr and prefixing it with a marker string.