Skip to content

Commit 777c6b4

Browse files
committed
Simplify trim-paths feature by merging all debuginfo options together
1 parent c5e7f45 commit 777c6b4

File tree

8 files changed

+18
-71
lines changed

8 files changed

+18
-71
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
@@ -875,7 +875,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
875875
)
876876
// We get a path relative to the working directory from split_dwarf_path
877877
.map(|f| {
878-
if tcx.sess.should_prefer_remapped_for_split_debuginfo_paths() {
878+
if tcx.sess.should_prefer_remapped_for_codegen() {
879879
tcx.sess.source_map().path_mapping().map_prefix(f).0
880880
} else {
881881
f.into()

compiler/rustc_session/src/config.rs

+6-16
Original file line numberDiff line numberDiff line change
@@ -990,22 +990,12 @@ bitflags::bitflags! {
990990
const MACRO = 1 << 0;
991991
/// Apply remappings to printed compiler diagnostics
992992
const DIAGNOSTICS = 1 << 1;
993-
/// Apply remappings to debug information only when they are written to
994-
/// compiled executables or libraries, but not when they are in split
995-
/// debuginfo files
996-
const UNSPLIT_DEBUGINFO = 1 << 2;
997-
/// Apply remappings to debug information only when they are written to
998-
/// split debug information files, but not in compiled executables or
999-
/// libraries
1000-
const SPLIT_DEBUGINFO = 1 << 3;
1001-
/// Apply remappings to the paths pointing to split debug information
1002-
/// files. Does nothing when these files are not generated.
1003-
const SPLIT_DEBUGINFO_PATH = 1 << 4;
1004-
1005-
/// An alias for macro,unsplit-debuginfo,split-debuginfo-path. This
1006-
/// ensures all paths in compiled executables or libraries are remapped
1007-
/// but not elsewhere.
1008-
const OBJECT = Self::MACRO.bits() | Self::UNSPLIT_DEBUGINFO.bits() | Self::SPLIT_DEBUGINFO_PATH.bits();
993+
/// Apply remappings to debug informations
994+
const DEBUGINFO = 1 << 3;
995+
996+
/// An alias for `macro` and `debuginfo`. This ensures all paths in compiled
997+
/// executables or libraries are remapped but not elsewhere.
998+
const OBJECT = Self::MACRO.bits() | Self::DEBUGINFO.bits();
1009999
}
10101000
}
10111001

compiler/rustc_session/src/options.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ mod desc {
433433
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
434434
pub const parse_proc_macro_execution_strategy: &str =
435435
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
436-
pub const parse_remap_path_scope: &str = "comma separated list of scopes: `macro`, `diagnostics`, `unsplit-debuginfo`, `split-debuginfo`, `split-debuginfo-path`, `object`, `all`";
436+
pub const parse_remap_path_scope: &str =
437+
"comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`";
437438
pub const parse_inlining_threshold: &str =
438439
"either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
439440
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`)";
@@ -1156,9 +1157,7 @@ mod parse {
11561157
*slot |= match s {
11571158
"macro" => RemapPathScopeComponents::MACRO,
11581159
"diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
1159-
"unsplit-debuginfo" => RemapPathScopeComponents::UNSPLIT_DEBUGINFO,
1160-
"split-debuginfo" => RemapPathScopeComponents::SPLIT_DEBUGINFO,
1161-
"split-debuginfo-path" => RemapPathScopeComponents::SPLIT_DEBUGINFO_PATH,
1160+
"debuginfo" => RemapPathScopeComponents::DEBUGINFO,
11621161
"object" => RemapPathScopeComponents::OBJECT,
11631162
"all" => RemapPathScopeComponents::all(),
11641163
_ => return false,

compiler/rustc_session/src/session.rs

+1-31
Original file line numberDiff line numberDiff line change
@@ -887,37 +887,7 @@ impl Session {
887887
}
888888

889889
pub fn should_prefer_remapped_for_codegen(&self) -> bool {
890-
let has_split_debuginfo = match self.split_debuginfo() {
891-
SplitDebuginfo::Off => false,
892-
SplitDebuginfo::Packed => true,
893-
SplitDebuginfo::Unpacked => true,
894-
};
895-
896-
let remap_path_scopes = &self.opts.unstable_opts.remap_path_scope;
897-
let mut prefer_remapped = false;
898-
899-
if remap_path_scopes.contains(RemapPathScopeComponents::UNSPLIT_DEBUGINFO) {
900-
prefer_remapped |= !has_split_debuginfo;
901-
}
902-
903-
if remap_path_scopes.contains(RemapPathScopeComponents::SPLIT_DEBUGINFO) {
904-
prefer_remapped |= has_split_debuginfo;
905-
}
906-
907-
prefer_remapped
908-
}
909-
910-
pub fn should_prefer_remapped_for_split_debuginfo_paths(&self) -> bool {
911-
let has_split_debuginfo = match self.split_debuginfo() {
912-
SplitDebuginfo::Off => false,
913-
SplitDebuginfo::Packed | SplitDebuginfo::Unpacked => true,
914-
};
915-
916-
self.opts
917-
.unstable_opts
918-
.remap_path_scope
919-
.contains(RemapPathScopeComponents::SPLIT_DEBUGINFO_PATH)
920-
&& has_split_debuginfo
890+
self.opts.unstable_opts.remap_path_scope.contains(RemapPathScopeComponents::DEBUGINFO)
921891
}
922892
}
923893

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ 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.
17-
- `all` and `true` - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
13+
- `debuginfo` - apply remappings to debug informations
14+
- `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,debuginfo`.
15+
- `all` - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
1816

1917
## Example
2018
```sh

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)