obraunsdorf
obraunsdorf

Reputation: 61

LLVM debug output through rust

I am looking for a way to read the LLVM debug output by invoking the rust compiler (through cargo). I am especially interested in output of LLVMs ASAN.

To run a build with ASAN I can do:

cargo clean && RUSTFLAGS="-Zsanitizer=address" cargo build

but I don't know the command to get the debug log ouput.

With clang I think one can add

-mllvm -debug-only=asan

as compiler-flag.

How can I supply something like this flag through rustc?

I am using the current rust source (https://github.com/rust-lang/rust/ commit 31f5d69) to build rustc myself.

Upvotes: 0

Views: 653

Answers (1)

obraunsdorf
obraunsdorf

Reputation: 61

The equivalent compiler argument for rustc is

-C llvm-args=-debug-only=<LLVM DEBUG_TYPE>

The -C part gives access to the options for code generation of rust.

The llvm-args part tells rustc to forward every subsequent flag to LLVM. If I understand correctly, you can specify every LLVM option that is evaluated with cl::opt() in LLVM source code.

So the full command to build a rust application with ASAN and see only the log output of ASAN would be:

cargo clean && RUSTFLAGS="-C llvm-args=-debug-only=asan -Zsanitizer=address" cargo build

Side note: I think debug mode for LLVM must be enabled in config.toml when building rust to see the respective log output.

Upvotes: 1

Related Questions