Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LLVM 4.0] Fix CreateCompileUnit #39747

Merged
merged 2 commits into from
Feb 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/librustc_llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,8 +1334,7 @@ extern "C" {

pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
Lang: c_uint,
File: *const c_char,
Dir: *const c_char,
File: DIFile,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really nice!

Producer: *const c_char,
isOptimized: bool,
Flags: *const c_char,
Expand Down
11 changes: 7 additions & 4 deletions src/librustc_trans/debuginfo/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -791,12 +791,15 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext,
let producer = CString::new(producer).unwrap();
let flags = "\0";
let split_name = "\0";
return unsafe {
llvm::LLVMRustDIBuilderCreateCompileUnit(

unsafe {
let file_metadata = llvm::LLVMRustDIBuilderCreateFile(
debug_context.builder, compile_unit_name, work_dir.as_ptr());

return llvm::LLVMRustDIBuilderCreateCompileUnit(
debug_context.builder,
DW_LANG_RUST,
compile_unit_name,
work_dir.as_ptr(),
file_metadata,
producer.as_ptr(),
sess.opts.optimize != config::OptLevel::No,
flags.as_ptr() as *const _,
Expand Down
14 changes: 11 additions & 3 deletions src/rustllvm/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,19 @@ extern "C" void LLVMRustDIBuilderFinalize(LLVMRustDIBuilderRef Builder) {
}

extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateCompileUnit(
LLVMRustDIBuilderRef Builder, unsigned Lang, const char *File,
const char *Dir, const char *Producer, bool isOptimized, const char *Flags,
LLVMRustDIBuilderRef Builder, unsigned Lang, LLVMRustMetadataRef FileRef,
const char *Producer, bool isOptimized, const char *Flags,
unsigned RuntimeVer, const char *SplitName) {
return wrap(Builder->createCompileUnit(Lang, File, Dir, Producer, isOptimized,
auto *File = unwrapDI<DIFile>(FileRef);

#if LLVM_VERSION_GE(4, 0)
return wrap(Builder->createCompileUnit(Lang, File, Producer, isOptimized,
Flags, RuntimeVer, SplitName));
#else
return wrap(Builder->createCompileUnit(Lang, File->getFilename(),
File->getDirectory(), Producer, isOptimized,
Flags, RuntimeVer, SplitName));
#endif
}

extern "C" LLVMRustMetadataRef
Expand Down