1
Fork 0

Replace RemapFileNameExt::for_codegen with explicit calls

This commit is contained in:
Urgau 2024-03-19 13:51:22 +01:00
parent 777c6b46cc
commit 106146fd95
9 changed files with 55 additions and 52 deletions

View file

@ -29,7 +29,8 @@ use rustc_data_structures::small_c_str::SmallCStr;
use rustc_errors::{DiagCtxt, FatalError, Level};
use rustc_fs_util::{link_or_copy, path_to_c_string};
use rustc_middle::ty::TyCtxt;
use rustc_session::config::{self, Lto, OutputType, Passes, SplitDwarfKind, SwitchWithOptPath};
use rustc_session::config::{self, Lto, OutputType, Passes};
use rustc_session::config::{RemapPathScopeComponents, SplitDwarfKind, SwitchWithOptPath};
use rustc_session::Session;
use rustc_span::symbol::sym;
use rustc_span::InnerSpan;
@ -257,7 +258,8 @@ pub fn target_machine_factory(
};
let debuginfo_compression = SmallCStr::new(&debuginfo_compression);
let should_prefer_remapped_paths = sess.should_prefer_remapped_for_codegen();
let should_prefer_remapped_paths =
sess.should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO);
Arc::new(move |config: TargetMachineFactoryConfig| {
let path_to_cstring_helper = |path: Option<PathBuf>| -> CString {

View file

@ -173,8 +173,14 @@ impl GlobalFileTable {
// Since rustc generates coverage maps with relative paths, the
// compilation directory can be combined with the relative paths
// to get absolute paths, if needed.
use rustc_session::config::RemapPathScopeComponents;
use rustc_session::RemapFileNameExt;
let working_dir: &str = &tcx.sess.opts.working_dir.for_codegen(tcx.sess).to_string_lossy();
let working_dir: &str = &tcx
.sess
.opts
.working_dir
.for_scope(tcx.sess, RemapPathScopeComponents::MACRO)
.to_string_lossy();
llvm::build_byte_buffer(|buffer| {
coverageinfo::write_filenames_section_to_buffer(

View file

@ -554,13 +554,13 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
) -> &'ll DIFile {
debug!(?source_file.name);
use rustc_session::RemapFileNameExt;
use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
let (directory, file_name) = match &source_file.name {
FileName::Real(filename) => {
let working_directory = &cx.sess().opts.working_dir;
debug!(?working_directory);
if cx.sess().should_prefer_remapped_for_codegen() {
if cx.sess().should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO) {
let filename = cx
.sess()
.source_map()
@ -623,7 +623,13 @@ pub fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFile) ->
}
other => {
debug!(?other);
("".into(), other.for_codegen(cx.sess()).to_string_lossy().into_owned())
(
"".into(),
other
.for_scope(cx.sess(), RemapPathScopeComponents::DEBUGINFO)
.to_string_lossy()
.into_owned(),
)
}
};
@ -862,9 +868,14 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
// FIXME(#41252) Remove "clang LLVM" if we can get GDB and LLVM to play nice.
let producer = format!("clang LLVM ({rustc_producer})");
use rustc_session::RemapFileNameExt;
use rustc_session::{config::RemapPathScopeComponents, RemapFileNameExt};
let name_in_debuginfo = name_in_debuginfo.to_string_lossy();
let work_dir = tcx.sess.opts.working_dir.for_codegen(tcx.sess).to_string_lossy();
let work_dir = tcx
.sess
.opts
.working_dir
.for_scope(tcx.sess, RemapPathScopeComponents::DEBUGINFO)
.to_string_lossy();
let output_filenames = tcx.output_filenames(());
let split_name = if tcx.sess.target_can_use_split_dwarf() {
output_filenames
@ -875,7 +886,7 @@ pub fn build_compile_unit_di_node<'ll, 'tcx>(
)
// We get a path relative to the working directory from split_dwarf_path
.map(|f| {
if tcx.sess.should_prefer_remapped_for_codegen() {
if tcx.sess.should_prefer_remapped(RemapPathScopeComponents::DEBUGINFO) {
tcx.sess.source_map().path_mapping().map_prefix(f).0
} else {
f.into()