summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libre/clamav/Add-support-for-LLVM-3.7.patch740
-rw-r--r--libre/clamav/Add-support-for-LLVM-3.8.patch457
-rw-r--r--libre/clamav/Add-support-for-LLVM-3.9.patch76
-rw-r--r--libre/clamav/PKGBUILD50
-rw-r--r--libre/clamav/clamav-0.99.2-gcc-6.patch84
-rw-r--r--libre/clamav/make_it_compile_against_openssl_1_1_0.patch98
6 files changed, 204 insertions, 1301 deletions
diff --git a/libre/clamav/Add-support-for-LLVM-3.7.patch b/libre/clamav/Add-support-for-LLVM-3.7.patch
deleted file mode 100644
index 8bcd1d7ea..000000000
--- a/libre/clamav/Add-support-for-LLVM-3.7.patch
+++ /dev/null
@@ -1,740 +0,0 @@
-From 3b1b2e757d0d1f13a3f234abf05d6e5015f52744 Mon Sep 17 00:00:00 2001
-From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-Date: Fri, 14 Oct 2016 20:24:39 +0200
-Subject: Add support for LLVM 3.7
-
-Main changes:
-The DataLayoutPass is no longer necessary.
-The LoopInfo pass is now a WrapperPass.
-Before creating TargetLibraryInfo one needs to create a
-TargetLibraryInfoImpl.
-PassManager is now in the legacy:: namespace.
-GetElementPtrInst::getIndexedType changed behavior causing segfaults in
-the testsuite; emulating the old behavior now.
-CreateCallX functions for fixed number X of elements got removed.
-JITEmitDebugInfo Option was removed.
-DIDescriptor was removed.
-
-Patch-Name: Add-support-for-LLVM-3.7.patch
----
- libclamav/c++/ClamBCRTChecks.cpp | 34 ++++++-
- libclamav/c++/PointerTracking.cpp | 44 ++++++++-
- libclamav/c++/bytecode2llvm.cpp | 181 +++++++++++++++++++++++++++++++++++---
- libclamav/c++/m4/llvm-flags.m4 | 4 +-
- 4 files changed, 244 insertions(+), 19 deletions(-)
-
-diff --git a/libclamav/c++/ClamBCRTChecks.cpp b/libclamav/c++/ClamBCRTChecks.cpp
-index 97099b2..35f7272 100644
---- a/libclamav/c++/ClamBCRTChecks.cpp
-+++ b/libclamav/c++/ClamBCRTChecks.cpp
-@@ -201,9 +201,11 @@ namespace llvm {
- TD = &getAnalysis<TargetData>();
- #elif LLVM_VERSION < 35
- TD = &getAnalysis<DataLayout>();
--#else
-+#elif LLVM_VERSION < 37
- DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
- TD = DLP ? &DLP->getDataLayout() : 0;
-+#else
-+ TD = &F.getEntryBlock().getModule()->getDataLayout();
- #endif
- SE = &getAnalysis<ScalarEvolution>();
- PT = &getAnalysis<PointerTracking>();
-@@ -212,7 +214,11 @@ namespace llvm {
- #else
- DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
- #endif
-+#if LLVM_VERSION < 37
- expander = new SCEVExpander(*SE OPT("SCEVexpander"));
-+#else
-+ expander = new SCEVExpander(*SE, *TD OPT("SCEVexpander"));
-+#endif
-
- std::vector<Instruction*> insns;
-
-@@ -351,8 +357,10 @@ namespace llvm {
- AU.addRequired<TargetData>();
- #elif LLVM_VERSION < 35
- AU.addRequired<DataLayout>();
--#else
-+#elif LLVM_VERSION < 37
- AU.addRequired<DataLayoutPass>();
-+#else
-+ // No DataLayout pass needed anymore.
- #endif
- #if LLVM_VERSION < 35
- AU.addRequired<DominatorTree>();
-@@ -406,7 +414,11 @@ namespace llvm {
- if (BaseMap.count(P)) {
- return BaseMap[Ptr] = BaseMap[P];
- }
-+#if LLVM_VERSION < 37
- Value *P2 = GetUnderlyingObject(P, TD);
-+#else
-+ Value *P2 = GetUnderlyingObject(P, *TD);
-+#endif
- if (P2 != P) {
- Value *V = getPointerBase(P2);
- return BaseMap[Ptr] = V;
-@@ -524,7 +536,11 @@ namespace llvm {
- }
- }
- if (LoadInst *LI = dyn_cast<LoadInst>(Base)) {
-+#if LLVM_VERSION < 37
- Value *V = GetUnderlyingObject(LI->getPointerOperand()->stripPointerCasts(), TD);
-+#else
-+ Value *V = GetUnderlyingObject(LI->getPointerOperand()->stripPointerCasts(), *TD);
-+#endif
- if (Argument *A = dyn_cast<Argument>(V)) {
- if (A->getArgNo() == 0) {
- // pointers from hidden ctx are trusted to be at least the
-@@ -651,7 +667,11 @@ namespace llvm {
- }
- BasicBlock *BB = I->getParent();
- BasicBlock::iterator It = I;
-+#if LLVM_VERSION < 37
- BasicBlock *newBB = SplitBlock(BB, &*It, this);
-+#else
-+ BasicBlock *newBB = SplitBlock(BB, &*It);
-+#endif
- PHINode *PN;
- unsigned MDDbgKind = I->getContext().getMDKindID("dbg");
- //verifyFunction(*BB->getParent());
-@@ -696,9 +716,15 @@ namespace llvm {
- unsigned locationid = 0;
- bool Approximate;
- if (MDNode *Dbg = getLocation(I, Approximate, MDDbgKind)) {
-+#if LLVM_VERSION < 37
- DILocation Loc(Dbg);
- locationid = Loc.getLineNumber() << 8;
- unsigned col = Loc.getColumnNumber();
-+#else
-+ DebugLoc Loc(Dbg);
-+ locationid = Loc.getLine() << 8;
-+ unsigned col = Loc.getCol();
-+#endif
- if (col > 254)
- col = 254;
- if (Approximate)
-@@ -912,7 +938,11 @@ INITIALIZE_PASS_DEPENDENCY(TargetData)
- #elif LLVM_VERSION < 35
- INITIALIZE_PASS_DEPENDENCY(DataLayout)
- #else
-+#if LLVM_VERSION < 37
- INITIALIZE_PASS_DEPENDENCY(DataLayoutPass)
-+#else
-+// No DataLayout pass needed anymore.
-+#endif
- #endif
- #if LLVM_VERSION < 35
- INITIALIZE_PASS_DEPENDENCY(DominatorTree)
-diff --git a/libclamav/c++/PointerTracking.cpp b/libclamav/c++/PointerTracking.cpp
-index 8e17a4a..67340e8 100644
---- a/libclamav/c++/PointerTracking.cpp
-+++ b/libclamav/c++/PointerTracking.cpp
-@@ -30,7 +30,11 @@
- #include "llvm/IR/InstIterator.h"
- #endif
- #include "llvm/Support/raw_ostream.h"
-+#if LLVM_VERSION < 37
- #include "llvm/Target/TargetLibraryInfo.h"
-+#else
-+#include <llvm/Analysis/TargetLibraryInfo.h>
-+#endif
-
- #if LLVM_VERSION < 32
- #include "llvm/Target/TargetData.h"
-@@ -70,7 +74,11 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTree)
- #else
- INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
- #endif
-+#if LLVM_VERSION < 37
- INITIALIZE_PASS_DEPENDENCY(LoopInfo)
-+#else
-+INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
-+#endif
- INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
- #if LLVM_VERSION < 35
- INITIALIZE_PASS_DEPENDENCY(DominatorTree)
-@@ -96,12 +104,18 @@ bool PointerTracking::runOnFunction(Function &F) {
- TD = getAnalysisIfAvailable<TargetData>();
- #elif LLVM_VERSION < 35
- TD = getAnalysisIfAvailable<DataLayout>();
--#else
-+#elif LLVM_VERSION < 37
- DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>();
- TD = DLP ? &DLP->getDataLayout() : 0;
-+#else
-+ TD = &F.getEntryBlock().getModule()->getDataLayout();
- #endif
- SE = &getAnalysis<ScalarEvolution>();
-+#if LLVM_VERSION < 37
- LI = &getAnalysis<LoopInfo>();
-+#else
-+ LI = &getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
-+#endif
- #if LLVM_VERSION < 35
- DT = &getAnalysis<DominatorTree>();
- #else
-@@ -116,7 +130,11 @@ void PointerTracking::getAnalysisUsage(AnalysisUsage &AU) const {
- #else
- AU.addRequiredTransitive<DominatorTreeWrapperPass>();
- #endif
-+#if LLVM_VERSION < 37
- AU.addRequiredTransitive<LoopInfo>();
-+#else
-+ AU.addRequiredTransitive<LoopInfoWrapperPass>();
-+#endif
- AU.addRequiredTransitive<ScalarEvolution>();
- AU.setPreservesAll();
- }
-@@ -178,12 +196,19 @@ const SCEV *PointerTracking::computeAllocationCount(Value *P,
- if (CallInst *CI = extractMallocCall(V)) {
- Value *arraySize = getMallocArraySize(CI, TD);
- constType* AllocTy = getMallocAllocatedType(CI);
--#else
-+#elif LLVM_VERSION < 37
- TargetLibraryInfo* TLI = new TargetLibraryInfo();
-
- if (CallInst *CI = extractMallocCall(V, TLI)) {
- Value *arraySize = getMallocArraySize(CI, TD, TLI);
- constType* AllocTy = getMallocAllocatedType(CI, TLI);
-+#else
-+ TargetLibraryInfoImpl* TLII = new TargetLibraryInfoImpl();
-+ TargetLibraryInfo* TLI = new TargetLibraryInfo(*TLII);
-+
-+ if (CallInst *CI = extractMallocCall(V, TLI)) {
-+ Value *arraySize = getMallocArraySize(CI, *TD, TLI);
-+ constType* AllocTy = getMallocAllocatedType(CI, TLI);
- #endif
- if (!AllocTy || !arraySize) return SE->getCouldNotCompute();
- Ty = AllocTy;
-@@ -240,7 +265,7 @@ Value *PointerTracking::computeAllocationCountValue(Value *P, constType *&Ty) co
- if (!Ty)
- return 0;
- Value *arraySize = getMallocArraySize(CI, TD);
--#else
-+#elif LLVM_VERSION < 37
- TargetLibraryInfo* TLI = new TargetLibraryInfo();
-
- if (CallInst *CI = extractMallocCall(V, TLI)) {
-@@ -248,6 +273,15 @@ Value *PointerTracking::computeAllocationCountValue(Value *P, constType *&Ty) co
- if (!Ty)
- return 0;
- Value *arraySize = getMallocArraySize(CI, TD, TLI);
-+#else
-+ TargetLibraryInfoImpl* TLII = new TargetLibraryInfoImpl();
-+ TargetLibraryInfo* TLI = new TargetLibraryInfo(*TLII);
-+
-+ if (CallInst *CI = extractMallocCall(V, TLI)) {
-+ Ty = getMallocAllocatedType(CI, TLI);
-+ if (!Ty)
-+ return 0;
-+ Value *arraySize = getMallocArraySize(CI, *TD, TLI);
- #endif
- if (!arraySize) {
- Ty = Type::getInt8Ty(P->getContext());
-@@ -351,7 +385,11 @@ void PointerTracking::getPointerOffset(Value *Pointer, Value *&Base,
- const SCEV *&Offset) const
- {
- Pointer = Pointer->stripPointerCasts();
-+#if LLVM_VERSION < 37
- Base = GetUnderlyingObject(Pointer, TD);
-+#else
-+ Base = GetUnderlyingObject(Pointer, *TD);
-+#endif
- Limit = getAllocationSizeInBytes(Base);
- if (isa<SCEVCouldNotCompute>(Limit)) {
- Base = 0;
-diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp
-index e5aea03..2171993 100644
---- a/libclamav/c++/bytecode2llvm.cpp
-+++ b/libclamav/c++/bytecode2llvm.cpp
-@@ -63,7 +63,11 @@
- #include "llvm/Object/ObjectFile.h"
- #endif
- #include "llvm/ExecutionEngine/JITEventListener.h"
-+#if LLVM_VERSION < 37
- #include "llvm/PassManager.h"
-+#else
-+#include "llvm/IR/LegacyPassManager.h"
-+#endif
- #include "llvm/Support/Compiler.h"
- #include "llvm/Support/Debug.h"
- #include "llvm/Support/CommandLine.h"
-@@ -231,7 +235,9 @@ namespace {
- #define llvm_report_error(x) report_fatal_error(x)
- #define llvm_install_error_handler(x) install_fatal_error_handler(x)
- #define DwarfExceptionHandling JITExceptionHandling
-+#if LLVM_VERSION < 37
- #define SetCurrentDebugLocation(x) SetCurrentDebugLocation(DebugLoc::getFromDILocation(x))
-+#endif
- #define DEFINEPASS(passname) passname() : FunctionPass(ID)
- #else
- #define DEFINEPASS(passname) passname() : FunctionPass(&ID)
-@@ -718,7 +724,11 @@ class RuntimeLimits : public FunctionPass {
- BBMap[BB] = apicalls;
- }
- if (!BackedgeTargets.empty()) {
-+#if LLVM_VERSION < 37
- LoopInfo &LI = getAnalysis<LoopInfo>();
-+#else
-+ LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
-+#endif
- ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
-
- // Now check whether any of these backedge targets are part of a loop
-@@ -802,7 +812,11 @@ class RuntimeLimits : public FunctionPass {
- #endif
- // Load Flag that tells us we timed out (first byte in bc_ctx)
- Value *Cond = Builder.CreateLoad(Flag, true);
-+#if LLVM_VERSION < 37
- BasicBlock *newBB = SplitBlock(BB, BB->getTerminator(), this);
-+#else
-+ BasicBlock *newBB = SplitBlock(BB, BB->getTerminator());
-+#endif
- TerminatorInst *TI = BB->getTerminator();
- BranchInst::Create(AbrtBB, newBB, Cond, TI);
- TI->eraseFromParent();
-@@ -823,7 +837,11 @@ class RuntimeLimits : public FunctionPass {
-
- virtual void getAnalysisUsage(AnalysisUsage &AU) const {
- AU.setPreservesAll();
-+#if LLVM_VERSION < 37
- AU.addRequired<LoopInfo>();
-+#else
-+ AU.addRequired<LoopInfoWrapperPass>();
-+#endif
- AU.addRequired<ScalarEvolution>();
- #if LLVM_VERSION < 35
- AU.addRequired<DominatorTree>();
-@@ -916,7 +934,11 @@ class LLVMCodegen {
- Module *M;
- LLVMContext &Context;
- ExecutionEngine *EE;
-+#if LLVM_VERSION < 37
- FunctionPassManager &PM, &PMUnsigned;
-+#else
-+ legacy::FunctionPassManager &PM, &PMUnsigned;
-+#endif
- LLVMTypeMapper *TypeMap;
-
- Function **apiFuncs;
-@@ -1089,7 +1111,11 @@ class LLVMCodegen {
- Constant *C = ConstantExpr::getPointerCast(GV, IP8Ty);
- //TODO: check constant bounds here
- return ConstantExpr::getPointerCast(
-+#if LLVM_VERSION < 37
- ConstantExpr::getInBoundsGetElementPtr(C, ARRAYREF(Value*, idxs, 1)),
-+#else
-+ ConstantExpr::getInBoundsGetElementPtr(Ty, C, ARRAYREF(Value*, idxs, 1)),
-+#endif
- PTy);
- }
- if (isa<IntegerType>(Ty)) {
-@@ -1118,15 +1144,21 @@ class LLVMCodegen {
-
- public:
- LLVMCodegen(const struct cli_bc *bc, Module *M, struct CommonFunctions *CF, FunctionMapTy &cFuncs,
-+#if LLVM_VERSION < 37
- ExecutionEngine *EE, FunctionPassManager &PM, FunctionPassManager &PMUnsigned,
-+#else
-+ ExecutionEngine *EE, legacy::FunctionPassManager &PM, legacy::FunctionPassManager &PMUnsigned,
-+#endif
- Function **apiFuncs, LLVMTypeMapper &apiMap)
- : bc(bc), M(M), Context(M->getContext()), EE(EE),
- PM(PM),PMUnsigned(PMUnsigned), TypeMap(), apiFuncs(apiFuncs),apiMap(apiMap),
- compiledFunctions(cFuncs), BytecodeID("bc"+Twine(bc->id)),
- #if LLVM_VERSION < 32
- Folder(EE->getTargetData()), Builder(Context, Folder), Values(), CF(CF) {
--#else
-+#elif LLVM_VERSION < 37
- Folder(EE->getDataLayout()), Builder(Context, Folder), Values(), CF(CF) {
-+#else
-+ Folder(*EE->getDataLayout()), Builder(Context, Folder), Values(), CF(CF) {
- #endif
-
- for (unsigned i=0;i<cli_apicall_maxglobal - _FIRST_GLOBAL;i++) {
-@@ -1141,7 +1173,17 @@ class LLVMCodegen {
- template <typename InputIterator>
- #endif
- Value* createGEP(Value *Base, constType *ETy, ARRAYREFPARAM(Value*,InputIterator Start,InputIterator End,ARef)) {
-+#if LLVM_VERSION < 37
- constType *Ty = GetElementPtrInst::getIndexedType(Base->getType(),ARRAYREFP(Start,End,ARef));
-+#else
-+ Type *Ty = NULL;
-+ // This used to be done internally in LLVM's getIndexedTypeInternal.
-+ PointerType *PTy = dyn_cast<PointerType>(Base->getType()->getScalarType());
-+ if (PTy) {
-+ Type *Agg = PTy->getElementType();
-+ Ty = GetElementPtrInst::getIndexedType(Agg,ARRAYREFP(Start,End,ARef));
-+ }
-+#endif
- if (!Ty || (ETy && (Ty != ETy && (!isa<IntegerType>(Ty) || !isa<IntegerType>(ETy))))) {
- if (cli_debug_flag) {
- std::string str;
-@@ -1457,7 +1499,11 @@ class LLVMCodegen {
- if (func->dbgnodes[c] != ~0u) {
- unsigned j = func->dbgnodes[c];
- assert(j < mdnodes.size());
-+#if LLVM_VERSION < 37
- Builder.SetCurrentDebugLocation(mdnodes[j]);
-+#else
-+ Builder.SetCurrentDebugLocation(DebugLoc(mdnodes[j]));
-+#endif
- } else
- Builder.SetCurrentDebugLocation(0);
- }
-@@ -1767,11 +1813,16 @@ class LLVMCodegen {
- #if LLVM_VERSION < 29
- CallInst *c = Builder.CreateCall4(CF->FMemset, Dst, Val, Len,
- ConstantInt::get(Type::getInt32Ty(Context), 1));
--#else
-+#elif LLVM_VERSION < 37
- CallInst *c = Builder.CreateCall5(CF->FMemset, Dst, Val, Len,
- ConstantInt::get(Type::getInt32Ty(Context), 1),
- ConstantInt::get(Type::getInt1Ty(Context), 0)
- );
-+#else
-+ Value *args[] = { Dst, Val, Len,
-+ ConstantInt::get(Type::getInt32Ty(Context), 1),
-+ ConstantInt::get(Type::getInt1Ty(Context), 0)};
-+ CallInst *c = Builder.CreateCall(CF->FMemset, ARRAYREF(Value*, args, args + 5));
- #endif
- c->setTailCall(true);
- c->setDoesNotThrow();
-@@ -1788,11 +1839,16 @@ class LLVMCodegen {
- #if LLVM_VERSION < 29
- CallInst *c = Builder.CreateCall4(CF->FMemcpy, Dst, Src, Len,
- ConstantInt::get(Type::getInt32Ty(Context), 1));
--#else
-+#elif LLVM_VERSION < 37
- CallInst *c = Builder.CreateCall5(CF->FMemcpy, Dst, Src, Len,
- ConstantInt::get(Type::getInt32Ty(Context), 1),
- ConstantInt::get(Type::getInt1Ty(Context), 0)
- );
-+#else
-+ Value *args[] = { Dst, Src, Len,
-+ ConstantInt::get(Type::getInt32Ty(Context), 1),
-+ ConstantInt::get(Type::getInt1Ty(Context), 0)};
-+ CallInst *c = Builder.CreateCall(CF->FMemcpy, ARRAYREF(Value*, args, args + 5));
- #endif
- c->setTailCall(true);
- c->setDoesNotThrow();
-@@ -1809,10 +1865,15 @@ class LLVMCodegen {
- #if LLVM_VERSION < 29
- CallInst *c = Builder.CreateCall4(CF->FMemmove, Dst, Src, Len,
- ConstantInt::get(Type::getInt32Ty(Context), 1));
--#else
-+#elif LLVM_VERSION < 37
- CallInst *c = Builder.CreateCall5(CF->FMemmove, Dst, Src, Len,
- ConstantInt::get(Type::getInt32Ty(Context), 1),
- ConstantInt::get(Type::getInt1Ty(Context), 0));
-+#else
-+ Value *args[] = {Dst, Src, Len,
-+ ConstantInt::get(Type::getInt32Ty(Context), 1),
-+ ConstantInt::get(Type::getInt1Ty(Context), 0)};
-+ CallInst *c = Builder.CreateCall(CF->FMemmove, args);
- #endif
- c->setTailCall(true);
- c->setDoesNotThrow();
-@@ -1830,7 +1891,12 @@ class LLVMCodegen {
- #else
- Value *Len = convertOperand(func, EE->getDataLayout()->getIntPtrType(Context), inst->u.three[2]);
- #endif
-+#if LLVM_VERSION < 37
- CallInst *c = Builder.CreateCall3(CF->FRealmemcmp, Dst, Src, Len);
-+#else
-+ Value *args[] = {Dst, Src, Len};
-+ CallInst *c = Builder.CreateCall(CF->FRealmemcmp, ARRAYREF(Value*, args, args + 3));
-+#endif
- c->setTailCall(true);
- c->setDoesNotThrow();
- Store(inst->dest, c);
-@@ -2211,7 +2277,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
- }
- #if LLVM_VERSION >= 29
- INITIALIZE_PASS_BEGIN(RuntimeLimits, "rl", "Runtime Limits", false, false)
-+#if LLVM_VERSION < 37
- INITIALIZE_PASS_DEPENDENCY(LoopInfo)
-+#else
-+INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
-+#endif
- INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
- #if LLVM_VERSION < 35
- INITIALIZE_PASS_DEPENDENCY(DominatorTree)
-@@ -2437,8 +2507,10 @@ static void addFPasses(FunctionPassManager &FPM, bool trusted, const TargetData
- static void addFPasses(FunctionPassManager &FPM, bool trusted, const DataLayout *TD)
- #elif LLVM_VERSION < 36
- static void addFPasses(FunctionPassManager &FPM, bool trusted, const Module *M)
--#else
-+#elif LLVM_VERSION < 37
- static void addFPasses(FunctionPassManager &FPM, bool trusted, Module *M)
-+#else
-+static void addFPasses(legacy::FunctionPassManager &FPM, bool trusted, Module *M)
- #endif
- {
- // Set up the optimizer pipeline. Start with registering info about how
-@@ -2449,10 +2521,12 @@ static void addFPasses(FunctionPassManager &FPM, bool trusted, Module *M)
- FPM.add(new DataLayout(*TD));
- #elif LLVM_VERSION < 36
- FPM.add(new DataLayoutPass(M));
--#else
-+#elif LLVM_VERSION < 37
- DataLayoutPass *DLP = new DataLayoutPass();
- DLP->doInitialization(*M);
- FPM.add(DLP);
-+#else
-+ // No DataLayout pass needed anymore.
- #endif
- // Promote allocas to registers.
- FPM.add(createPromoteMemoryToRegisterPass());
-@@ -2482,6 +2556,8 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
-
- #if LLVM_VERSION >= 31
- TargetOptions Options;
-+#if LLVM_VERSION < 37
-+ // This option was removed.
- #ifdef CL_DEBUG
- //disable this for now, it leaks
- Options.JITEmitDebugInfo = false;
-@@ -2489,6 +2565,7 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
- #else
- Options.JITEmitDebugInfo = false;
- #endif
-+#endif
- #if LLVM_VERSION < 34
- Options.DwarfExceptionHandling = false;
- #else
-@@ -2525,7 +2602,11 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
- struct CommonFunctions CF;
- addFunctionProtos(&CF, EE, M);
-
-+#if LLVM_VERSION < 37
- FunctionPassManager OurFPM(M), OurFPMUnsigned(M);
-+#else
-+ legacy::FunctionPassManager OurFPM(M), OurFPMUnsigned(M);
-+#endif
- #if LLVM_VERSION < 32
- M->setDataLayout(EE->getTargetData()->getStringRepresentation());
- #else
-@@ -2665,17 +2746,23 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
- break;
- }
- }
-+#if LLVM_VERSION < 37
- PassManager PM;
-+#else
-+ legacy::PassManager PM;
-+#endif
- #if LLVM_VERSION < 32
- PM.add(new TargetData(*EE->getTargetData()));
- #elif LLVM_VERSION < 35
- PM.add(new DataLayout(*EE->getDataLayout()));
- #elif LLVM_VERSION < 36
- PM.add(new DataLayoutPass(M));
--#else
-+#elif LLVM_VERSION < 37
- DataLayoutPass *DLP = new DataLayoutPass();
- DLP->doInitialization(*M);
- PM.add(DLP);
-+#else
-+ // No DataLayout pass needed anymore.
- #endif
- // TODO: only run this on the untrusted bytecodes, not all of them...
- if (has_untrusted)
-@@ -2987,11 +3074,19 @@ static Metadata *findDbgGlobalDeclare(GlobalVariable *V) {
- return 0;
-
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
-+#if LLVM_VERSION < 37
- DIDescriptor DIG(cast<MDNode>(NMD->getOperand(i)));
- if (!DIG.isGlobalVariable())
- continue;
- if (DIGlobalVariable(DIG).getGlobal() == V)
- return DIG;
-+#else
-+ MDNode *DIG = NMD->getOperand(i);
-+ if (!DIGlobalVariable::classof(DIG))
-+ continue;
-+ if ((cast<DIGlobalVariable>(DIG))->getVariable() == V)
-+ return DIG;
-+#endif
- }
- return 0;
- }
-@@ -3008,11 +3103,19 @@ static Metadata *findDbgSubprogramDeclare(Function *V) {
- return 0;
-
- for (unsigned i = 0, e = NMD->getNumOperands(); i != e; ++i) {
-+#if LLVM_VERSION < 37
- DIDescriptor DIG(cast<MDNode>(NMD->getOperand(i)));
- if (!DIG.isSubprogram())
- continue;
- if (DISubprogram(DIG).getFunction() == V)
- return DIG;
-+#else
-+ MDNode *DIG = NMD->getOperand(i);
-+ if (!DISubprogram::classof(DIG))
-+ continue;
-+ if ((cast<DISubprogram>(DIG))->getFunction() == V)
-+ return DIG;
-+#endif
- }
- return 0;
- }
-@@ -3061,22 +3164,39 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
- Metadata *DIGV = findDbgGlobalDeclare(GV);
- #endif
- if (!DIGV) return false;
-+#if LLVM_VERSION < 37
- DIGlobalVariable Var(cast<MDNode>(DIGV));
-+#else
-+ DIGlobalVariable *Var = cast<DIGlobalVariable>(DIGV);
-+#endif
-
-+#if LLVM_VERSION < 37
- StringRef D = Var.getDisplayName();
-+#else
-+ StringRef D = Var->getDisplayName();
-+#endif
- if (!D.empty())
- DisplayName = D;
-+#if LLVM_VERSION < 37
- LineNo = Var.getLineNumber();
-+#else
-+ LineNo = Var->getLine();
-+#endif
- #if LLVM_VERSION < 33
- Unit = Var.getCompileUnit();
--#else
-+#elif LLVM_VERSION < 37
- G = Var.getFilename();
- H = Var.getDirectory();
-+#else
-+ G = Var->getFilename();
-+ H = Var->getDirectory();
- #endif
- #if LLVM_VERSION < 35
- TypeD = Var.getType();
--#else
-+#elif LLVM_VERSION < 37
- T = Var.getType().getName();
-+#else
-+ T = (cast<DIType>(*Var->getType())).getName();
- #endif
- } else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){
- #if LLVM_VERSION < 36
-@@ -3085,32 +3205,61 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
- Metadata *DIF = findDbgSubprogramDeclare(F);
- #endif
- if (!DIF) return false;
-+#if LLVM_VERSION < 37
- DISubprogram Var(cast<MDNode>(DIF));
-+#else
-+ DISubprogram *Var = cast<DISubprogram>(DIF);
-+#endif
-
-+#if LLVM_VERSION < 37
- StringRef D = Var.getDisplayName();
-+#else
-+ StringRef D = Var->getDisplayName();
-+#endif
- if (!D.empty())
- DisplayName = D;
-+#if LLVM_VERSION < 37
- LineNo = Var.getLineNumber();
-+#else
-+ LineNo = Var->getLine();
-+#endif
- #if LLVM_VERSION < 33
- Unit = Var.getCompileUnit();
--#else
-+#elif LLVM_VERSION < 37
- G = Var.getFilename();
- H = Var.getDirectory();
-+#else
-+ G = Var->getFilename();
-+ H = Var->getDirectory();
- #endif
- #if LLVM_VERSION < 35
- TypeD = Var.getType();
--#else
-+#elif LLVM_VERSION < 37
- T = Var.getType().getName();
-+#else
-+ T = Var->getType()->getName();
- #endif
- } else {
- const DbgDeclareInst *DDI = findDbgDeclare(V);
- if (!DDI) return false;
-+#if LLVM_VERSION < 37
- DIVariable Var(cast<MDNode>(DDI->getVariable()));
-+#else
-+ DIVariable* Var = DDI->getVariable();
-+#endif
-
-+#if LLVM_VERSION < 37
- StringRef D = Var.getName();
-+#else
-+ StringRef D = Var->getName();
-+#endif
- if (!D.empty())
- DisplayName = D;
-+#if LLVM_VERSION < 37
- LineNo = Var.getLineNumber();
-+#else
-+ LineNo = Var->getLine();
-+#endif
- #if LLVM_VERSION < 33
- Unit = Var.getCompileUnit();
- #else
-@@ -3120,8 +3269,10 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
- #endif
- #if LLVM_VERSION < 35
- TypeD = Var.getType();
--#else
-+#elif LLVM_VERSION < 37
- T = Var.getType().getName();
-+#else
-+ T = (cast<DIType>(*Var->getType())).getName();
- #endif
- }
-
-@@ -3157,9 +3308,15 @@ void printValue(llvm::Value *V, bool a, bool b) {
-
- void printLocation(llvm::Instruction *I, bool a, bool b) {
- if (MDNode *N = I->getMetadata("dbg")) {
-+#if LLVM_VERSION < 37
- DILocation Loc(N);
- errs() << Loc.getFilename() << ":" << Loc.getLineNumber();
- if (unsigned Col = Loc.getColumnNumber()) {
-+#else
-+ DebugLoc Loc(N);
-+ errs() << Loc.get()->getFilename() << ":" << Loc.getLine();
-+ if (unsigned Col = Loc.getCol()) {
-+#endif
- errs() << ":" << Col;
- }
- errs() << ": ";
-diff --git a/libclamav/c++/m4/llvm-flags.m4 b/libclamav/c++/m4/llvm-flags.m4
-index dce4e10..04d6833 100644
---- a/libclamav/c++/m4/llvm-flags.m4
-+++ b/libclamav/c++/m4/llvm-flags.m4
-@@ -98,14 +98,14 @@ elif test $llvmver_test -lt 290; then
- elif test $llvmver_test -lt 360; then
- llvmcomp="jit nativecodegen scalaropts ipo"
- AC_MSG_RESULT([ok ($llvmver)])
--elif test $llvmver_test -lt 370; then
-+elif test $llvmver_test -lt 380; then
- dnl LLVM 3.6.0 removed jit, so we have to use mcjit
- dnl and we're using InitializeNativeTargetAsmParser, so we need the architecture specific parsers
- llvmcomp="mcjit nativecodegen scalaropts ipo x86asmparser powerpcasmparser"
- AC_MSG_RESULT([ok ($llvmver)])
- else
- AC_MSG_RESULT([no ($llvmver)])
-- AC_MSG_ERROR([LLVM < 3.7 required, but "$llvmver"($llvmver_test) found])
-+ AC_MSG_ERROR([LLVM < 3.8 required, but "$llvmver"($llvmver_test) found])
- fi
-
- dnl aquire the required flags to properly link in external LLVM
diff --git a/libre/clamav/Add-support-for-LLVM-3.8.patch b/libre/clamav/Add-support-for-LLVM-3.8.patch
deleted file mode 100644
index 1d421b3a0..000000000
--- a/libre/clamav/Add-support-for-LLVM-3.8.patch
+++ /dev/null
@@ -1,457 +0,0 @@
-From 3111db3d1a3f2b20a007673f69a53ad69afec2f8 Mon Sep 17 00:00:00 2001
-From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-Date: Fri, 14 Oct 2016 20:24:48 +0200
-Subject: Add support for LLVM 3.8
-
-Main changes:
-llvm/Config/config.h was removed.
-The ScalarEvolution pass is now a WrapperPass.
-Iterators are no longer automatically converted to and from pointers.
-The GVNPass causes the test_bswap_jit test to fail; replaced with
-ConstantPropagationPass.
-LLVMIsMultithreaded is from the C API, while llvm_is_multithreaded is
-the corresponding C++ API.
-
-Patch-Name: Add-support-for-LLVM-3.8.patch
----
- libclamav/c++/ClamBCRTChecks.cpp | 50 ++++++++++++++++++++++++++++++
- libclamav/c++/PointerTracking.cpp | 12 ++++++++
- libclamav/c++/bytecode2llvm.cpp | 65 +++++++++++++++++++++++++++++++--------
- libclamav/c++/detect.cpp | 2 ++
- libclamav/c++/m4/llvm-flags.m4 | 4 +--
- 5 files changed, 119 insertions(+), 14 deletions(-)
-
-diff --git a/libclamav/c++/ClamBCRTChecks.cpp b/libclamav/c++/ClamBCRTChecks.cpp
-index 35f7272..a254c40 100644
---- a/libclamav/c++/ClamBCRTChecks.cpp
-+++ b/libclamav/c++/ClamBCRTChecks.cpp
-@@ -54,7 +54,9 @@
- #include "llvm/Analysis/ScalarEvolution.h"
- #include "llvm/Analysis/ScalarEvolutionExpressions.h"
- #include "llvm/Analysis/ScalarEvolutionExpander.h"
-+#if LLVM_VERSION < 38
- #include "llvm/Config/config.h"
-+#endif
- #include "llvm/Pass.h"
- #include "llvm/Support/CommandLine.h"
- #if LLVM_VERSION < 35
-@@ -207,7 +209,11 @@ namespace llvm {
- #else
- TD = &F.getEntryBlock().getModule()->getDataLayout();
- #endif
-+#if LLVM_VERSION < 38
- SE = &getAnalysis<ScalarEvolution>();
-+#else
-+ SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
-+#endif
- PT = &getAnalysis<PointerTracking>();
- #if LLVM_VERSION < 35
- DT = &getAnalysis<DominatorTree>();
-@@ -332,7 +338,11 @@ namespace llvm {
- AbrtC->setDoesNotThrow();
- #endif
- // remove all instructions from entry
-+#if LLVM_VERSION < 38
- BasicBlock::iterator BBI = I, BBE=BB->end();
-+#else
-+ BasicBlock::iterator BBI = I->getIterator(), BBE=BB->end();
-+#endif
- while (BBI != BBE) {
- if (!BBI->use_empty())
- BBI->replaceAllUsesWith(UndefValue::get(BBI->getType()));
-@@ -367,7 +377,11 @@ namespace llvm {
- #else
- AU.addRequired<DominatorTreeWrapperPass>();
- #endif
-+#if LLVM_VERSION < 38
- AU.addRequired<ScalarEvolution>();
-+#else
-+ AU.addRequired<ScalarEvolutionWrapperPass>();
-+#endif
- AU.addRequired<PointerTracking>();
- #if LLVM_VERSION < 35
- AU.addRequired<CallGraph>();
-@@ -398,9 +412,17 @@ namespace llvm {
-
- Instruction *getInsertPoint(Value *V)
- {
-+#if LLVM_VERSION < 38
- BasicBlock::iterator It = EP;
-+#else
-+ BasicBlock::iterator It = EP->getIterator();
-+#endif
- if (Instruction *I = dyn_cast<Instruction>(V)) {
-+#if LLVM_VERSION < 38
- It = I;
-+#else
-+ It = I->getIterator();
-+#endif
- ++It;
- }
- return &*It;
-@@ -427,7 +449,11 @@ namespace llvm {
- constType *P8Ty =
- PointerType::getUnqual(Type::getInt8Ty(Ptr->getContext()));
- if (PHINode *PN = dyn_cast<PHINode>(Ptr)) {
-+#if LLVM_VERSION < 38
- BasicBlock::iterator It = PN;
-+#else
-+ BasicBlock::iterator It = PN->getIterator();
-+#endif
- ++It;
- PHINode *newPN = PHINode::Create(P8Ty, HINT(PN->getNumIncomingValues()) ".verif.base", &*It);
- Changed = true;
-@@ -441,7 +467,11 @@ namespace llvm {
- return newPN;
- }
- if (SelectInst *SI = dyn_cast<SelectInst>(Ptr)) {
-+#if LLVM_VERSION < 38
- BasicBlock::iterator It = SI;
-+#else
-+ BasicBlock::iterator It = SI->getIterator();
-+#endif
- ++It;
- Value *TrueB = getPointerBase(SI->getTrueValue());
- Value *FalseB = getPointerBase(SI->getFalseValue());
-@@ -552,7 +582,11 @@ namespace llvm {
- }
- #endif
- if (PHINode *PN = dyn_cast<PHINode>(Base)) {
-+#if LLVM_VERSION < 38
- BasicBlock::iterator It = PN;
-+#else
-+ BasicBlock::iterator It = PN->getIterator();
-+#endif
- ++It;
- PHINode *newPN = PHINode::Create(I64Ty, HINT(PN->getNumIncomingValues()) ".verif.bounds", &*It);
- Changed = true;
-@@ -575,7 +609,11 @@ namespace llvm {
- return BoundsMap[Base] = newPN;
- }
- if (SelectInst *SI = dyn_cast<SelectInst>(Base)) {
-+#if LLVM_VERSION < 38
- BasicBlock::iterator It = SI;
-+#else
-+ BasicBlock::iterator It = SI->getIterator();
-+#endif
- ++It;
- Value *TrueB = getPointerBounds(SI->getTrueValue());
- Value *FalseB = getPointerBounds(SI->getFalseValue());
-@@ -632,7 +670,11 @@ namespace llvm {
- if (!MDDbgKind)
- return 0;
- Approximate = true;
-+#if LLVM_VERSION < 38
- BasicBlock::iterator It = I;
-+#else
-+ BasicBlock::iterator It = I->getIterator();
-+#endif
- while (It != I->getParent()->begin()) {
- --It;
- if (MDNode *Dbg = It->getMetadata(MDDbgKind))
-@@ -666,7 +708,11 @@ namespace llvm {
- return false;
- }
- BasicBlock *BB = I->getParent();
-+#if LLVM_VERSION < 38
- BasicBlock::iterator It = I;
-+#else
-+ BasicBlock::iterator It = I->getIterator();
-+#endif
- #if LLVM_VERSION < 37
- BasicBlock *newBB = SplitBlock(BB, &*It, this);
- #else
-@@ -949,7 +995,11 @@ INITIALIZE_PASS_DEPENDENCY(DominatorTree)
- #else
- INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
- #endif
-+#if LLVM_VERSION < 38
- INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
-+#else
-+INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
-+#endif
- #if LLVM_VERSION < 34
- INITIALIZE_AG_DEPENDENCY(CallGraph)
- #elif LLVM_VERSION < 35
-diff --git a/libclamav/c++/PointerTracking.cpp b/libclamav/c++/PointerTracking.cpp
-index 67340e8..ad5b93f 100644
---- a/libclamav/c++/PointerTracking.cpp
-+++ b/libclamav/c++/PointerTracking.cpp
-@@ -79,7 +79,11 @@ INITIALIZE_PASS_DEPENDENCY(LoopInfo)
- #else
- INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
- #endif
-+#if LLVM_VERSION < 38
- INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
-+#else
-+INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
-+#endif
- #if LLVM_VERSION < 35
- INITIALIZE_PASS_DEPENDENCY(DominatorTree)
- #else
-@@ -110,7 +114,11 @@ bool PointerTracking::runOnFunction(Function &F) {
- #else
- TD = &F.getEntryBlock().getModule()->getDataLayout();
- #endif
-+#if LLVM_VERSION < 38
- SE = &getAnalysis<ScalarEvolution>();
-+#else
-+ SE = &getAnalysis<ScalarEvolutionWrapperPass>().getSE();
-+#endif
- #if LLVM_VERSION < 37
- LI = &getAnalysis<LoopInfo>();
- #else
-@@ -135,7 +143,11 @@ void PointerTracking::getAnalysisUsage(AnalysisUsage &AU) const {
- #else
- AU.addRequiredTransitive<LoopInfoWrapperPass>();
- #endif
-+#if LLVM_VERSION < 38
- AU.addRequiredTransitive<ScalarEvolution>();
-+#else
-+ AU.addRequiredTransitive<ScalarEvolutionWrapperPass>();
-+#endif
- AU.setPreservesAll();
- }
-
-diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp
-index 2171993..213847c 100644
---- a/libclamav/c++/bytecode2llvm.cpp
-+++ b/libclamav/c++/bytecode2llvm.cpp
-@@ -170,7 +170,9 @@ void LLVMInitializePowerPCAsmPrinter();
- //#define TIMING
- #undef TIMING
-
-+#if LLVM_VERSION < 38
- #include "llvm/Config/config.h"
-+#endif
- #ifdef ENABLE_THREADS
- #if !ENABLE_THREADS
- #error "Thread support was explicitly disabled. Cannot continue"
-@@ -729,7 +731,11 @@ class RuntimeLimits : public FunctionPass {
- #else
- LoopInfo &LI = getAnalysis<LoopInfoWrapperPass>().getLoopInfo();
- #endif
-+#if LLVM_VERSION < 38
- ScalarEvolution &SE = getAnalysis<ScalarEvolution>();
-+#else
-+ ScalarEvolution &SE = getAnalysis<ScalarEvolutionWrapperPass>().getSE();
-+#endif
-
- // Now check whether any of these backedge targets are part of a loop
- // with a small constant trip count
-@@ -783,7 +789,11 @@ class RuntimeLimits : public FunctionPass {
- new UnreachableInst(F.getContext(), AbrtBB);
- IRBuilder<false> Builder(F.getContext());
-
-+#if LLVM_VERSION < 38
- Value *Flag = F.arg_begin();
-+#else
-+ Value *Flag = &*F.arg_begin();
-+#endif
- #if LLVM_VERSION < 30
- Function *LSBarrier = Intrinsic::getDeclaration(F.getParent(),
- Intrinsic::memory_barrier);
-@@ -797,13 +807,21 @@ class RuntimeLimits : public FunctionPass {
- #endif
- verifyFunction(F);
- BasicBlock *BB = &F.getEntryBlock();
-+#if LLVM_VERSION < 38
- Builder.SetInsertPoint(BB, BB->getTerminator());
-+#else
-+ Builder.SetInsertPoint(BB, BB->getTerminator()->getIterator());
-+#endif
- Flag = Builder.CreatePointerCast(Flag, PointerType::getUnqual(
- Type::getInt1Ty(F.getContext())));
- for (BBSetTy::iterator I=needsTimeoutCheck.begin(),
- E=needsTimeoutCheck.end(); I != E; ++I) {
- BasicBlock *BB = *I;
-+#if LLVM_VERSION < 38
- Builder.SetInsertPoint(BB, BB->getTerminator());
-+#else
-+ Builder.SetInsertPoint(BB, BB->getTerminator()->getIterator());
-+#endif
- #if LLVM_VERSION < 30
- // store-load barrier: will be a no-op on x86 but not other arches
- Builder.CreateCall(LSBarrier, ARRAYREF(Value*, MBArgs, MBArgs+5));
-@@ -842,7 +860,11 @@ class RuntimeLimits : public FunctionPass {
- #else
- AU.addRequired<LoopInfoWrapperPass>();
- #endif
-+#if LLVM_VERSION < 38
- AU.addRequired<ScalarEvolution>();
-+#else
-+ AU.addRequired<ScalarEvolutionWrapperPass>();
-+#endif
- #if LLVM_VERSION < 35
- AU.addRequired<DominatorTree>();
- #else
-@@ -1157,8 +1179,10 @@ class LLVMCodegen {
- Folder(EE->getTargetData()), Builder(Context, Folder), Values(), CF(CF) {
- #elif LLVM_VERSION < 37
- Folder(EE->getDataLayout()), Builder(Context, Folder), Values(), CF(CF) {
--#else
-+#elif LLVM_VERSION < 38
- Folder(*EE->getDataLayout()), Builder(Context, Folder), Values(), CF(CF) {
-+#else
-+ Folder(EE->getDataLayout()), Builder(Context, Folder), Values(), CF(CF) {
- #endif
-
- for (unsigned i=0;i<cli_apicall_maxglobal - _FIRST_GLOBAL;i++) {
-@@ -1319,8 +1343,10 @@ class LLVMCodegen {
- }
- #if LLVM_VERSION < 32
- if (EE->getTargetData()->getPointerSize() == 8) {
--#else
-+#elif LLVM_VERSION < 38
- if (EE->getDataLayout()->getPointerSize() == 8) {
-+#else
-+ if (EE->getDataLayout().getPointerSize() == 8) {
- #endif
- // eliminate useless trunc, GEP can take i64 too
- if (TruncInst *I = dyn_cast<TruncInst>(V)) {
-@@ -1440,7 +1466,11 @@ class LLVMCodegen {
- numArgs = func->numArgs;
-
- if (FakeGVs.any()) {
-+#if LLVM_VERSION < 38
- Argument *Ctx = F->arg_begin();
-+#else
-+ Argument *Ctx = &*F->arg_begin();
-+#endif
- for (unsigned i=0;i<bc->num_globals;i++) {
- if (!FakeGVs[i])
- continue;
-@@ -1888,8 +1918,10 @@ class LLVMCodegen {
- Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context)));
- #if LLVM_VERSION < 32
- Value *Len = convertOperand(func, EE->getTargetData()->getIntPtrType(Context), inst->u.three[2]);
--#else
-+#elif LLVM_VERSION < 38
- Value *Len = convertOperand(func, EE->getDataLayout()->getIntPtrType(Context), inst->u.three[2]);
-+#else
-+ Value *Len = convertOperand(func, EE->getDataLayout().getIntPtrType(Context), inst->u.three[2]);
- #endif
- #if LLVM_VERSION < 37
- CallInst *c = Builder.CreateCall3(CF->FRealmemcmp, Dst, Src, Len);
-@@ -2028,6 +2060,7 @@ class LLVMCodegen {
- PMUnsigned.run(*F);
- PMUnsigned.doFinalization();
- }
-+
- apiMap.pmTimer.stopTimer();
- apiMap.irgenTimer.startTimer();
- }
-@@ -2260,8 +2293,10 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
- args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
- #if LLVM_VERSION < 32
- args.push_back(EE->getTargetData()->getIntPtrType(Context));
--#else
-+#elif LLVM_VERSION < 38
- args.push_back(EE->getDataLayout()->getIntPtrType(Context));
-+#else
-+ args.push_back(EE->getDataLayout().getIntPtrType(Context));
- #endif
- FuncTy_5 = FunctionType::get(Type::getInt32Ty(Context),
- args, false);
-@@ -2282,7 +2317,11 @@ INITIALIZE_PASS_DEPENDENCY(LoopInfo)
- #else
- INITIALIZE_PASS_DEPENDENCY(LoopInfoWrapperPass)
- #endif
-+#if LLVM_VERSION < 38
- INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
-+#else
-+INITIALIZE_PASS_DEPENDENCY(ScalarEvolutionWrapperPass)
-+#endif
- #if LLVM_VERSION < 35
- INITIALIZE_PASS_DEPENDENCY(DominatorTree)
- #else
-@@ -2609,8 +2648,10 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
- #endif
- #if LLVM_VERSION < 32
- M->setDataLayout(EE->getTargetData()->getStringRepresentation());
--#else
-+#elif LLVM_VERSION < 38
- M->setDataLayout(EE->getDataLayout()->getStringRepresentation());
-+#else
-+ M->setDataLayout(EE->getDataLayout().getStringRepresentation());
- #endif
- #if LLVM_VERSION < 31
- M->setTargetTriple(sys::getHostTriple());
-@@ -2767,7 +2808,11 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
- // TODO: only run this on the untrusted bytecodes, not all of them...
- if (has_untrusted)
- PM.add(createClamBCRTChecks());
--#if LLVM_VERSION >= 36
-+#if LLVM_VERSION >= 38
-+ // With LLVM 3.8 the test_bswap_jit test fails with the GVNPass enabled.
-+ // To prevent the segfaults mentioned below, replace it with the ConstantPropagationPass.
-+ PM.add(createConstantPropagationPass());
-+#elif LLVM_VERSION >= 36
- // With LLVM 3.6 (MCJIT) this Pass is required to work around
- // a crash in LLVM caused by the SCCP Pass:
- // Pass 'Sparse Conditional Constant Propagation' is not initialized.
-@@ -2841,7 +2886,7 @@ int bytecode_init(void)
- return CL_EARG;
- }
- #else
-- if (!LLVMIsMultithreaded()) {
-+ if (!llvm_is_multithreaded()) {
- cli_warnmsg("bytecode_init: LLVM is compiled without multithreading support\n");
- }
- #endif
-@@ -2890,11 +2935,7 @@ int bytecode_init(void)
- InitializeAllTargets();
- #endif
-
--#if LLVM_VERSION < 35
- if (!llvm_is_multithreaded()) {
--#else
-- if (!LLVMIsMultithreaded()) {
--#endif
- //TODO:cli_dbgmsg
- DEBUG(errs() << "WARNING: ClamAV JIT built w/o atomic builtins\n"
- << "On x86 for best performance ClamAV should be built for i686, not i386!\n");
-@@ -3113,7 +3154,7 @@ static Metadata *findDbgSubprogramDeclare(Function *V) {
- MDNode *DIG = NMD->getOperand(i);
- if (!DISubprogram::classof(DIG))
- continue;
-- if ((cast<DISubprogram>(DIG))->getFunction() == V)
-+ if ((cast<DISubprogram>(DIG))->describes(V))
- return DIG;
- #endif
- }
-diff --git a/libclamav/c++/detect.cpp b/libclamav/c++/detect.cpp
-index 17348af..95ba2f7 100644
---- a/libclamav/c++/detect.cpp
-+++ b/libclamav/c++/detect.cpp
-@@ -22,7 +22,9 @@
- */
-
- #include "llvm/ADT/Triple.h"
-+#if LLVM_VERSION < 38
- #include "llvm/Config/config.h"
-+#endif
- #include "llvm/Support/raw_ostream.h"
- #if LLVM_VERSION < 29
- #include "llvm/System/DataTypes.h"
-diff --git a/libclamav/c++/m4/llvm-flags.m4 b/libclamav/c++/m4/llvm-flags.m4
-index 04d6833..345c7ae 100644
---- a/libclamav/c++/m4/llvm-flags.m4
-+++ b/libclamav/c++/m4/llvm-flags.m4
-@@ -98,14 +98,14 @@ elif test $llvmver_test -lt 290; then
- elif test $llvmver_test -lt 360; then
- llvmcomp="jit nativecodegen scalaropts ipo"
- AC_MSG_RESULT([ok ($llvmver)])
--elif test $llvmver_test -lt 380; then
-+elif test $llvmver_test -lt 390; then
- dnl LLVM 3.6.0 removed jit, so we have to use mcjit
- dnl and we're using InitializeNativeTargetAsmParser, so we need the architecture specific parsers
- llvmcomp="mcjit nativecodegen scalaropts ipo x86asmparser powerpcasmparser"
- AC_MSG_RESULT([ok ($llvmver)])
- else
- AC_MSG_RESULT([no ($llvmver)])
-- AC_MSG_ERROR([LLVM < 3.8 required, but "$llvmver"($llvmver_test) found])
-+ AC_MSG_ERROR([LLVM < 3.9 required, but "$llvmver"($llvmver_test) found])
- fi
-
- dnl aquire the required flags to properly link in external LLVM
diff --git a/libre/clamav/Add-support-for-LLVM-3.9.patch b/libre/clamav/Add-support-for-LLVM-3.9.patch
deleted file mode 100644
index 084d41c1a..000000000
--- a/libre/clamav/Add-support-for-LLVM-3.9.patch
+++ /dev/null
@@ -1,76 +0,0 @@
-From fef1bbc259bca9cfaac65a85de877f9b7ed27773 Mon Sep 17 00:00:00 2001
-From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
-Date: Fri, 14 Oct 2016 20:24:56 +0200
-Subject: Add support for LLVM 3.9
-
-Changes:
-IRBuilder no longer has a preserveNames template argument.
-AtomicOrdering is now a strongly typed enum.
-
-Patch-Name: Add-support-for-LLVM-3.9.patch
----
- libclamav/c++/bytecode2llvm.cpp | 12 +++++++++++-
- libclamav/c++/m4/llvm-flags.m4 | 4 ++--
- 2 files changed, 13 insertions(+), 3 deletions(-)
-
-diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp
-index 213847c..252f8f6 100644
---- a/libclamav/c++/bytecode2llvm.cpp
-+++ b/libclamav/c++/bytecode2llvm.cpp
-@@ -787,7 +787,11 @@ class RuntimeLimits : public FunctionPass {
- AbrtC->setDoesNotThrow();
- #endif
- new UnreachableInst(F.getContext(), AbrtBB);
-+#if LLVM_VERSION < 39
- IRBuilder<false> Builder(F.getContext());
-+#else
-+ IRBuilder<> Builder(F.getContext());
-+#endif
-
- #if LLVM_VERSION < 38
- Value *Flag = F.arg_begin();
-@@ -825,8 +829,10 @@ class RuntimeLimits : public FunctionPass {
- #if LLVM_VERSION < 30
- // store-load barrier: will be a no-op on x86 but not other arches
- Builder.CreateCall(LSBarrier, ARRAYREF(Value*, MBArgs, MBArgs+5));
--#else
-+#elif LLVM_VERSION < 39
- Builder.CreateFence(Release);
-+#else
-+ Builder.CreateFence(AtomicOrdering::Release);
- #endif
- // Load Flag that tells us we timed out (first byte in bc_ctx)
- Value *Cond = Builder.CreateLoad(Flag, true);
-@@ -969,7 +975,11 @@ class LLVMCodegen {
- Twine BytecodeID;
-
- TargetFolder Folder;
-+#if LLVM_VERSION < 39
- IRBuilder<false, TargetFolder> Builder;
-+#else
-+ IRBuilder<TargetFolder> Builder;
-+#endif
-
- std::vector<Value*> globals;
- DenseMap<unsigned, unsigned> GVoffsetMap;
-diff --git a/libclamav/c++/m4/llvm-flags.m4 b/libclamav/c++/m4/llvm-flags.m4
-index 345c7ae..9631d5d 100644
---- a/libclamav/c++/m4/llvm-flags.m4
-+++ b/libclamav/c++/m4/llvm-flags.m4
-@@ -98,14 +98,14 @@ elif test $llvmver_test -lt 290; then
- elif test $llvmver_test -lt 360; then
- llvmcomp="jit nativecodegen scalaropts ipo"
- AC_MSG_RESULT([ok ($llvmver)])
--elif test $llvmver_test -lt 390; then
-+elif test $llvmver_test -lt 400; then
- dnl LLVM 3.6.0 removed jit, so we have to use mcjit
- dnl and we're using InitializeNativeTargetAsmParser, so we need the architecture specific parsers
- llvmcomp="mcjit nativecodegen scalaropts ipo x86asmparser powerpcasmparser"
- AC_MSG_RESULT([ok ($llvmver)])
- else
- AC_MSG_RESULT([no ($llvmver)])
-- AC_MSG_ERROR([LLVM < 3.9 required, but "$llvmver"($llvmver_test) found])
-+ AC_MSG_ERROR([LLVM < 4.0 required, but "$llvmver"($llvmver_test) found])
- fi
-
- dnl aquire the required flags to properly link in external LLVM
diff --git a/libre/clamav/PKGBUILD b/libre/clamav/PKGBUILD
index b81ff3dfe..00ef191d9 100644
--- a/libre/clamav/PKGBUILD
+++ b/libre/clamav/PKGBUILD
@@ -1,4 +1,4 @@
-# $Id: PKGBUILD 288711 2017-02-11 22:07:31Z foutrelis $
+# $Id: PKGBUILD 292502 2017-04-08 08:19:57Z foutrelis $
# Contributor (Arch): Dale Blount <dale@archlinux.org>
# Contributor (Arch): Gregor Ibic <gregor.ibic@intelicom.si>
# Maintainer (Arch): Gaetan Bisson <bisson@archlinux.org>
@@ -9,7 +9,7 @@
_pkgname=clamav-libre
pkgname=clamav
pkgver=0.99.2
-pkgrel=3.parabola1
+pkgrel=5.parabola1
pkgdesc='Anti-virus toolkit for Unix, without nonfree decompression engine for RAR archives'
url='http://www.clamav.net/'
license=('GPL')
@@ -17,7 +17,7 @@ arch=('i686' 'x86_64' 'armv7h')
makedepends=('libmilter')
makedepends_x86_64=('llvm')
makedepends_i686=("${makedepends_x86_64[@]}")
-depends=('bzip2' 'libltdl' 'libxml2' 'curl')
+depends=('bzip2' 'libltdl' 'libxml2' 'curl' 'pcre')
depends_x86_64=('llvm-libs')
depends_i686=("${depends_x86_64[@]}")
depends_armv7h=('gcc-libs')
@@ -31,21 +31,19 @@ source=("https://repo.parabola.nu/other/${_pkgname}/${_pkgname}-${pkgver}.tar.gz
'freshclam.conf'
'clamd.service'
'freshclamd.service'
- 'Add-support-for-LLVM-3.7.patch'
- 'Add-support-for-LLVM-3.8.patch'
- 'Add-support-for-LLVM-3.9.patch')
-mksha1sums=('c1a47411834d8527f7b40727aebee63f01d488af'
- 'SKIP')
-sha1sums=('f6460a9ce0edb7d76397e4f9b1ebd3cc2c7d544c'
- 'bb488a56b0f6a0760446cde89c1e3321e2717b78'
- 'a224ea9b4d0f4f196827347d54bed51e11c197ea'
- '887f624eb305f2446f55d8339e2972ad0cfe2b79'
- 'b767837d0279ad30b92c314cb762b73e5ad0415e'
- '77899cce83f04cbe134b30da376f879d2841f769'
- 'cda9a087e5593992150cb456e34c5f6f589aca82'
- '89765c80080c84f0a48c295ac11e1a4ce7f4cc14'
- '5a513779e59253b22aefe36451f941866178cc64'
- '16be511156965197f956a0f2147ce1be2a546008')
+ 'clamav-0.99.2-gcc-6.patch'
+ 'make_it_compile_against_openssl_1_1_0.patch')
+mksha256sums=('167bd6a13e05ece326b968fdb539b05c2ffcfef6018a274a10aeda85c2c0027a'
+ 'SKIP')
+sha256sums=('9cbca11e54c78129c0c9495ff40f42e83c34a430e832fdf86c9408bc397d6d07'
+ 'ce4b9b8c300614641af600c9a73b52a00ee8e47ccc9f91b2428a113b0ecff21b'
+ '0a61abee3b9bba94126afe3344e7d8e82da5120ca6dbd2b413b10f75da5b0b0d'
+ 'afdb95f93f7e11e163d368caccd5f6814206c6f0d74816b4f712c0267b50572a'
+ '127b39e13525ffb4242198cfb76f99d4d517e5f2fd9fa8dcad3f31fc9f82f952'
+ 'e376ab0cefeefa5ac5f1cd611718452ea8646198e854aca3cc0026f5ffe58fb4'
+ 'dd5ff6c79ee360da5f2221c4d9110a2a8886d86293f6c93c16bf74fdb126593c'
+ 'b2960553243392a4298f37d5ef537296e989e95f7cc084800b8e3ab6a251be6d'
+ '0a8e02a91bc3f2c99bd52dc475592637376baa991fe3f899b7745b840fc586c5')
backup=('etc/clamav/clamd.conf'
'etc/clamav/freshclam.conf'
@@ -63,19 +61,14 @@ mksource() {
prepare() {
if [ "$CARCH" = i686 -o "$CARCH" = x86_64 ]; then
cd "${srcdir}/${pkgname}-${pkgver}"
- patch -Np1 -i ../Add-support-for-LLVM-3.7.patch
- patch -Np1 -i ../Add-support-for-LLVM-3.8.patch
- patch -Np1 -i ../Add-support-for-LLVM-3.9.patch
- autoreconf -vi libclamav/c++
+ patch -Np1 -i ../clamav-0.99.2-gcc-6.patch
+ patch -Np1 -i ../make_it_compile_against_openssl_1_1_0.patch
+ autoreconf -fi
fi
}
build() {
cd "${srcdir}/${pkgname}-${pkgver}"
- if [ "$CARCH" = i686 -o "$CARCH" = x86_64 ]; then
- local x86_flags="--with-system-llvm \
- --with-llvm-linking=dynamic"
- fi
# --disable-zlib-vcheck because the configure script thinks that
# zlib 1.2.11 is older than 1.2.2
./configure \
@@ -86,8 +79,9 @@ build() {
--disable-clamav \
--disable-zlib-vcheck \
--enable-milter \
- --disable-unrar \
- $x86_flags
+ --disable-unrar
+
+ sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
make
}
diff --git a/libre/clamav/clamav-0.99.2-gcc-6.patch b/libre/clamav/clamav-0.99.2-gcc-6.patch
new file mode 100644
index 000000000..2031edbd3
--- /dev/null
+++ b/libre/clamav/clamav-0.99.2-gcc-6.patch
@@ -0,0 +1,84 @@
+diff --git a/libclamav/c++/llvm/include/llvm/ADT/StringMap.h b/libclamav/c++/llvm/include/llvm/ADT/StringMap.h
+index 59ff6aa..1325394 100644
+--- a/libclamav/c++/llvm/include/llvm/ADT/StringMap.h
++++ b/libclamav/c++/llvm/include/llvm/ADT/StringMap.h
+@@ -169,3 +169,3 @@ public:
+ KeyLength+1;
+- unsigned Alignment = alignof<StringMapEntry>();
++ unsigned Alignment = alignOf<StringMapEntry>();
+
+diff --git a/libclamav/c++/llvm/include/llvm/CodeGen/SlotIndexes.h b/libclamav/c++/llvm/include/llvm/CodeGen/SlotIndexes.h
+index 88044c7..86b0f40 100644
+--- a/libclamav/c++/llvm/include/llvm/CodeGen/SlotIndexes.h
++++ b/libclamav/c++/llvm/include/llvm/CodeGen/SlotIndexes.h
+@@ -417,3 +417,3 @@ namespace llvm {
+ ileAllocator.Allocate(sizeof(IndexListEntry),
+- alignof<IndexListEntry>()));
++ alignOf<IndexListEntry>()));
+
+diff --git a/libclamav/c++/llvm/include/llvm/Support/AlignOf.h b/libclamav/c++/llvm/include/llvm/Support/AlignOf.h
+index 6a7a1a6..979e597 100644
+--- a/libclamav/c++/llvm/include/llvm/Support/AlignOf.h
++++ b/libclamav/c++/llvm/include/llvm/Support/AlignOf.h
+@@ -51,8 +51,8 @@ struct AlignOf {
+
+-/// alignof - A templated function that returns the mininum alignment of
++/// alignOf - A templated function that returns the mininum alignment of
+ /// of a type. This provides no extra functionality beyond the AlignOf
+ /// class besides some cosmetic cleanliness. Example usage:
+-/// alignof<int>() returns the alignment of an int.
++/// alignOf<int>() returns the alignment of an int.
+ template <typename T>
+-static inline unsigned alignof() { return AlignOf<T>::Alignment; }
++static inline unsigned alignOf() { return AlignOf<T>::Alignment; }
+
+diff --git a/libclamav/c++/llvm/include/llvm/Support/Allocator.h b/libclamav/c++/llvm/include/llvm/Support/Allocator.h
+index 4a7251f..17caf5e 100644
+--- a/libclamav/c++/llvm/include/llvm/Support/Allocator.h
++++ b/libclamav/c++/llvm/include/llvm/Support/Allocator.h
+@@ -203,3 +203,3 @@ public:
+ for (char *Ptr = (char*)(Slab+1); Ptr < End; Ptr += sizeof(T)) {
+- Ptr = Allocator.AlignPtr(Ptr, alignof<T>());
++ Ptr = Allocator.AlignPtr(Ptr, alignOf<T>());
+ if (Ptr + sizeof(T) <= End)
+diff --git a/libclamav/c++/llvm/lib/Analysis/ScalarEvolution.cpp b/libclamav/c++/llvm/lib/Analysis/ScalarEvolution.cpp
+index b892d85..dc72346 100644
+--- a/libclamav/c++/llvm/lib/Analysis/ScalarEvolution.cpp
++++ b/libclamav/c++/llvm/lib/Analysis/ScalarEvolution.cpp
+@@ -495,3 +495,3 @@ void SCEVUnknown::print(raw_ostream &OS) const {
+ if (isAlignOf(AllocTy)) {
+- OS << "alignof(" << *AllocTy << ")";
++ OS << "alignOf(" << *AllocTy << ")";
+ return;
+diff --git a/libclamav/c++/llvm/lib/Target/X86/X86CodeEmitter.cpp b/libclamav/c++/llvm/lib/Target/X86/X86CodeEmitter.cpp
+index 824021c..757ca50 100644
+--- a/libclamav/c++/llvm/lib/Target/X86/X86CodeEmitter.cpp
++++ b/libclamav/c++/llvm/lib/Target/X86/X86CodeEmitter.cpp
+@@ -569,3 +569,3 @@ void Emitter<CodeEmitter>::emitMemModRMByte(const MachineInstr &MI,
+ // Calculate what the SS field value should be...
+- static const unsigned SSTable[] = { ~0, 0, 1, ~0, 2, ~0, ~0, ~0, 3 };
++ static const unsigned SSTable[] = { ~0u, 0u, 1u, ~0u, 2u, ~0u, ~0u, ~0u, 3u };
+ unsigned SS = SSTable[Scale.getImm()];
+diff --git a/libclamav/c++/llvm/lib/Target/X86/X86MCCodeEmitter.cpp b/libclamav/c++/llvm/lib/Target/X86/X86MCCodeEmitter.cpp
+index 9564fe0..b2b7986 100644
+--- a/libclamav/c++/llvm/lib/Target/X86/X86MCCodeEmitter.cpp
++++ b/libclamav/c++/llvm/lib/Target/X86/X86MCCodeEmitter.cpp
+@@ -332,3 +332,3 @@ void X86MCCodeEmitter::EmitMemModRMByte(const MCInst &MI, unsigned Op,
+ // Calculate what the SS field value should be...
+- static const unsigned SSTable[] = { ~0, 0, 1, ~0, 2, ~0, ~0, ~0, 3 };
++ static const unsigned SSTable[] = { ~0u, 0u, 1u, ~0u, 2u, ~0u, ~0u, ~0u, 3u };
+ unsigned SS = SSTable[Scale.getImm()];
+diff --git a/libclamav/mpool.c b/libclamav/mpool.c
+index cd38e15..b5e537d 100644
+--- a/libclamav/mpool.c
++++ b/libclamav/mpool.c
+@@ -417,3 +417,3 @@ static size_t from_bits(unsigned int bits) {
+
+-static inline unsigned int alignof(size_t size)
++static inline unsigned int alignOf(size_t size)
+ {
+@@ -609,3 +609,3 @@ static void* allocate_aligned(struct MPMAP *mpm, size_t size, unsigned align, co
+ void *mpool_malloc(struct MP *mp, size_t size) {
+- size_t align = alignof(size);
++ size_t align = alignOf(size);
+ size_t i, needed = align_increase(size+FRAG_OVERHEAD, align);
diff --git a/libre/clamav/make_it_compile_against_openssl_1_1_0.patch b/libre/clamav/make_it_compile_against_openssl_1_1_0.patch
new file mode 100644
index 000000000..2974fe5f8
--- /dev/null
+++ b/libre/clamav/make_it_compile_against_openssl_1_1_0.patch
@@ -0,0 +1,98 @@
+From 088af365ce4f715b9f1d41754651e01db6ebf39a Mon Sep 17 00:00:00 2001
+From: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
+Date: Sat, 2 Jul 2016 00:12:01 +0200
+Subject: make it compile against openssl 1.1.0
+
+- SSL_library_init() is no longer a function but a define invoking
+ another function with parameters. Thus a link check against this
+ function will fail. As a fix AC_LINK_IFELSE is used so the header file
+ can be included.
+
+- X509_CRL is opaque and needs an accessor. X509_CRL_get_nextUpdate() is
+ around since OpenSSL 0.9.1c. X509_cmp_current_time() seems to be
+ around since SSLeay 0.8.1b.
+
+BTS: https://bugs.debian.org/828083
+clamav: https://bugzilla.clamav.net/show_bug.cgi?id=11594
+Patch-Name: make_it_compile_against_openssl_1_1_0.patch
+
+Signed-off-by: Sebastian Andrzej Siewior <sebastian@breakpoint.cc>
+---
+ libclamav/crypto.c | 21 ++++++---------------
+ m4/reorganization/libs/openssl.m4 | 12 +++++++++---
+ 2 files changed, 15 insertions(+), 18 deletions(-)
+
+diff --git a/libclamav/crypto.c b/libclamav/crypto.c
+index c62c65a..4be900f 100644
+--- a/libclamav/crypto.c
++++ b/libclamav/crypto.c
+@@ -1096,7 +1096,6 @@ X509_CRL *cl_load_crl(const char *file)
+ {
+ X509_CRL *x=NULL;
+ FILE *fp;
+- struct tm *tm;
+
+ if (!(file))
+ return NULL;
+@@ -1110,21 +1109,13 @@ X509_CRL *cl_load_crl(const char *file)
+ fclose(fp);
+
+ if ((x)) {
+- tm = cl_ASN1_GetTimeT(x->crl->nextUpdate);
+- if (!(tm)) {
+- X509_CRL_free(x);
+- return NULL;
+- }
++ ASN1_TIME *tme;
+
+-#if !defined(_WIN32)
+- if (timegm(tm) < time(NULL)) {
+- X509_CRL_free(x);
+- free(tm);
+- return NULL;
+- }
+-#endif
+-
+- free(tm);
++ tme = X509_CRL_get_nextUpdate(x);
++ if (!tme || X509_cmp_current_time(tme) < 0) {
++ X509_CRL_free(x);
++ return NULL;
++ }
+ }
+
+ return x;
+diff --git a/m4/reorganization/libs/openssl.m4 b/m4/reorganization/libs/openssl.m4
+index 78e2c23..45ee02d 100644
+--- a/m4/reorganization/libs/openssl.m4
++++ b/m4/reorganization/libs/openssl.m4
+@@ -26,12 +26,13 @@ save_LDFLAGS="$LDFLAGS"
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+
+-SSL_LIBS="-lssl -lcrypto -lz"
++SSL_LIBS="$LIBS -lssl -lcrypto -lz"
++LIBS="$LIBS $SSL_LIBS"
+
+ if test "$LIBSSL_HOME" != "/usr"; then
+ SSL_LDFLAGS="-L$LIBSSL_HOME/lib"
+ SSL_CPPFLAGS="-I$LIBSSL_HOME/include"
+- LDFLAGS="-L$LIBSSL_HOME/lib $SSL_LIBS"
++ LDFLAGS="-L$LIBSSL_HOME/lib"
+ CFLAGS="$SSL_CPPFLAGS"
+ else
+ SSL_LDFLAGS=""
+@@ -41,7 +42,12 @@ fi
+ have_ssl="no"
+ have_crypto="no"
+
+-AC_CHECK_LIB([ssl], [SSL_library_init], [have_ssl="yes"], [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])], [-lcrypto -lz])
++AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM([[#include <openssl/ssl.h>]],
++ [[SSL_library_init();]])],
++ [have_ssl="yes";],
++ [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])])
++
+
+ AC_CHECK_LIB([crypto], [EVP_EncryptInit], [have_crypto="yes"], [AC_MSG_ERROR([Your OpenSSL installation is misconfigured or missing])], [-lcrypto -lz])
+