Skip to content

Commit 23601a6

Browse files
committed
Simplify trim-paths feature by merging all debuginfo options together
1 parent aa029ce commit 23601a6

File tree

8 files changed

+17
-70
lines changed

8 files changed

+17
-70
lines changed

compiler/rustc_codegen_llvm/src/back/write.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,12 @@ pub fn target_machine_factory(
257257
};
258258
let debuginfo_compression = SmallCStr::new(&debuginfo_compression);
259259

260-
let should_prefer_remapped_for_split_debuginfo_paths =
261-
sess.should_prefer_remapped_for_split_debuginfo_paths();
260+
let should_prefer_remapped_paths = sess.should_prefer_remapped_for_codegen();
262261

263262
Arc::new(move |config: TargetMachineFactoryConfig| {
264263
let path_to_cstring_helper = |path: Option<PathBuf>| -> CString {
265264
let path = path.unwrap_or_default();
266-
let path = if should_prefer_remapped_for_split_debuginfo_paths {
265+
let path = if should_prefer_remapped_paths {
267266
path_mapping.map_prefix(path).0
268267
} else {
269268
path.into()

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
874874
)
875875
// We get a path relative to the working directory from split_dwarf_path
876876
.map(|f| {
877-
if tcx.sess.should_prefer_remapped_for_split_debuginfo_paths() {
877+
if tcx.sess.should_prefer_remapped_for_codegen() {
878878
tcx.sess.source_map().path_mapping().map_prefix(f).0
879879
} else {
880880
f.into()

compiler/rustc_session/src/config.rs

+6-16
Original file line numberDiff line numberDiff line change
@@ -1000,22 +1000,12 @@ bitflags::bitflags! {
10001000
const MACRO = 1 << 0;
10011001
/// Apply remappings to printed compiler diagnostics
10021002
const DIAGNOSTICS = 1 << 1;
1003-
/// Apply remappings to debug information only when they are written to
1004-
/// compiled executables or libraries, but not when they are in split
1005-
/// debuginfo files
1006-
const UNSPLIT_DEBUGINFO = 1 << 2;
1007-
/// Apply remappings to debug information only when they are written to
1008-
/// split debug information files, but not in compiled executables or
1009-
/// libraries
1010-
const SPLIT_DEBUGINFO = 1 << 3;
1011-
/// Apply remappings to the paths pointing to split debug information
1012-
/// files. Does nothing when these files are not generated.
1013-
const SPLIT_DEBUGINFO_PATH = 1 << 4;
1014-
1015-
/// An alias for macro,unsplit-debuginfo,split-debuginfo-path. This
1016-
/// ensures all paths in compiled executables or libraries are remapped
1017-
/// but not elsewhere.
1018-
const OBJECT = Self::MACRO.bits() | Self::UNSPLIT_DEBUGINFO.bits() | Self::SPLIT_DEBUGINFO_PATH.bits();
1003+
/// Apply remappings to debug informations
1004+
const DEBUGINFO = 1 << 3;
1005+
1006+
/// An alias for macro,debuginfo-path. This ensures all paths in compiled
1007+
/// executables or libraries are remapped but not elsewhere.
1008+
const OBJECT = Self::MACRO.bits() | Self::DEBUGINFO.bits();
10191009
}
10201010
}
10211011

compiler/rustc_session/src/options.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,8 @@ mod desc {
432432
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
433433
pub const parse_proc_macro_execution_strategy: &str =
434434
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
435-
pub const parse_remap_path_scope: &str = "comma separated list of scopes: `macro`, `diagnostics`, `unsplit-debuginfo`, `split-debuginfo`, `split-debuginfo-path`, `object`, `all`";
435+
pub const parse_remap_path_scope: &str =
436+
"comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`";
436437
pub const parse_inlining_threshold: &str =
437438
"either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
438439
pub const parse_llvm_module_flag: &str = "<key>:<type>:<value>:<behavior>. Type must currently be `u32`. Behavior should be one of (`error`, `warning`, `require`, `override`, `append`, `appendunique`, `max`, `min`)";
@@ -1142,9 +1143,7 @@ mod parse {
11421143
*slot |= match s {
11431144
"macro" => RemapPathScopeComponents::MACRO,
11441145
"diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
1145-
"unsplit-debuginfo" => RemapPathScopeComponents::UNSPLIT_DEBUGINFO,
1146-
"split-debuginfo" => RemapPathScopeComponents::SPLIT_DEBUGINFO,
1147-
"split-debuginfo-path" => RemapPathScopeComponents::SPLIT_DEBUGINFO_PATH,
1146+
"debuginfo" => RemapPathScopeComponents::DEBUGINFO,
11481147
"object" => RemapPathScopeComponents::OBJECT,
11491148
"all" => RemapPathScopeComponents::all(),
11501149
_ => return false,

compiler/rustc_session/src/session.rs

+1-31
Original file line numberDiff line numberDiff line change
@@ -899,37 +899,7 @@ impl Session {
899899
}
900900

901901
pub fn should_prefer_remapped_for_codegen(&self) -> bool {
902-
let has_split_debuginfo = match self.split_debuginfo() {
903-
SplitDebuginfo::Off => false,
904-
SplitDebuginfo::Packed => true,
905-
SplitDebuginfo::Unpacked => true,
906-
};
907-
908-
let remap_path_scopes = &self.opts.unstable_opts.remap_path_scope;
909-
let mut prefer_remapped = false;
910-
911-
if remap_path_scopes.contains(RemapPathScopeComponents::UNSPLIT_DEBUGINFO) {
912-
prefer_remapped |= !has_split_debuginfo;
913-
}
914-
915-
if remap_path_scopes.contains(RemapPathScopeComponents::SPLIT_DEBUGINFO) {
916-
prefer_remapped |= has_split_debuginfo;
917-
}
918-
919-
prefer_remapped
920-
}
921-
922-
pub fn should_prefer_remapped_for_split_debuginfo_paths(&self) -> bool {
923-
let has_split_debuginfo = match self.split_debuginfo() {
924-
SplitDebuginfo::Off => false,
925-
SplitDebuginfo::Packed | SplitDebuginfo::Unpacked => true,
926-
};
927-
928-
self.opts
929-
.unstable_opts
930-
.remap_path_scope
931-
.contains(RemapPathScopeComponents::SPLIT_DEBUGINFO_PATH)
932-
&& has_split_debuginfo
902+
self.opts.unstable_opts.remap_path_scope.contains(RemapPathScopeComponents::DEBUGINFO)
933903
}
934904
}
935905

src/doc/unstable-book/src/compiler-flags/remap-path-scope.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ This flag accepts a comma-separated list of values and may be specified multiple
1010

1111
- `macro` - apply remappings to the expansion of `std::file!()` macro. This is where paths in embedded panic messages come from
1212
- `diagnostics` - apply remappings to printed compiler diagnostics
13-
- `unsplit-debuginfo` - apply remappings to debug information only when they are written to compiled executables or libraries, but not when they are in split debuginfo files
14-
- `split-debuginfo` - apply remappings to debug information only when they are written to split debug information files, but not in compiled executables or libraries
15-
- `split-debuginfo-path` - apply remappings to the paths pointing to split debug information files. Does nothing when these files are not generated.
16-
- `object` - an alias for `macro,unsplit-debuginfo,split-debuginfo-path`. This ensures all paths in compiled executables or libraries are remapped, but not elsewhere.
13+
- `debuginfo` - apply remappings to debug informations
14+
- `object` - an alias for `macro,debuginfo`. This ensures all paths in compiled executables or libraries are remapped, but not elsewhere.
1715
- `all` and `true` - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
1816

1917
## Example

tests/run-make/remap-path-prefix/Makefile

-9
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,3 @@ remap-with-scope:
2828
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics,object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
2929
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
3030
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
31-
32-
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=split-debuginfo $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
33-
! grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
34-
grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
35-
36-
# FIXME: We should test the split debuginfo files, but we don't currently a good infra for that
37-
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=split-debuginfo -Zunstable-options -Csplit-debuginfo=packed --crate-type=lib --emit=metadata auxiliary/lib.rs
38-
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
39-
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1

tests/run-make/split-debuginfo/Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ packed-remapped-single:
142142
packed-remapped-scope:
143143
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
144144
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
145-
-Z remap-path-scope=split-debuginfo-path foo.rs -g
145+
-Z remap-path-scope=debuginfo foo.rs -g
146146
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
147147
ls $(TMPDIR)/*.o && exit 1 || exit 0
148148
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
@@ -298,7 +298,7 @@ unpacked-remapped-single:
298298
unpacked-remapped-scope:
299299
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
300300
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
301-
-Z remap-path-scope=split-debuginfo-path foo.rs -g
301+
-Z remap-path-scope=debuginfo foo.rs -g
302302
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
303303
rm $(TMPDIR)/*.o
304304
ls $(TMPDIR)/*.dwo && exit 1 || exit 0

0 commit comments

Comments
 (0)