Auto merge of #113492 - nebulark:pr_96475, r=petrochenkov

Add CL and CMD into to pdb debug info

Partial fix for https://github.com/rust-lang/rust/issues/96475

The Arg0 and CommandLineArgs of the MCTargetOptions cpp class are not set within bb548f9645/compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp (L378)

This causes LLVM to not  neither output any compiler path (cl) nor the arguments that were used when invoking it (cmd) in the PDB file.

This fix adds the missing information to the target machine so LLVM can use it.
This commit is contained in:
bors 2023-09-08 10:06:40 +00:00
commit 9be4eac264
16 changed files with 117 additions and 1 deletions

View file

@ -61,6 +61,7 @@ fn compile(code: String, output: PathBuf, sysroot: PathBuf) {
override_queries: None,
make_codegen_backend: None,
registry: rustc_driver::diagnostics_registry(),
expanded_args: Default::default(),
};
interface::run_compiler(config, |compiler| {

View file

@ -0,0 +1,16 @@
include ../tools.mk
# only-windows-msvc
# tests if the pdb contains the following information in the LF_BUILDINFO:
# 1. the commandline args to compile it (cmd)
# 2. full path to the compiler (cl)
# we just do a stringsearch on the pdb, as these need to show up at least once, as the LF_BUILDINFO is created for each cgu
# actual parsing would be better, but this is a simple and good enough solution for now
all:
$(RUSTC_ORIGINAL) main.rs -g --crate-name my_crate_name --crate-type bin -C metadata=dc9ef878b0a48666 --out-dir $(TMPDIR)
cat '$(TMPDIR)/my_crate_name.pdb' | grep -F '$(RUSTC_ORIGINAL)'
# using a file containing the string so I don't have problems with escaping quotes and spaces
cat '$(TMPDIR)/my_crate_name.pdb' | grep -f 'stringlist.txt'

View file

@ -0,0 +1,2 @@
fn main() {
}

View file

@ -0,0 +1 @@
"main.rs" "-g" "--crate-name" "my_crate_name" "--crate-type" "bin" "-C" "metadata=dc9ef878b0a48666" "--out-dir"