Skip to content

Commit 47f70b2

Browse files
Check for LLVM archive writting support by delegating to C.
1 parent f7c6fe0 commit 47f70b2

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/librustc_llvm/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2109,6 +2109,7 @@ extern {
21092109

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

2112+
pub fn LLVMRustUseArchiveWriter() -> bool;
21122113
pub fn LLVMRustWriteArchive(Dst: *const c_char,
21132114
NumMembers: size_t,
21142115
Members: *const RustArchiveMemberRef,

src/librustc_trans/back/archive.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ impl<'a> ArchiveBuilder<'a> {
218218
}
219219

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

src/rustllvm/ArchiveWrapper.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ typedef Archive RustArchive;
3636
#define GET_ARCHIVE(a) (a)
3737
#endif
3838

39+
extern "C" bool
40+
LLVMRustUseArchiveWriter() {
41+
return LLVM_VERSION_MINOR >= 7 && !PNACL_LLVM;
42+
}
43+
3944
extern "C" void*
4045
LLVMRustOpenArchive(char *path) {
4146
ErrorOr<std::unique_ptr<MemoryBuffer>> buf_or = MemoryBuffer::getFile(path,

0 commit comments

Comments
 (0)