Skip to content

Commit 18632ba

Browse files
committed
LLVM < 3.5 is unsupported since bb18a3c
1 parent e959fab commit 18632ba

File tree

5 files changed

+14
-44
lines changed

5 files changed

+14
-44
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/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-6
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());

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)