Skip to content

Commit 9a74dac

Browse files
committed
Adapt cg_cranelift to the overhauled filename handling
1 parent 406518b commit 9a74dac

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

compiler/rustc_codegen_cranelift/src/debuginfo/line_info.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use std::path::{Component, Path};
66
use cranelift_codegen::MachSrcLoc;
77
use cranelift_codegen::binemit::CodeOffset;
88
use gimli::write::{AttributeValue, FileId, FileInfo, LineProgram, LineString, LineStringTable};
9-
use rustc_span::{FileName, Pos, SourceFile, SourceFileAndLine, SourceFileHashAlgorithm, hygiene};
9+
use rustc_span::{
10+
FileName, Pos, RemapPathScopeComponents, SourceFile, SourceFileAndLine,
11+
SourceFileHashAlgorithm, hygiene,
12+
};
1013

1114
use crate::debuginfo::FunctionDebugContext;
1215
use crate::debuginfo::emit::address_for_func;
@@ -95,7 +98,7 @@ impl DebugContext {
9598
match &source_file.name {
9699
FileName::Real(path) => {
97100
let (dir_path, file_name) =
98-
split_path_dir_and_file(path.to_path(self.filename_display_preference));
101+
split_path_dir_and_file(path.path(RemapPathScopeComponents::DEBUGINFO));
99102
let dir_name = osstr_as_utf8_bytes(dir_path.as_os_str());
100103
let file_name = osstr_as_utf8_bytes(file_name);
101104

compiler/rustc_codegen_cranelift/src/debuginfo/mod.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_hir::def::DefKind;
2121
use rustc_hir::def_id::DefIdMap;
2222
use rustc_session::Session;
2323
use rustc_session::config::DebugInfo;
24-
use rustc_span::{FileNameDisplayPreference, SourceFileHash, StableSourceFileId};
24+
use rustc_span::{RemapPathScopeComponents, SourceFileHash, StableSourceFileId};
2525
use rustc_target::callconv::FnAbi;
2626

2727
pub(crate) use self::emit::{DebugReloc, DebugRelocName};
@@ -44,7 +44,6 @@ pub(crate) struct DebugContext {
4444
namespace_map: DefIdMap<UnitEntryId>,
4545
array_size_type: UnitEntryId,
4646

47-
filename_display_preference: FileNameDisplayPreference,
4847
embed_source: bool,
4948
}
5049

@@ -102,18 +101,18 @@ impl DebugContext {
102101

103102
let mut dwarf = DwarfUnit::new(encoding);
104103

105-
use rustc_session::config::RemapPathScopeComponents;
106-
107-
let filename_display_preference =
108-
tcx.sess.filename_display_preference(RemapPathScopeComponents::DEBUGINFO);
109-
110104
let producer = producer(tcx.sess);
111-
let comp_dir =
112-
tcx.sess.opts.working_dir.to_string_lossy(filename_display_preference).to_string();
105+
let comp_dir = tcx
106+
.sess
107+
.source_map()
108+
.working_dir()
109+
.path(RemapPathScopeComponents::DEBUGINFO)
110+
.to_string_lossy();
113111

114112
let (name, file_info) = match tcx.sess.local_crate_source_file() {
115113
Some(path) => {
116-
let name = path.to_string_lossy(filename_display_preference).to_string();
114+
let name =
115+
path.path(RemapPathScopeComponents::DEBUGINFO).to_string_lossy().into_owned();
117116
(name, None)
118117
}
119118
None => (tcx.crate_name(LOCAL_CRATE).to_string(), None),
@@ -137,7 +136,7 @@ impl DebugContext {
137136

138137
{
139138
let name = dwarf.strings.add(format!("{name}/@/{cgu_name}"));
140-
let comp_dir = dwarf.strings.add(comp_dir);
139+
let comp_dir = dwarf.strings.add(&*comp_dir);
141140

142141
let root = dwarf.unit.root();
143142
let root = dwarf.unit.get_mut(root);
@@ -175,7 +174,6 @@ impl DebugContext {
175174
stack_pointer_register,
176175
namespace_map: DefIdMap::default(),
177176
array_size_type,
178-
filename_display_preference,
179177
embed_source,
180178
})
181179
}

0 commit comments

Comments
 (0)