Skip to content

Commit

Permalink
Check for LLVM archive writting support by delegating to C.
Browse files Browse the repository at this point in the history
  • Loading branch information
DiamondLovesYou committed Aug 1, 2015
1 parent f7c6fe0 commit 47f70b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,7 @@ extern {

pub fn LLVMWriteSMDiagnosticToString(d: SMDiagnosticRef, s: RustStringRef);

pub fn LLVMRustUseArchiveWriter() -> bool;
pub fn LLVMRustWriteArchive(Dst: *const c_char,
NumMembers: size_t,
Members: *const RustArchiveMemberRef,
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl<'a> ArchiveBuilder<'a> {
}

pub fn llvm_archive_kind(&self) -> Option<ArchiveKind> {
if unsafe { llvm::LLVMVersionMinor() < 7 } {
if !unsafe { llvm::LLVMRustUseArchiveWriter() } {
return None
}

Expand Down
5 changes: 5 additions & 0 deletions src/rustllvm/ArchiveWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ typedef Archive RustArchive;
#define GET_ARCHIVE(a) (a)
#endif

extern "C" bool
LLVMRustUseArchiveWriter() {
return LLVM_VERSION_MINOR >= 7 && !PNACL_LLVM;
}

extern "C" void*
LLVMRustOpenArchive(char *path) {
ErrorOr<std::unique_ptr<MemoryBuffer>> buf_or = MemoryBuffer::getFile(path,
Expand Down

0 comments on commit 47f70b2

Please sign in to comment.