LLVM < 3.5 is unsupported since bb18a3c
This commit is contained in:
parent
77acda1c8e
commit
ba276adab5
@ -46,13 +46,8 @@ def run(args):
|
|||||||
|
|
||||||
f.write("\n")
|
f.write("\n")
|
||||||
|
|
||||||
version = run([llconfig, '--version']).strip()
|
|
||||||
|
|
||||||
# LLVM libs
|
# LLVM libs
|
||||||
if version < '3.5':
|
args = [llconfig, '--libs', '--system-libs']
|
||||||
args = [llconfig, '--libs']
|
|
||||||
else:
|
|
||||||
args = [llconfig, '--libs', '--system-libs']
|
|
||||||
|
|
||||||
args.extend(components)
|
args.extend(components)
|
||||||
out = run(args)
|
out = run(args)
|
||||||
@ -73,11 +68,6 @@ for lib in out.strip().replace("\n", ' ').split(' '):
|
|||||||
f.write(", kind = \"static\"")
|
f.write(", kind = \"static\"")
|
||||||
f.write(")]\n")
|
f.write(")]\n")
|
||||||
|
|
||||||
# llvm-config before 3.5 didn't have a system-libs flag
|
|
||||||
if version < '3.5':
|
|
||||||
if os == 'win32':
|
|
||||||
f.write("#[link(name = \"imagehlp\")]")
|
|
||||||
|
|
||||||
# LLVM ldflags
|
# LLVM ldflags
|
||||||
out = run([llconfig, '--ldflags'])
|
out = run([llconfig, '--ldflags'])
|
||||||
for lib in out.strip().split(' '):
|
for lib in out.strip().split(' '):
|
||||||
|
@ -2056,8 +2056,6 @@ extern {
|
|||||||
pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
|
pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
|
||||||
|
|
||||||
pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
|
pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
|
||||||
pub fn LLVMVersionMajor() -> c_int;
|
|
||||||
pub fn LLVMVersionMinor() -> c_int;
|
|
||||||
|
|
||||||
pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
|
pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
|
||||||
data: *mut *const c_char) -> c_int;
|
data: *mut *const c_char) -> c_int;
|
||||||
|
@ -878,16 +878,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
|
|||||||
// were introduced in LLVM 3.4, so we case on that.
|
// were introduced in LLVM 3.4, so we case on that.
|
||||||
macro_rules! compatible_ifn {
|
macro_rules! compatible_ifn {
|
||||||
($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr) => (
|
($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr) => (
|
||||||
if unsafe { llvm::LLVMVersionMinor() >= 4 } {
|
ifn!($name, fn($($arg),*) -> $ret);
|
||||||
// The `if key == $name` is already in ifn!
|
|
||||||
ifn!($name, fn($($arg),*) -> $ret);
|
|
||||||
} else if *key == $name {
|
|
||||||
let f = declare::declare_cfn(ccx, stringify!($cname),
|
|
||||||
Type::func(&[$($arg),*], &$ret),
|
|
||||||
ty::mk_nil(ccx.tcx()));
|
|
||||||
ccx.intrinsics().borrow_mut().insert($name, f.clone());
|
|
||||||
return Some(f);
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2653,26 +2653,8 @@ fn set_members_of_composite_type(cx: &CrateContext,
|
|||||||
let mut composite_types_completed =
|
let mut composite_types_completed =
|
||||||
debug_context(cx).composite_types_completed.borrow_mut();
|
debug_context(cx).composite_types_completed.borrow_mut();
|
||||||
if composite_types_completed.contains(&composite_type_metadata) {
|
if composite_types_completed.contains(&composite_type_metadata) {
|
||||||
let (llvm_version_major, llvm_version_minor) = unsafe {
|
cx.sess().bug("debuginfo::set_members_of_composite_type() - \
|
||||||
(llvm::LLVMVersionMajor(), llvm::LLVMVersionMinor())
|
Already completed forward declaration re-encountered.");
|
||||||
};
|
|
||||||
|
|
||||||
let actual_llvm_version = llvm_version_major * 1000000 + llvm_version_minor * 1000;
|
|
||||||
let min_supported_llvm_version = 3 * 1000000 + 4 * 1000;
|
|
||||||
|
|
||||||
if actual_llvm_version < min_supported_llvm_version {
|
|
||||||
cx.sess().warn(&format!("This version of rustc was built with LLVM \
|
|
||||||
{}.{}. Rustc just ran into a known \
|
|
||||||
debuginfo corruption problem thatoften \
|
|
||||||
occurs with LLVM versions below 3.4. \
|
|
||||||
Please use a rustc built with anewer \
|
|
||||||
version of LLVM.",
|
|
||||||
llvm_version_major,
|
|
||||||
llvm_version_minor));
|
|
||||||
} else {
|
|
||||||
cx.sess().bug("debuginfo::set_members_of_composite_type() - \
|
|
||||||
Already completed forward declaration re-encountered.");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
composite_types_completed.insert(composite_type_metadata);
|
composite_types_completed.insert(composite_type_metadata);
|
||||||
}
|
}
|
||||||
|
@ -746,11 +746,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
|
|||||||
let src = to_arg_ty(bcx, llargs[2], tp_ty);
|
let src = to_arg_ty(bcx, llargs[2], tp_ty);
|
||||||
let res = AtomicCmpXchg(bcx, ptr, cmp, src, order,
|
let res = AtomicCmpXchg(bcx, ptr, cmp, src, order,
|
||||||
strongest_failure_ordering);
|
strongest_failure_ordering);
|
||||||
if unsafe { llvm::LLVMVersionMinor() >= 5 } {
|
ExtractValue(bcx, res, 0)
|
||||||
ExtractValue(bcx, res, 0)
|
|
||||||
} else {
|
|
||||||
res
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"load" => {
|
"load" => {
|
||||||
|
@ -89,12 +89,12 @@ extern "C" LLVMExecutionEngineRef LLVMBuildExecutionEngine(
|
|||||||
options.NoFramePointerElim = true;
|
options.NoFramePointerElim = true;
|
||||||
|
|
||||||
ExecutionEngine *ee =
|
ExecutionEngine *ee =
|
||||||
#if LLVM_VERSION_MINOR <= 5
|
#if LLVM_VERSION_MINOR >= 6
|
||||||
EngineBuilder(unwrap(mod))
|
|
||||||
.setMCJITMemoryManager(unwrap(mref))
|
|
||||||
#else
|
|
||||||
EngineBuilder(std::unique_ptr<Module>(unwrap(mod)))
|
EngineBuilder(std::unique_ptr<Module>(unwrap(mod)))
|
||||||
.setMCJITMemoryManager(std::unique_ptr<RustJITMemoryManager>(unwrap(mref)))
|
.setMCJITMemoryManager(std::unique_ptr<RustJITMemoryManager>(unwrap(mref)))
|
||||||
|
#else
|
||||||
|
EngineBuilder(unwrap(mod))
|
||||||
|
.setMCJITMemoryManager(unwrap(mref))
|
||||||
#endif
|
#endif
|
||||||
.setEngineKind(EngineKind::JIT)
|
.setEngineKind(EngineKind::JIT)
|
||||||
.setErrorStr(&error_str)
|
.setErrorStr(&error_str)
|
||||||
|
@ -92,9 +92,6 @@ LLVMRustCreateTargetMachine(const char *triple,
|
|||||||
TargetOptions Options;
|
TargetOptions Options;
|
||||||
Options.PositionIndependentExecutable = PositionIndependentExecutable;
|
Options.PositionIndependentExecutable = PositionIndependentExecutable;
|
||||||
Options.NoFramePointerElim = NoFramePointerElim;
|
Options.NoFramePointerElim = NoFramePointerElim;
|
||||||
#if LLVM_VERSION_MINOR < 5
|
|
||||||
Options.EnableSegmentedStacks = EnableSegmentedStacks;
|
|
||||||
#endif
|
|
||||||
Options.FloatABIType = FloatABI::Default;
|
Options.FloatABIType = FloatABI::Default;
|
||||||
Options.UseSoftFloat = UseSoftFloat;
|
Options.UseSoftFloat = UseSoftFloat;
|
||||||
if (UseSoftFloat) {
|
if (UseSoftFloat) {
|
||||||
@ -128,10 +125,8 @@ LLVMRustAddAnalysisPasses(LLVMTargetMachineRef TM,
|
|||||||
PassManagerBase *PM = unwrap(PMR);
|
PassManagerBase *PM = unwrap(PMR);
|
||||||
#if LLVM_VERSION_MINOR >= 6
|
#if LLVM_VERSION_MINOR >= 6
|
||||||
PM->add(new DataLayoutPass());
|
PM->add(new DataLayoutPass());
|
||||||
#elif LLVM_VERSION_MINOR == 5
|
|
||||||
PM->add(new DataLayoutPass(unwrap(M)));
|
|
||||||
#else
|
#else
|
||||||
PM->add(new DataLayout(unwrap(M)));
|
PM->add(new DataLayoutPass(unwrap(M)));
|
||||||
#endif
|
#endif
|
||||||
unwrap(TM)->addAnalysisPasses(*PM);
|
unwrap(TM)->addAnalysisPasses(*PM);
|
||||||
}
|
}
|
||||||
@ -202,10 +197,8 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target,
|
|||||||
raw_fd_ostream OS(path, EC, sys::fs::F_None);
|
raw_fd_ostream OS(path, EC, sys::fs::F_None);
|
||||||
if (EC)
|
if (EC)
|
||||||
ErrorInfo = EC.message();
|
ErrorInfo = EC.message();
|
||||||
#elif LLVM_VERSION_MINOR >= 4
|
|
||||||
raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
|
|
||||||
#else
|
#else
|
||||||
raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary);
|
raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
|
||||||
#endif
|
#endif
|
||||||
if (ErrorInfo != "") {
|
if (ErrorInfo != "") {
|
||||||
LLVMRustSetLastError(ErrorInfo.c_str());
|
LLVMRustSetLastError(ErrorInfo.c_str());
|
||||||
@ -230,19 +223,13 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR,
|
|||||||
raw_fd_ostream OS(path, EC, sys::fs::F_None);
|
raw_fd_ostream OS(path, EC, sys::fs::F_None);
|
||||||
if (EC)
|
if (EC)
|
||||||
ErrorInfo = EC.message();
|
ErrorInfo = EC.message();
|
||||||
#elif LLVM_VERSION_MINOR >= 4
|
|
||||||
raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
|
|
||||||
#else
|
#else
|
||||||
raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary);
|
raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
formatted_raw_ostream FOS(OS);
|
formatted_raw_ostream FOS(OS);
|
||||||
|
|
||||||
#if LLVM_VERSION_MINOR >= 5
|
|
||||||
PM->add(createPrintModulePass(FOS));
|
PM->add(createPrintModulePass(FOS));
|
||||||
#else
|
|
||||||
PM->add(createPrintModulePass(&FOS));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
PM->run(*unwrap(M));
|
PM->run(*unwrap(M));
|
||||||
}
|
}
|
||||||
|
@ -412,7 +412,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable(
|
|||||||
bool isLocalToUnit,
|
bool isLocalToUnit,
|
||||||
LLVMValueRef Val,
|
LLVMValueRef Val,
|
||||||
LLVMMetadataRef Decl = NULL) {
|
LLVMMetadataRef Decl = NULL) {
|
||||||
#if LLVM_VERSION_MINOR == 6
|
#if LLVM_VERSION_MINOR >= 6
|
||||||
return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context),
|
return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context),
|
||||||
#else
|
#else
|
||||||
return wrap(Builder->createStaticVariable(unwrapDI<DIDescriptor>(Context),
|
return wrap(Builder->createStaticVariable(unwrapDI<DIDescriptor>(Context),
|
||||||
@ -440,7 +440,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable(
|
|||||||
int64_t* AddrOps,
|
int64_t* AddrOps,
|
||||||
unsigned AddrOpsCount,
|
unsigned AddrOpsCount,
|
||||||
unsigned ArgNo) {
|
unsigned ArgNo) {
|
||||||
#if LLVM_VERSION_MINOR < 6
|
#if LLVM_VERSION_MINOR == 5
|
||||||
if (AddrOpsCount > 0) {
|
if (AddrOpsCount > 0) {
|
||||||
SmallVector<llvm::Value *, 16> addr_ops;
|
SmallVector<llvm::Value *, 16> addr_ops;
|
||||||
llvm::Type *Int64Ty = Type::getInt64Ty(unwrap<MDNode>(Scope)->getContext());
|
llvm::Type *Int64Ty = Type::getInt64Ty(unwrap<MDNode>(Scope)->getContext());
|
||||||
@ -707,12 +707,12 @@ extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) {
|
|||||||
extern "C" bool
|
extern "C" bool
|
||||||
LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
|
LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
|
||||||
Module *Dst = unwrap(dst);
|
Module *Dst = unwrap(dst);
|
||||||
#if LLVM_VERSION_MINOR == 5
|
#if LLVM_VERSION_MINOR >= 6
|
||||||
MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
|
|
||||||
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(buf, Dst->getContext());
|
|
||||||
#else
|
|
||||||
std::unique_ptr<MemoryBuffer> buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
|
std::unique_ptr<MemoryBuffer> buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
|
||||||
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(std::move(buf), Dst->getContext());
|
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(std::move(buf), Dst->getContext());
|
||||||
|
#else
|
||||||
|
MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
|
||||||
|
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(buf, Dst->getContext());
|
||||||
#endif
|
#endif
|
||||||
if (!Src) {
|
if (!Src) {
|
||||||
LLVMRustSetLastError(Src.getError().message().c_str());
|
LLVMRustSetLastError(Src.getError().message().c_str());
|
||||||
@ -809,16 +809,6 @@ LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) {
|
|||||||
V->setDLLStorageClass(GlobalValue::DLLExportStorageClass);
|
V->setDLLStorageClass(GlobalValue::DLLExportStorageClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int
|
|
||||||
LLVMVersionMinor() {
|
|
||||||
return LLVM_VERSION_MINOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" int
|
|
||||||
LLVMVersionMajor() {
|
|
||||||
return LLVM_VERSION_MAJOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note that the two following functions look quite similar to the
|
// Note that the two following functions look quite similar to the
|
||||||
// LLVMGetSectionName function. Sadly, it appears that this function only
|
// LLVMGetSectionName function. Sadly, it appears that this function only
|
||||||
// returns a char* pointer, which isn't guaranteed to be null-terminated. The
|
// returns a char* pointer, which isn't guaranteed to be null-terminated. The
|
||||||
|
@ -46,17 +46,10 @@
|
|||||||
#include "llvm-c/ExecutionEngine.h"
|
#include "llvm-c/ExecutionEngine.h"
|
||||||
#include "llvm-c/Object.h"
|
#include "llvm-c/Object.h"
|
||||||
|
|
||||||
#if LLVM_VERSION_MINOR >= 5
|
|
||||||
#include "llvm/IR/IRPrintingPasses.h"
|
#include "llvm/IR/IRPrintingPasses.h"
|
||||||
#include "llvm/IR/DebugInfo.h"
|
#include "llvm/IR/DebugInfo.h"
|
||||||
#include "llvm/IR/DIBuilder.h"
|
#include "llvm/IR/DIBuilder.h"
|
||||||
#include "llvm/Linker/Linker.h"
|
#include "llvm/Linker/Linker.h"
|
||||||
#else
|
|
||||||
#include "llvm/Assembly/PrintModulePass.h"
|
|
||||||
#include "llvm/DebugInfo.h"
|
|
||||||
#include "llvm/DIBuilder.h"
|
|
||||||
#include "llvm/Linker.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Used by RustMCJITMemoryManager::getPointerToNamedFunction()
|
// Used by RustMCJITMemoryManager::getPointerToNamedFunction()
|
||||||
// to get around glibc issues. See the function for more information.
|
// to get around glibc issues. See the function for more information.
|
||||||
|
Loading…
Reference in New Issue
Block a user