Auto merge of #115120 - icedrocket:ignore-strip-on-msvc, r=michaelwoerister
Ignore `-C strip` on MSVC tl;dr - Define `-Cstrip` to only ever affect the binary; no other build artifacts. This is necessary to improve cross-platform behavior consistency: if someone wanted debug information to be contained only in separate files on all platforms, they would set `-Cstrip=symbols` and `-Csplit-debuginfo=packed`, but this would result in no PDB files on MSVC. Resolves #114215
This commit is contained in:
commit
7f2fc33da6
4 changed files with 100 additions and 54 deletions
26
tests/ui/debuginfo/msvc-strip-debuginfo.rs
Normal file
26
tests/ui/debuginfo/msvc-strip-debuginfo.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//@ compile-flags: -C strip=debuginfo
|
||||
//@ only-msvc
|
||||
//@ run-pass
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
pub fn is_related_pdb<P: AsRef<Path>>(path: &P, exe: &P) -> bool {
|
||||
let (exe, path) = (exe.as_ref(), path.as_ref());
|
||||
|
||||
path.extension()
|
||||
.map(|x| x.to_ascii_lowercase())
|
||||
.is_some_and(|x| x == "pdb")
|
||||
&& path.file_stem() == exe.file_stem()
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let curr_exe = std::env::current_exe().unwrap();
|
||||
let curr_dir = curr_exe.parent().unwrap();
|
||||
|
||||
let entries = std::fs::read_dir(curr_dir).unwrap();
|
||||
|
||||
assert!(entries
|
||||
.map_while(|x| x.ok())
|
||||
.find(|x| is_related_pdb(&x.path(), &curr_exe))
|
||||
.is_some());
|
||||
}
|
||||
26
tests/ui/debuginfo/msvc-strip-symbols.rs
Normal file
26
tests/ui/debuginfo/msvc-strip-symbols.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
//@ compile-flags: -C strip=symbols
|
||||
//@ only-msvc
|
||||
//@ run-pass
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
pub fn is_related_pdb<P: AsRef<Path>>(path: &P, exe: &P) -> bool {
|
||||
let (exe, path) = (exe.as_ref(), path.as_ref());
|
||||
|
||||
path.extension()
|
||||
.map(|x| x.to_ascii_lowercase())
|
||||
.is_some_and(|x| x == "pdb")
|
||||
&& path.file_stem() == exe.file_stem()
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
let curr_exe = std::env::current_exe().unwrap();
|
||||
let curr_dir = curr_exe.parent().unwrap();
|
||||
|
||||
let entries = std::fs::read_dir(curr_dir).unwrap();
|
||||
|
||||
assert!(entries
|
||||
.map_while(|x| x.ok())
|
||||
.find(|x| is_related_pdb(&x.path(), &curr_exe))
|
||||
.is_some());
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue