Skip to content

Commit 8ad5ad4

Browse files
committed
LLVM < 3.5 is unsupported since bb18a3c
1 parent e959fab commit 8ad5ad4

File tree

9 files changed

+18
-90
lines changed

9 files changed

+18
-90
lines changed

src/etc/mklldeps.py

+1-11
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,8 @@ def run(args):
4646

4747
f.write("\n")
4848

49-
version = run([llconfig, '--version']).strip()
50-
5149
# LLVM libs
52-
if version < '3.5':
53-
args = [llconfig, '--libs']
54-
else:
55-
args = [llconfig, '--libs', '--system-libs']
50+
args = [llconfig, '--libs', '--system-libs']
5651

5752
args.extend(components)
5853
out = run(args)
@@ -73,11 +68,6 @@ def run(args):
7368
f.write(", kind = \"static\"")
7469
f.write(")]\n")
7570

76-
# llvm-config before 3.5 didn't have a system-libs flag
77-
if version < '3.5':
78-
if os == 'win32':
79-
f.write("#[link(name = \"imagehlp\")]")
80-
8171
# LLVM ldflags
8272
out = run([llconfig, '--ldflags'])
8373
for lib in out.strip().split(' '):

src/librustc_llvm/lib.rs

-2
Original file line numberDiff line numberDiff line change
@@ -2056,8 +2056,6 @@ extern {
20562056
pub fn LLVMRustDestroyArchive(AR: ArchiveRef);
20572057

20582058
pub fn LLVMRustSetDLLExportStorageClass(V: ValueRef);
2059-
pub fn LLVMVersionMajor() -> c_int;
2060-
pub fn LLVMVersionMinor() -> c_int;
20612059

20622060
pub fn LLVMRustGetSectionName(SI: SectionIteratorRef,
20632061
data: *mut *const c_char) -> c_int;

src/librustc_trans/trans/context.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -878,16 +878,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
878878
// were introduced in LLVM 3.4, so we case on that.
879879
macro_rules! compatible_ifn {
880880
($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr) => (
881-
if unsafe { llvm::LLVMVersionMinor() >= 4 } {
882-
// The `if key == $name` is already in ifn!
883-
ifn!($name, fn($($arg),*) -> $ret);
884-
} else if *key == $name {
885-
let f = declare::declare_cfn(ccx, stringify!($cname),
886-
Type::func(&[$($arg),*], &$ret),
887-
ty::mk_nil(ccx.tcx()));
888-
ccx.intrinsics().borrow_mut().insert($name, f.clone());
889-
return Some(f);
890-
}
881+
ifn!($name, fn($($arg),*) -> $ret);
891882
)
892883
}
893884

src/librustc_trans/trans/debuginfo.rs

+2-19
Original file line numberDiff line numberDiff line change
@@ -2653,25 +2653,8 @@ fn set_members_of_composite_type(cx: &CrateContext,
26532653
let mut composite_types_completed =
26542654
debug_context(cx).composite_types_completed.borrow_mut();
26552655
if composite_types_completed.contains(&composite_type_metadata) {
2656-
let (llvm_version_major, llvm_version_minor) = unsafe {
2657-
(llvm::LLVMVersionMajor(), llvm::LLVMVersionMinor())
2658-
};
2659-
2660-
let actual_llvm_version = llvm_version_major * 1000000 + llvm_version_minor * 1000;
2661-
let min_supported_llvm_version = 3 * 1000000 + 4 * 1000;
2662-
2663-
if actual_llvm_version < min_supported_llvm_version {
2664-
cx.sess().warn(&format!("This version of rustc was built with LLVM \
2665-
{}.{}. Rustc just ran into a known \
2666-
debuginfo corruption problem thatoften \
2667-
occurs with LLVM versions below 3.4. \
2668-
Please use a rustc built with anewer \
2669-
version of LLVM.",
2670-
llvm_version_major,
2671-
llvm_version_minor));
2672-
} else {
2673-
cx.sess().bug("debuginfo::set_members_of_composite_type() - \
2674-
Already completed forward declaration re-encountered.");
2656+
cx.sess().bug("debuginfo::set_members_of_composite_type() - \
2657+
Already completed forward declaration re-encountered.");
26752658
}
26762659
} else {
26772660
composite_types_completed.insert(composite_type_metadata);

src/librustc_trans/trans/intrinsic.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -746,11 +746,7 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
746746
let src = to_arg_ty(bcx, llargs[2], tp_ty);
747747
let res = AtomicCmpXchg(bcx, ptr, cmp, src, order,
748748
strongest_failure_ordering);
749-
if unsafe { llvm::LLVMVersionMinor() >= 5 } {
750-
ExtractValue(bcx, res, 0)
751-
} else {
752-
res
753-
}
749+
ExtractValue(bcx, res, 0)
754750
}
755751

756752
"load" => {

src/rustllvm/ExecutionEngineWrapper.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ extern "C" LLVMExecutionEngineRef LLVMBuildExecutionEngine(
8989
options.NoFramePointerElim = true;
9090

9191
ExecutionEngine *ee =
92-
#if LLVM_VERSION_MINOR <= 5
93-
EngineBuilder(unwrap(mod))
94-
.setMCJITMemoryManager(unwrap(mref))
95-
#else
92+
#if LLVM_VERSION_MINOR >= 6
9693
EngineBuilder(std::unique_ptr<Module>(unwrap(mod)))
9794
.setMCJITMemoryManager(std::unique_ptr<RustJITMemoryManager>(unwrap(mref)))
95+
#else
96+
EngineBuilder(unwrap(mod))
97+
.setMCJITMemoryManager(unwrap(mref))
9898
#endif
9999
.setEngineKind(EngineKind::JIT)
100100
.setErrorStr(&error_str)

src/rustllvm/PassWrapper.cpp

+3-16
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ LLVMRustCreateTargetMachine(const char *triple,
9292
TargetOptions Options;
9393
Options.PositionIndependentExecutable = PositionIndependentExecutable;
9494
Options.NoFramePointerElim = NoFramePointerElim;
95-
#if LLVM_VERSION_MINOR < 5
96-
Options.EnableSegmentedStacks = EnableSegmentedStacks;
97-
#endif
9895
Options.FloatABIType = FloatABI::Default;
9996
Options.UseSoftFloat = UseSoftFloat;
10097
if (UseSoftFloat) {
@@ -128,10 +125,8 @@ LLVMRustAddAnalysisPasses(LLVMTargetMachineRef TM,
128125
PassManagerBase *PM = unwrap(PMR);
129126
#if LLVM_VERSION_MINOR >= 6
130127
PM->add(new DataLayoutPass());
131-
#elif LLVM_VERSION_MINOR == 5
132-
PM->add(new DataLayoutPass(unwrap(M)));
133128
#else
134-
PM->add(new DataLayout(unwrap(M)));
129+
PM->add(new DataLayoutPass(unwrap(M)));
135130
#endif
136131
unwrap(TM)->addAnalysisPasses(*PM);
137132
}
@@ -202,10 +197,8 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target,
202197
raw_fd_ostream OS(path, EC, sys::fs::F_None);
203198
if (EC)
204199
ErrorInfo = EC.message();
205-
#elif LLVM_VERSION_MINOR >= 4
206-
raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
207200
#else
208-
raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary);
201+
raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
209202
#endif
210203
if (ErrorInfo != "") {
211204
LLVMRustSetLastError(ErrorInfo.c_str());
@@ -230,19 +223,13 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR,
230223
raw_fd_ostream OS(path, EC, sys::fs::F_None);
231224
if (EC)
232225
ErrorInfo = EC.message();
233-
#elif LLVM_VERSION_MINOR >= 4
226+
#elif
234227
raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
235-
#else
236-
raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary);
237228
#endif
238229

239230
formatted_raw_ostream FOS(OS);
240231

241-
#if LLVM_VERSION_MINOR >= 5
242232
PM->add(createPrintModulePass(FOS));
243-
#else
244-
PM->add(createPrintModulePass(&FOS));
245-
#endif
246233

247234
PM->run(*unwrap(M));
248235
}

src/rustllvm/RustWrapper.cpp

+6-16
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable(
412412
bool isLocalToUnit,
413413
LLVMValueRef Val,
414414
LLVMMetadataRef Decl = NULL) {
415-
#if LLVM_VERSION_MINOR == 6
415+
#if LLVM_VERSION_MINOR >= 6
416416
return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context),
417417
#else
418418
return wrap(Builder->createStaticVariable(unwrapDI<DIDescriptor>(Context),
@@ -440,7 +440,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable(
440440
int64_t* AddrOps,
441441
unsigned AddrOpsCount,
442442
unsigned ArgNo) {
443-
#if LLVM_VERSION_MINOR < 6
443+
#if LLVM_VERSION_MINOR == 5
444444
if (AddrOpsCount > 0) {
445445
SmallVector<llvm::Value *, 16> addr_ops;
446446
llvm::Type *Int64Ty = Type::getInt64Ty(unwrap<MDNode>(Scope)->getContext());
@@ -707,12 +707,12 @@ extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) {
707707
extern "C" bool
708708
LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
709709
Module *Dst = unwrap(dst);
710-
#if LLVM_VERSION_MINOR == 5
711-
MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
712-
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(buf, Dst->getContext());
713-
#else
710+
#if LLVM_VERSION_MINOR >= 6
714711
std::unique_ptr<MemoryBuffer> buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
715712
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(std::move(buf), Dst->getContext());
713+
#else
714+
MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
715+
ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(buf, Dst->getContext());
716716
#endif
717717
if (!Src) {
718718
LLVMRustSetLastError(Src.getError().message().c_str());
@@ -809,16 +809,6 @@ LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) {
809809
V->setDLLStorageClass(GlobalValue::DLLExportStorageClass);
810810
}
811811

812-
extern "C" int
813-
LLVMVersionMinor() {
814-
return LLVM_VERSION_MINOR;
815-
}
816-
817-
extern "C" int
818-
LLVMVersionMajor() {
819-
return LLVM_VERSION_MAJOR;
820-
}
821-
822812
// Note that the two following functions look quite similar to the
823813
// LLVMGetSectionName function. Sadly, it appears that this function only
824814
// returns a char* pointer, which isn't guaranteed to be null-terminated. The

src/rustllvm/rustllvm.h

-7
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,10 @@
4646
#include "llvm-c/ExecutionEngine.h"
4747
#include "llvm-c/Object.h"
4848

49-
#if LLVM_VERSION_MINOR >= 5
5049
#include "llvm/IR/IRPrintingPasses.h"
5150
#include "llvm/IR/DebugInfo.h"
5251
#include "llvm/IR/DIBuilder.h"
5352
#include "llvm/Linker/Linker.h"
54-
#else
55-
#include "llvm/Assembly/PrintModulePass.h"
56-
#include "llvm/DebugInfo.h"
57-
#include "llvm/DIBuilder.h"
58-
#include "llvm/Linker.h"
59-
#endif
6053

6154
// Used by RustMCJITMemoryManager::getPointerToNamedFunction()
6255
// to get around glibc issues. See the function for more information.

0 commit comments

Comments
 (0)