Simplify trim-paths feature by merging all debuginfo options together
This commit is contained in:
parent
c5e7f45b62
commit
777c6b46cc
8 changed files with 17 additions and 70 deletions
|
@ -257,13 +257,12 @@ pub fn target_machine_factory(
|
||||||
};
|
};
|
||||||
let debuginfo_compression = SmallCStr::new(&debuginfo_compression);
|
let debuginfo_compression = SmallCStr::new(&debuginfo_compression);
|
||||||
|
|
||||||
let should_prefer_remapped_for_split_debuginfo_paths =
|
let should_prefer_remapped_paths = sess.should_prefer_remapped_for_codegen();
|
||||||
sess.should_prefer_remapped_for_split_debuginfo_paths();
|
|
||||||
|
|
||||||
Arc::new(move |config: TargetMachineFactoryConfig| {
|
Arc::new(move |config: TargetMachineFactoryConfig| {
|
||||||
let path_to_cstring_helper = |path: Option<PathBuf>| -> CString {
|
let path_to_cstring_helper = |path: Option<PathBuf>| -> CString {
|
||||||
let path = path.unwrap_or_default();
|
let path = path.unwrap_or_default();
|
||||||
let path = if should_prefer_remapped_for_split_debuginfo_paths {
|
let path = if should_prefer_remapped_paths {
|
||||||
path_mapping.map_prefix(path).0
|
path_mapping.map_prefix(path).0
|
||||||
} else {
|
} else {
|
||||||
path.into()
|
path.into()
|
||||||
|
|
|
@ -875,7 +875,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
|
||||||
)
|
)
|
||||||
// We get a path relative to the working directory from split_dwarf_path
|
// We get a path relative to the working directory from split_dwarf_path
|
||||||
.map(|f| {
|
.map(|f| {
|
||||||
if tcx.sess.should_prefer_remapped_for_split_debuginfo_paths() {
|
if tcx.sess.should_prefer_remapped_for_codegen() {
|
||||||
tcx.sess.source_map().path_mapping().map_prefix(f).0
|
tcx.sess.source_map().path_mapping().map_prefix(f).0
|
||||||
} else {
|
} else {
|
||||||
f.into()
|
f.into()
|
||||||
|
|
|
@ -990,22 +990,12 @@ bitflags::bitflags! {
|
||||||
const MACRO = 1 << 0;
|
const MACRO = 1 << 0;
|
||||||
/// Apply remappings to printed compiler diagnostics
|
/// Apply remappings to printed compiler diagnostics
|
||||||
const DIAGNOSTICS = 1 << 1;
|
const DIAGNOSTICS = 1 << 1;
|
||||||
/// Apply remappings to debug information only when they are written to
|
/// Apply remappings to debug informations
|
||||||
/// compiled executables or libraries, but not when they are in split
|
const DEBUGINFO = 1 << 3;
|
||||||
/// debuginfo files
|
|
||||||
const UNSPLIT_DEBUGINFO = 1 << 2;
|
|
||||||
/// Apply remappings to debug information only when they are written to
|
|
||||||
/// split debug information files, but not in compiled executables or
|
|
||||||
/// libraries
|
|
||||||
const SPLIT_DEBUGINFO = 1 << 3;
|
|
||||||
/// Apply remappings to the paths pointing to split debug information
|
|
||||||
/// files. Does nothing when these files are not generated.
|
|
||||||
const SPLIT_DEBUGINFO_PATH = 1 << 4;
|
|
||||||
|
|
||||||
/// An alias for macro,unsplit-debuginfo,split-debuginfo-path. This
|
/// An alias for `macro` and `debuginfo`. This ensures all paths in compiled
|
||||||
/// ensures all paths in compiled executables or libraries are remapped
|
/// executables or libraries are remapped but not elsewhere.
|
||||||
/// but not elsewhere.
|
const OBJECT = Self::MACRO.bits() | Self::DEBUGINFO.bits();
|
||||||
const OBJECT = Self::MACRO.bits() | Self::UNSPLIT_DEBUGINFO.bits() | Self::SPLIT_DEBUGINFO_PATH.bits();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -433,7 +433,8 @@ mod desc {
|
||||||
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
|
"a `,` separated combination of `bti`, `b-key`, `pac-ret`, or `leaf`";
|
||||||
pub const parse_proc_macro_execution_strategy: &str =
|
pub const parse_proc_macro_execution_strategy: &str =
|
||||||
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
|
"one of supported execution strategies (`same-thread`, or `cross-thread`)";
|
||||||
pub const parse_remap_path_scope: &str = "comma separated list of scopes: `macro`, `diagnostics`, `unsplit-debuginfo`, `split-debuginfo`, `split-debuginfo-path`, `object`, `all`";
|
pub const parse_remap_path_scope: &str =
|
||||||
|
"comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`";
|
||||||
pub const parse_inlining_threshold: &str =
|
pub const parse_inlining_threshold: &str =
|
||||||
"either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
|
"either a boolean (`yes`, `no`, `on`, `off`, etc), or a non-negative number";
|
||||||
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`)";
|
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 {
|
||||||
*slot |= match s {
|
*slot |= match s {
|
||||||
"macro" => RemapPathScopeComponents::MACRO,
|
"macro" => RemapPathScopeComponents::MACRO,
|
||||||
"diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
|
"diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
|
||||||
"unsplit-debuginfo" => RemapPathScopeComponents::UNSPLIT_DEBUGINFO,
|
"debuginfo" => RemapPathScopeComponents::DEBUGINFO,
|
||||||
"split-debuginfo" => RemapPathScopeComponents::SPLIT_DEBUGINFO,
|
|
||||||
"split-debuginfo-path" => RemapPathScopeComponents::SPLIT_DEBUGINFO_PATH,
|
|
||||||
"object" => RemapPathScopeComponents::OBJECT,
|
"object" => RemapPathScopeComponents::OBJECT,
|
||||||
"all" => RemapPathScopeComponents::all(),
|
"all" => RemapPathScopeComponents::all(),
|
||||||
_ => return false,
|
_ => return false,
|
||||||
|
|
|
@ -887,37 +887,7 @@ impl Session {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn should_prefer_remapped_for_codegen(&self) -> bool {
|
pub fn should_prefer_remapped_for_codegen(&self) -> bool {
|
||||||
let has_split_debuginfo = match self.split_debuginfo() {
|
self.opts.unstable_opts.remap_path_scope.contains(RemapPathScopeComponents::DEBUGINFO)
|
||||||
SplitDebuginfo::Off => false,
|
|
||||||
SplitDebuginfo::Packed => true,
|
|
||||||
SplitDebuginfo::Unpacked => true,
|
|
||||||
};
|
|
||||||
|
|
||||||
let remap_path_scopes = &self.opts.unstable_opts.remap_path_scope;
|
|
||||||
let mut prefer_remapped = false;
|
|
||||||
|
|
||||||
if remap_path_scopes.contains(RemapPathScopeComponents::UNSPLIT_DEBUGINFO) {
|
|
||||||
prefer_remapped |= !has_split_debuginfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
if remap_path_scopes.contains(RemapPathScopeComponents::SPLIT_DEBUGINFO) {
|
|
||||||
prefer_remapped |= has_split_debuginfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
prefer_remapped
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn should_prefer_remapped_for_split_debuginfo_paths(&self) -> bool {
|
|
||||||
let has_split_debuginfo = match self.split_debuginfo() {
|
|
||||||
SplitDebuginfo::Off => false,
|
|
||||||
SplitDebuginfo::Packed | SplitDebuginfo::Unpacked => true,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.opts
|
|
||||||
.unstable_opts
|
|
||||||
.remap_path_scope
|
|
||||||
.contains(RemapPathScopeComponents::SPLIT_DEBUGINFO_PATH)
|
|
||||||
&& has_split_debuginfo
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,11 +10,9 @@ This flag accepts a comma-separated list of values and may be specified multiple
|
||||||
|
|
||||||
- `macro` - apply remappings to the expansion of `std::file!()` macro. This is where paths in embedded panic messages come from
|
- `macro` - apply remappings to the expansion of `std::file!()` macro. This is where paths in embedded panic messages come from
|
||||||
- `diagnostics` - apply remappings to printed compiler diagnostics
|
- `diagnostics` - apply remappings to printed compiler diagnostics
|
||||||
- `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
|
- `debuginfo` - apply remappings to debug informations
|
||||||
- `split-debuginfo` - apply remappings to debug information only when they are written to split debug information files, but not in compiled executables or libraries
|
- `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,debuginfo`.
|
||||||
- `split-debuginfo-path` - apply remappings to the paths pointing to split debug information files. Does nothing when these files are not generated.
|
- `all` - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
|
||||||
- `object` - an alias for `macro,unsplit-debuginfo,split-debuginfo-path`. This ensures all paths in compiled executables or libraries are remapped, but not elsewhere.
|
|
||||||
- `all` and `true` - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
|
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
```sh
|
```sh
|
||||||
|
|
|
@ -28,12 +28,3 @@ remap-with-scope:
|
||||||
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics,object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
|
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=diagnostics,object $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
|
||||||
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
|
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
|
||||||
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
|
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
|
||||||
|
|
||||||
$(RUSTC) --remap-path-prefix $$PWD/auxiliary=/the/aux -Zremap-path-scope=split-debuginfo $(DEBUGINFOOPTS) --crate-type=lib --emit=metadata auxiliary/lib.rs
|
|
||||||
! grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
|
|
||||||
grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
|
|
||||||
|
|
||||||
# FIXME: We should test the split debuginfo files, but we don't currently a good infra for that
|
|
||||||
$(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
|
|
||||||
grep "/the/aux/lib.rs" $(TMPDIR)/liblib.rmeta || exit 1
|
|
||||||
! grep "$$PWD/auxiliary" $(TMPDIR)/liblib.rmeta || exit 1
|
|
||||||
|
|
|
@ -142,7 +142,7 @@ packed-remapped-single:
|
||||||
packed-remapped-scope:
|
packed-remapped-scope:
|
||||||
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
|
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \
|
||||||
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
|
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
|
||||||
-Z remap-path-scope=split-debuginfo-path foo.rs -g
|
-Z remap-path-scope=debuginfo foo.rs -g
|
||||||
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
|
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
|
||||||
ls $(TMPDIR)/*.o && exit 1 || exit 0
|
ls $(TMPDIR)/*.o && exit 1 || exit 0
|
||||||
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
|
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
|
||||||
|
@ -298,7 +298,7 @@ unpacked-remapped-single:
|
||||||
unpacked-remapped-scope:
|
unpacked-remapped-scope:
|
||||||
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
|
$(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \
|
||||||
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
|
-Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \
|
||||||
-Z remap-path-scope=split-debuginfo-path foo.rs -g
|
-Z remap-path-scope=debuginfo foo.rs -g
|
||||||
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
|
objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1
|
||||||
rm $(TMPDIR)/*.o
|
rm $(TMPDIR)/*.o
|
||||||
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
|
ls $(TMPDIR)/*.dwo && exit 1 || exit 0
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue