diff options
| author | bors <bors@rust-lang.org> | 2024-04-22 12:05:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-04-22 12:05:39 +0000 |
| commit | 7f2fc33da6633f5a764ddc263c769b6b2873d167 (patch) | |
| tree | 728abf2769d6560a625952183307b22ae709961e /tests/ui/debuginfo | |
| parent | 290d792411566c94273e5d1a980a1ab91f1d950b (diff) | |
| parent | e82f46ab7226b69b29d5265c94647eeb5ca1e278 (diff) | |
| download | rust-7f2fc33da6633f5a764ddc263c769b6b2873d167.tar.gz rust-7f2fc33da6633f5a764ddc263c769b6b2873d167.zip | |
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
Diffstat (limited to 'tests/ui/debuginfo')
| -rw-r--r-- | tests/ui/debuginfo/msvc-strip-debuginfo.rs | 26 | ||||
| -rw-r--r-- | tests/ui/debuginfo/msvc-strip-symbols.rs | 26 |
2 files changed, 52 insertions, 0 deletions
diff --git a/tests/ui/debuginfo/msvc-strip-debuginfo.rs b/tests/ui/debuginfo/msvc-strip-debuginfo.rs new file mode 100644 index 00000000000..d5f516eefe2 --- /dev/null +++ b/tests/ui/debuginfo/msvc-strip-debuginfo.rs @@ -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()); +} diff --git a/tests/ui/debuginfo/msvc-strip-symbols.rs b/tests/ui/debuginfo/msvc-strip-symbols.rs new file mode 100644 index 00000000000..198c9496cb4 --- /dev/null +++ b/tests/ui/debuginfo/msvc-strip-symbols.rs @@ -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()); +} |
