Rollup merge of #126985 - Mrmaxmeier:dwarf-embed-source, r=davidtwco

Implement `-Z embed-source` (DWARFv5 source code embedding extension)

Implement https://github.com/rust-lang/compiler-team/issues/764 MCP which adds an unstable flag that exposes LLVM's [DWARFv5 source code embedding](https://dwarfstd.org/issues/180201.1.html) support.
This commit is contained in:
Trevor Gross 2024-08-27 01:46:49 -05:00 committed by GitHub
commit 9c26ebe32e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 135 additions and 4 deletions

View file

@ -629,6 +629,9 @@ pub(crate) fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFi
};
let hash_value = hex_encode(source_file.src_hash.hash_bytes());
let source =
cx.sess().opts.unstable_opts.embed_source.then_some(()).and(source_file.src.as_ref());
unsafe {
llvm::LLVMRustDIBuilderCreateFile(
DIB(cx),
@ -639,6 +642,8 @@ pub(crate) fn file_metadata<'ll>(cx: &CodegenCx<'ll, '_>, source_file: &SourceFi
hash_kind,
hash_value.as_ptr().cast(),
hash_value.len(),
source.map_or(ptr::null(), |x| x.as_ptr().cast()),
source.map_or(0, |x| x.len()),
)
}
}
@ -659,6 +664,8 @@ fn unknown_file_metadata<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll DIFile {
llvm::ChecksumKind::None,
hash_value.as_ptr().cast(),
hash_value.len(),
ptr::null(),
0,
)
})
}
@ -943,6 +950,8 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
llvm::ChecksumKind::None,
ptr::null(),
0,
ptr::null(),
0,
);
let unit_metadata = llvm::LLVMRustDIBuilderCreateCompileUnit(

View file

@ -1860,6 +1860,8 @@ extern "C" {
CSKind: ChecksumKind,
Checksum: *const c_char,
ChecksumLen: size_t,
Source: *const c_char,
SourceLen: size_t,
) -> &'a DIFile;
pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(