[LLVM 4.0] Fix CreateCompileUnit

This commit is contained in:
Matt Ickstadt 2017-02-11 15:01:25 -06:00
parent 064a0ee131
commit 68fff62542
3 changed files with 22 additions and 12 deletions

View File

@ -1334,8 +1334,7 @@ extern "C" {
pub fn LLVMRustDIBuilderCreateCompileUnit(Builder: DIBuilderRef,
Lang: c_uint,
File: *const c_char,
Dir: *const c_char,
File: DIFile,
Producer: *const c_char,
isOptimized: bool,
Flags: *const c_char,

View File

@ -787,17 +787,20 @@ pub fn compile_unit_metadata(scc: &SharedCrateContext,
(option_env!("CFG_VERSION")).expect("CFG_VERSION"));
let compile_unit_name = compile_unit_name.as_ptr();
let work_dir = path2cstr(&work_dir);
let producer = CString::new(producer).unwrap();
let work_dir = path2cstr(&work_dir).as_ptr();
let producer = CString::new(producer).unwrap().as_ptr();
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);
return llvm::LLVMRustDIBuilderCreateCompileUnit(
debug_context.builder,
DW_LANG_RUST,
compile_unit_name,
work_dir.as_ptr(),
producer.as_ptr(),
file_metadata,
producer,
sess.opts.optimize != config::OptLevel::No,
flags.as_ptr() as *const _,
0,

View File

@ -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