~ubuntu-branches/ubuntu/saucy/clamav/saucy-backports

« back to all changes in this revision

Viewing changes to debian/patches/0004-Fix-FTBFS-with-LLVM-3.1-3.4.patch

  • Committer: Package Import Robot
  • Author(s): Scott Kitterman
  • Date: 2014-07-15 01:08:10 UTC
  • mfrom: (0.35.47 sid)
  • Revision ID: package-import@ubuntu.com-20140715010810-ru66ek4fun2iseba
Tags: 0.98.4+dfsg-2~ubuntu13.10.1
No-change backport to saucy (LP: #1341962)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From afdd6526fe20e5dd8ca3946abcbfc07e564eec08 Mon Sep 17 00:00:00 2001
 
2
From: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
 
3
Date: Fri, 2 May 2014 16:04:52 +0200
 
4
Subject: Fix FTBFS with LLVM 3.1-3.4
 
5
 
 
6
Fixed detection of LLVM versions like 3.4.2 as 34.
 
7
---
 
8
 libclamav/c++/ClamBCRTChecks.cpp  |  80 ++++++++++++--
 
9
 libclamav/c++/Makefile.am         |   3 +-
 
10
 libclamav/c++/PointerTracking.cpp |  45 +++++++-
 
11
 libclamav/c++/PointerTracking.h   |  15 ++-
 
12
 libclamav/c++/bytecode2llvm.cpp   | 227 ++++++++++++++++++++++++++++++++++----
 
13
 libclamav/c++/configure.ac        |  21 +++-
 
14
 libclamav/c++/detect.cpp          |  13 +++
 
15
 7 files changed, 365 insertions(+), 39 deletions(-)
 
16
 
 
17
diff --git a/libclamav/c++/ClamBCRTChecks.cpp b/libclamav/c++/ClamBCRTChecks.cpp
 
18
index 634700d..380c015 100644
 
19
--- a/libclamav/c++/ClamBCRTChecks.cpp
 
20
+++ b/libclamav/c++/ClamBCRTChecks.cpp
 
21
@@ -27,7 +27,6 @@
 
22
 #include "llvm/ADT/SCCIterator.h"
 
23
 #include "llvm/Analysis/CallGraph.h"
 
24
 #include "llvm/Analysis/Verifier.h"
 
25
-#include "llvm/Analysis/DebugInfo.h"
 
26
 #include "llvm/Analysis/Dominators.h"
 
27
 #include "llvm/Analysis/ConstantFolding.h"
 
28
 //#include "llvm/Analysis/LiveValues.h"
 
29
@@ -42,25 +41,49 @@
 
30
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
 
31
 #include "llvm/Analysis/ScalarEvolutionExpander.h"
 
32
 #include "llvm/Config/config.h"
 
33
-#include "llvm/DerivedTypes.h"
 
34
-#include "llvm/Instructions.h"
 
35
-#include "llvm/IntrinsicInst.h"
 
36
-#include "llvm/Intrinsics.h"
 
37
-#include "llvm/LLVMContext.h"
 
38
-#include "llvm/Module.h"
 
39
 #include "llvm/Pass.h"
 
40
 #include "llvm/Support/CommandLine.h"
 
41
 #include "llvm/Support/DataFlow.h"
 
42
 #include "llvm/Support/InstIterator.h"
 
43
-#include "llvm/Support/InstVisitor.h"
 
44
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 
45
 #include "llvm/ADT/DepthFirstIterator.h"
 
46
-#include "llvm/Target/TargetData.h"
 
47
 #include "llvm/Transforms/Scalar.h"
 
48
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
 
49
 #include "llvm/Support/Debug.h"
 
50
 #include "llvm30_compat.h"
 
51
 
 
52
+#if LLVM_VERSION < 32
 
53
+#include "llvm/Analysis/DebugInfo.h"
 
54
+#else
 
55
+#include "llvm/DebugInfo.h"
 
56
+#endif
 
57
+
 
58
+#if LLVM_VERSION < 32
 
59
+#include "llvm/Target/TargetData.h"
 
60
+#elif LLVM_VERSION < 33
 
61
+#include "llvm/DataLayout.h"
 
62
+#else
 
63
+#include "llvm/IR/DataLayout.h"
 
64
+#endif
 
65
+
 
66
+#if LLVM_VERSION < 33
 
67
+#include "llvm/DerivedTypes.h"
 
68
+#include "llvm/Instructions.h"
 
69
+#include "llvm/IntrinsicInst.h"
 
70
+#include "llvm/Intrinsics.h"
 
71
+#include "llvm/LLVMContext.h"
 
72
+#include "llvm/Module.h"
 
73
+#include "llvm/Support/InstVisitor.h"
 
74
+#else
 
75
+#include "llvm/IR/DerivedTypes.h"
 
76
+#include "llvm/IR/Instructions.h"
 
77
+#include "llvm/IR/IntrinsicInst.h"
 
78
+#include "llvm/IR/Intrinsics.h"
 
79
+#include "llvm/IR/LLVMContext.h"
 
80
+#include "llvm/IR/Module.h"
 
81
+#include "llvm/InstVisitor.h"
 
82
+#endif
 
83
+
 
84
 #ifndef LLVM28
 
85
 #define LLVM28
 
86
 #endif
 
87
@@ -72,7 +95,11 @@
 
88
 
 
89
 using namespace llvm;
 
90
 #ifndef LLVM29
 
91
+#if LLVM_VERSION < 32
 
92
 static Value *GetUnderlyingObject(Value *P, TargetData *TD)
 
93
+#else
 
94
+static Value *GetUnderlyingObject(Value *P, DataLayout *TD)
 
95
+#endif
 
96
 {
 
97
     return P->getUnderlyingObject();
 
98
 }
 
99
@@ -137,8 +164,11 @@ namespace llvm {
 
100
       BasicBlock::iterator It = F.getEntryBlock().begin();
 
101
       while (isa<AllocaInst>(It) || isa<PHINode>(It)) ++It;
 
102
       EP = &*It;
 
103
-
 
104
+#if LLVM_VERSION < 32
 
105
       TD = &getAnalysis<TargetData>();
 
106
+#else
 
107
+      TD = &getAnalysis<DataLayout>();
 
108
+#endif
 
109
       SE = &getAnalysis<ScalarEvolution>();
 
110
       PT = &getAnalysis<PointerTracking>();
 
111
       DT = &getAnalysis<DominatorTree>();
 
112
@@ -247,8 +277,13 @@ namespace llvm {
 
113
        CallInst *AbrtC = CallInst::Create(func_abort, "", UI);
 
114
         AbrtC->setCallingConv(CallingConv::C);
 
115
         AbrtC->setTailCall(true);
 
116
+#if LLVM_VERSION < 32
 
117
         AbrtC->setDoesNotReturn(true);
 
118
         AbrtC->setDoesNotThrow(true);
 
119
+#else
 
120
+        AbrtC->setDoesNotReturn();
 
121
+        AbrtC->setDoesNotThrow();
 
122
+#endif
 
123
        // remove all instructions from entry
 
124
        BasicBlock::iterator BBI = I, BBE=BB->end();
 
125
        while (BBI != BBE) {
 
126
@@ -265,7 +300,11 @@ namespace llvm {
 
127
     }
 
128
 
 
129
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
 
130
+#if LLVM_VERSION < 32
 
131
       AU.addRequired<TargetData>();
 
132
+#else
 
133
+      AU.addRequired<DataLayout>();
 
134
+#endif
 
135
       AU.addRequired<DominatorTree>();
 
136
       AU.addRequired<ScalarEvolution>();
 
137
       AU.addRequired<PointerTracking>();
 
138
@@ -275,7 +314,11 @@ namespace llvm {
 
139
     bool isValid() const { return valid; }
 
140
   private:
 
141
     PointerTracking *PT;
 
142
+#if LLVM_VERSION < 32
 
143
     TargetData *TD;
 
144
+#else
 
145
+    DataLayout *TD;
 
146
+#endif
 
147
     ScalarEvolution *SE;
 
148
     DominatorTree *DT;
 
149
     DenseMap<Value*, Value*> BaseMap;
 
150
@@ -511,13 +554,22 @@ namespace llvm {
 
151
           CallInst *RtErrCall = CallInst::Create(func_rterr, PN, "", AbrtBB);
 
152
           RtErrCall->setCallingConv(CallingConv::C);
 
153
           RtErrCall->setTailCall(true);
 
154
+#if LLVM_VERSION < 32
 
155
           RtErrCall->setDoesNotThrow(true);
 
156
+#else
 
157
+          RtErrCall->setDoesNotThrow();
 
158
+#endif
 
159
         }
 
160
         CallInst* AbrtC = CallInst::Create(func_abort, "", AbrtBB);
 
161
         AbrtC->setCallingConv(CallingConv::C);
 
162
         AbrtC->setTailCall(true);
 
163
+#if LLVM_VERSION < 32
 
164
         AbrtC->setDoesNotReturn(true);
 
165
         AbrtC->setDoesNotThrow(true);
 
166
+#else
 
167
+        AbrtC->setDoesNotReturn();
 
168
+        AbrtC->setDoesNotThrow();
 
169
+#endif
 
170
         new UnreachableInst(BB->getContext(), AbrtBB);
 
171
         DT->addNewBlock(AbrtBB, BB);
 
172
         //verifyFunction(*BB->getParent());
 
173
@@ -732,10 +784,18 @@ namespace llvm {
 
174
 }
 
175
 #ifdef LLVM30
 
176
 INITIALIZE_PASS_BEGIN(PtrVerifier, "", "", false, false)
 
177
+#if LLVM_VERSION < 32
 
178
 INITIALIZE_PASS_DEPENDENCY(TargetData)
 
179
+#else
 
180
+INITIALIZE_PASS_DEPENDENCY(DataLayout)
 
181
+#endif
 
182
 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
 
183
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
 
184
+#if LLVM_VERSION < 34
 
185
 INITIALIZE_AG_DEPENDENCY(CallGraph)
 
186
+#else
 
187
+INITIALIZE_PASS_DEPENDENCY(CallGraph)
 
188
+#endif
 
189
 INITIALIZE_PASS_DEPENDENCY(PointerTracking)
 
190
 INITIALIZE_PASS_END(PtrVerifier, "clambcrtchecks", "ClamBC RTchecks", false, false)
 
191
 #endif
 
192
diff --git a/libclamav/c++/Makefile.am b/libclamav/c++/Makefile.am
 
193
index 599321d..d8c8244 100644
 
194
--- a/libclamav/c++/Makefile.am
 
195
+++ b/libclamav/c++/Makefile.am
 
196
@@ -38,6 +38,7 @@ libclamavcxx_la_CXXFLAGS = $(AM_CPPFLAGS) @LLVMCONFIG_CXXFLAGS@ -fexceptions -DL
 
197
 if BUILD_LLVM3
 
198
 libclamavcxx_la_CXXFLAGS += -DLLVM30
 
199
 endif
 
200
+libclamavcxx_la_CXXFLAGS += -DLLVM_VERSION=${LLVM_VERSION}
 
201
 libclamavcxx_la_LDFLAGS = @LLVMCONFIG_LDFLAGS@ @LLVMCONFIG_LIBS@
 
202
 libclamavcxx_la_DEPENDENCIES = @LLVMCONFIG_LIBFILES@
 
203
 noinst_LTLIBRARIES = libclamavcxx.la
 
204
@@ -51,7 +52,7 @@ noinst_LTLIBRARIES = libclamavcxx.la libllvmsystem.la\
 
205
 libclamavcxx_la_LIBADD=libllvmjit.la
 
206
 libclamavcxx_la_DEPENDENCIES=libllvmjit.la libllvmcodegen.la libllvmsystem.la
 
207
 libclamavcxx_la_LDFLAGS=-no-undefined
 
208
-libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS)
 
209
+libclamavcxx_la_CXXFLAGS = $(LLVM_CXXFLAGS) -DLLVM_VERSION=${LLVM_VERSION}
 
210
 
 
211
 
 
212
 if BUILD_X86
 
213
diff --git a/libclamav/c++/PointerTracking.cpp b/libclamav/c++/PointerTracking.cpp
 
214
index da559cf..e853bd3 100644
 
215
--- a/libclamav/c++/PointerTracking.cpp
 
216
+++ b/libclamav/c++/PointerTracking.cpp
 
217
@@ -23,19 +23,36 @@
 
218
 #include "PointerTracking.h"
 
219
 #include "llvm/Analysis/ScalarEvolution.h"
 
220
 #include "llvm/Analysis/ScalarEvolutionExpressions.h"
 
221
-#include "llvm/Constants.h"
 
222
-#include "llvm/Module.h"
 
223
-#include "llvm/Value.h"
 
224
 #include "llvm/Support/CallSite.h"
 
225
 #include "llvm/Support/InstIterator.h"
 
226
 #include "llvm/Support/raw_ostream.h"
 
227
+#include "llvm/Target/TargetLibraryInfo.h"
 
228
+
 
229
+#if LLVM_VERSION < 32
 
230
 #include "llvm/Target/TargetData.h"
 
231
+#elif LLVM_VERSION < 33
 
232
+#include "llvm/DataLayout.h"
 
233
+#else
 
234
+#include "llvm/IR/DataLayout.h"
 
235
+#endif
 
236
+
 
237
+#if LLVM_VERSION < 33
 
238
+#include "llvm/Constants.h"
 
239
+#include "llvm/Module.h"
 
240
+#include "llvm/Value.h"
 
241
+#else
 
242
+#include "llvm/IR/Constants.h"
 
243
+#include "llvm/IR/Module.h"
 
244
+#include "llvm/IR/Value.h"
 
245
+#endif
 
246
+
 
247
 using namespace llvm;
 
248
 namespace llvm {
 
249
     void initializePointerTrackingPass(llvm::PassRegistry&);
 
250
 };
 
251
 INITIALIZE_PASS_BEGIN(PointerTracking, "pointertracking",
 
252
                 "Track pointer bounds", false, true)
 
253
+
 
254
 INITIALIZE_PASS_DEPENDENCY(DominatorTree)
 
255
 INITIALIZE_PASS_DEPENDENCY(LoopInfo)
 
256
 INITIALIZE_PASS_DEPENDENCY(ScalarEvolution)
 
257
@@ -52,7 +69,11 @@ bool PointerTracking::runOnFunction(Function &F) {
 
258
   predCache.clear();
 
259
   assert(analyzing.empty());
 
260
   FF = &F;
 
261
+#if LLVM_VERSION < 32
 
262
   TD = getAnalysisIfAvailable<TargetData>();
 
263
+#else
 
264
+  TD = getAnalysisIfAvailable<DataLayout>();
 
265
+#endif
 
266
   SE = &getAnalysis<ScalarEvolution>();
 
267
   LI = &getAnalysis<LoopInfo>();
 
268
   DT = &getAnalysis<DominatorTree>();
 
269
@@ -119,9 +140,17 @@ const SCEV *PointerTracking::computeAllocationCount(Value *P,
 
270
     return SE->getSCEV(arraySize);
 
271
   }
 
272
 
 
273
+#if LLVM_VERSION < 32
 
274
   if (CallInst *CI = extractMallocCall(V)) {
 
275
     Value *arraySize = getMallocArraySize(CI, TD);
 
276
     constType* AllocTy = getMallocAllocatedType(CI);
 
277
+#else
 
278
+  TargetLibraryInfo* TLI = new TargetLibraryInfo();
 
279
+
 
280
+  if (CallInst *CI = extractMallocCall(V, TLI)) {
 
281
+    Value *arraySize = getMallocArraySize(CI, TD, TLI);
 
282
+    constType* AllocTy = getMallocAllocatedType(CI, TLI);
 
283
+#endif
 
284
     if (!AllocTy || !arraySize) return SE->getCouldNotCompute();
 
285
     Ty = AllocTy;
 
286
     // arraySize elements of type Ty.
 
287
@@ -171,11 +200,21 @@ Value *PointerTracking::computeAllocationCountValue(Value *P, constType *&Ty) co
 
288
     return AI->getArraySize();
 
289
   }
 
290
 
 
291
+#if LLVM_VERSION < 32
 
292
   if (CallInst *CI = extractMallocCall(V)) {
 
293
     Ty = getMallocAllocatedType(CI);
 
294
     if (!Ty)
 
295
       return 0;
 
296
     Value *arraySize = getMallocArraySize(CI, TD);
 
297
+#else
 
298
+  TargetLibraryInfo* TLI = new TargetLibraryInfo();
 
299
+
 
300
+  if (CallInst *CI = extractMallocCall(V, TLI)) {
 
301
+    Ty = getMallocAllocatedType(CI, TLI);
 
302
+    if (!Ty)
 
303
+      return 0;
 
304
+    Value *arraySize = getMallocArraySize(CI, TD, TLI);
 
305
+#endif
 
306
     if (!arraySize) {
 
307
       Ty = Type::getInt8Ty(P->getContext());
 
308
       return CI->getArgOperand(0);
 
309
diff --git a/libclamav/c++/PointerTracking.h b/libclamav/c++/PointerTracking.h
 
310
index 20eee22..3429991 100644
 
311
--- a/libclamav/c++/PointerTracking.h
 
312
+++ b/libclamav/c++/PointerTracking.h
 
313
@@ -29,18 +29,27 @@
 
314
 
 
315
 #include "llvm/ADT/SmallPtrSet.h"
 
316
 #include "llvm/Analysis/Dominators.h"
 
317
-#include "llvm/Instructions.h"
 
318
 #include "llvm/Pass.h"
 
319
 #include "llvm/Support/PredIteratorCache.h"
 
320
 #include "llvm30_compat.h"
 
321
 
 
322
+#if LLVM_VERSION < 33
 
323
+#include "llvm/Instructions.h"
 
324
+#else
 
325
+#include "llvm/IR/Instructions.h"
 
326
+#endif
 
327
+
 
328
 namespace llvm {
 
329
   class DominatorTree;
 
330
   class ScalarEvolution;
 
331
   class SCEV;
 
332
   class Loop;
 
333
   class LoopInfo;
 
334
+#if LLVM_VERSION < 32
 
335
   class TargetData;
 
336
+#else
 
337
+  class DataLayout;
 
338
+#endif
 
339
 
 
340
   // Result from solver, assuming pointer is not NULL,
 
341
   // and it is not a use-after-free situation.
 
342
@@ -106,7 +115,11 @@ namespace llvm {
 
343
     Value *computeAllocationCountValue(Value *P, constType *&Ty) const;
 
344
   private:
 
345
     Function *FF;
 
346
+#if LLVM_VERSION < 32
 
347
     TargetData *TD;
 
348
+#else
 
349
+    DataLayout *TD;
 
350
+#endif
 
351
     ScalarEvolution *SE;
 
352
     LoopInfo *LI;
 
353
     DominatorTree *DT;
 
354
diff --git a/libclamav/c++/bytecode2llvm.cpp b/libclamav/c++/bytecode2llvm.cpp
 
355
index 41b3112..b0176b2 100644
 
356
--- a/libclamav/c++/bytecode2llvm.cpp
 
357
+++ b/libclamav/c++/bytecode2llvm.cpp
 
358
@@ -27,7 +27,6 @@
 
359
 
 
360
 #include "ClamBCModule.h"
 
361
 #include "ClamBCDiagnostics.h"
 
362
-#include "llvm/Analysis/DebugInfo.h"
 
363
 #include "llvm/ADT/DenseMap.h"
 
364
 #include "llvm/ADT/BitVector.h"
 
365
 #include "llvm/ADT/PostOrderIterator.h"
 
366
@@ -40,15 +39,9 @@
 
367
 #include "llvm/Analysis/ScalarEvolution.h"
 
368
 #include "llvm/Analysis/Verifier.h"
 
369
 #include "llvm/AutoUpgrade.h"
 
370
-#include "llvm/CallingConv.h"
 
371
-#include "llvm/DerivedTypes.h"
 
372
-#include "llvm/Function.h"
 
373
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 
374
 #include "llvm/ExecutionEngine/JIT.h"
 
375
 #include "llvm/ExecutionEngine/JITEventListener.h"
 
376
-#include "llvm/LLVMContext.h"
 
377
-#include "llvm/Intrinsics.h"
 
378
-#include "llvm/Module.h"
 
379
 #include "llvm/PassManager.h"
 
380
 #include "llvm/Support/Compiler.h"
 
381
 #include "llvm/Support/Debug.h"
 
382
@@ -58,7 +51,6 @@
 
383
 #include "llvm/Support/MemoryBuffer.h"
 
384
 #include "llvm/Support/raw_ostream.h"
 
385
 #include "llvm/Support/SourceMgr.h"
 
386
-#include "llvm/Support/IRBuilder.h"
 
387
 #include "llvm/Support/PrettyStackTrace.h"
 
388
 
 
389
 #ifdef LLVM29
 
390
@@ -70,8 +62,12 @@
 
391
 #include "llvm/Support/Signals.h"
 
392
 #include "llvm/Support/Threading.h"
 
393
 #include "llvm/Support/ThreadLocal.h"
 
394
-#include "llvm/IntrinsicInst.h"
 
395
 #include "llvm/PassRegistry.h"
 
396
+#if LLVM_VERSION < 33
 
397
+#include "llvm/IntrinsicInst.h"
 
398
+#else
 
399
+#include "llvm/IR/IntrinsicInst.h"
 
400
+#endif
 
401
 #else
 
402
 #include "llvm/System/DataTypes.h"
 
403
 #include "llvm/System/Host.h"
 
404
@@ -94,7 +90,6 @@ void LLVMInitializePowerPCAsmPrinter();
 
405
 #else
 
406
 #include "llvm/Target/TargetSelect.h"
 
407
 #endif
 
408
-#include "llvm/Target/TargetData.h"
 
409
 #include "llvm/Target/TargetOptions.h"
 
410
 #include "llvm/Support/TargetFolder.h"
 
411
 #include "llvm/Transforms/Scalar.h"
 
412
@@ -106,13 +101,58 @@ void LLVMInitializePowerPCAsmPrinter();
 
413
 #include <cerrno>
 
414
 #include <string>
 
415
 
 
416
+#if LLVM_VERSION < 32
 
417
+#include "llvm/Analysis/DebugInfo.h"
 
418
+#else
 
419
+#include "llvm/DebugInfo.h"
 
420
+#endif
 
421
+
 
422
+#if LLVM_VERSION < 32
 
423
+#include "llvm/Support/IRBuilder.h"
 
424
+#include "llvm/Target/TargetData.h"
 
425
+#elif LLVM_VERSION < 33
 
426
+#include "llvm/IRBuilder.h"
 
427
+#include "llvm/DataLayout.h"
 
428
+#else
 
429
+#include "llvm/IR/IRBuilder.h"
 
430
+#include "llvm/IR/DataLayout.h"
 
431
+#endif
 
432
+
 
433
+#if LLVM_VERSION < 33
 
434
+#include "llvm/CallingConv.h"
 
435
+#include "llvm/DerivedTypes.h"
 
436
+#include "llvm/Function.h"
 
437
+#include "llvm/LLVMContext.h"
 
438
+#include "llvm/Intrinsics.h"
 
439
+#include "llvm/Module.h"
 
440
+#else
 
441
+#include "llvm/IR/CallingConv.h"
 
442
+#include "llvm/IR/DerivedTypes.h"
 
443
+#include "llvm/IR/Function.h"
 
444
+#include "llvm/IR/LLVMContext.h"
 
445
+#include "llvm/IR/Intrinsics.h"
 
446
+#include "llvm/IR/Module.h"
 
447
+#endif
 
448
+
 
449
+#if LLVM_VERSION >= 34
 
450
+#include "llvm/Analysis/CFG.h"
 
451
+#endif
 
452
+
 
453
 //#define TIMING
 
454
 #undef TIMING
 
455
 
 
456
 #include "llvm/Config/config.h"
 
457
+#ifdef ENABLE_THREADS
 
458
 #if !ENABLE_THREADS
 
459
 #error "Thread support was explicitly disabled. Cannot continue"
 
460
 #endif
 
461
+#endif
 
462
+
 
463
+#ifdef LLVM_ENABLE_THREADS
 
464
+#if !LLVM_ENABLE_THREADS
 
465
+#error "Thread support was explicitly disabled. Cannot continue"
 
466
+#endif
 
467
+#endif
 
468
 
 
469
 #ifdef _GLIBCXX_PARALLEL
 
470
 #error "libstdc++ parallel mode is not supported for ClamAV. Please remove -D_GLIBCXX_PARALLEL from CXXFLAGS!"
 
471
@@ -274,7 +314,11 @@ static void NORETURN jit_ssp_handler(void)
 
472
     jit_exception_handler();
 
473
 }
 
474
 
 
475
+#if LLVM_VERSION < 33
 
476
 void llvm_error_handler(void *user_data, const std::string &reason)
 
477
+#else
 
478
+void llvm_error_handler(void *user_data, const std::string &reason, bool gen_crash_diag = true)
 
479
+#endif
 
480
 {
 
481
     // Output it to stderr, it might exceed the 1k/4k limit of cli_errmsg
 
482
     cli_errmsg("[Bytecode JIT]: [LLVM error] %s\n", reason.c_str());
 
483
@@ -383,7 +427,11 @@ class NotifyListener : public JITEventListener {
 
484
        if (!cli_debug_flag)
 
485
            return;
 
486
        cli_dbgmsg_internal("[Bytecode JIT]: emitted function %s of %ld bytes at %p\n",
 
487
+#if LLVM_VERSION < 31
 
488
                            F.getNameStr().c_str(), (long)Size, Code);
 
489
+#else
 
490
+                           F.getName().str().c_str(), (long)Size, Code);
 
491
+#endif
 
492
     }
 
493
 };
 
494
 
 
495
@@ -676,8 +724,13 @@ class RuntimeLimits : public FunctionPass {
 
496
         CallInst* AbrtC = CallInst::Create(func_abort, "", AbrtBB);
 
497
         AbrtC->setCallingConv(CallingConv::C);
 
498
         AbrtC->setTailCall(true);
 
499
+#if LLVM_VERSION < 32
 
500
         AbrtC->setDoesNotReturn(true);
 
501
         AbrtC->setDoesNotThrow(true);
 
502
+#else
 
503
+        AbrtC->setDoesNotReturn();
 
504
+        AbrtC->setDoesNotThrow();
 
505
+#endif
 
506
         new UnreachableInst(F.getContext(), AbrtBB);
 
507
        IRBuilder<false> Builder(F.getContext());
 
508
 
 
509
@@ -1027,7 +1080,11 @@ class LLVMCodegen {
 
510
        : bc(bc), M(M), Context(M->getContext()), EE(EE),
 
511
        PM(PM),PMUnsigned(PMUnsigned), TypeMap(), apiFuncs(apiFuncs),apiMap(apiMap),
 
512
        compiledFunctions(cFuncs), BytecodeID("bc"+Twine(bc->id)),
 
513
+#if LLVM_VERSION < 32
 
514
        Folder(EE->getTargetData()), Builder(Context, Folder), Values(), CF(CF) {
 
515
+#else
 
516
+       Folder(EE->getDataLayout()), Builder(Context, Folder), Values(), CF(CF) {
 
517
+#endif
 
518
 
 
519
        for (unsigned i=0;i<cli_apicall_maxglobal - _FIRST_GLOBAL;i++) {
 
520
            unsigned id = cli_globals[i].globalid;
 
521
@@ -1158,7 +1215,11 @@ class LLVMCodegen {
 
522
            }
 
523
            V = SI->getOperand(0);
 
524
        }
 
525
+#if LLVM_VERSION < 32
 
526
        if (EE->getTargetData()->getPointerSize() == 8) {
 
527
+#else
 
528
+       if (EE->getDataLayout()->getPointerSize() == 8) {
 
529
+#endif
 
530
            // eliminate useless trunc, GEP can take i64 too
 
531
            if (TruncInst *I = dyn_cast<TruncInst>(V)) {
 
532
                Value *Src = I->getOperand(0);
 
533
@@ -1233,7 +1294,12 @@ class LLVMCodegen {
 
534
            Functions[j]->setLinkage(GlobalValue::InternalLinkage);
 
535
 #ifdef C_LINUX
 
536
            /* bb #2270, this should really be fixed either by LLVM or GCC.*/
 
537
+#if LLVM_VERSION < 32
 
538
            Functions[j]->addFnAttr(Attribute::constructStackAlignmentFromInt(16));
 
539
+#else
 
540
+       // TODO: How does this translate?
 
541
+//         Functions[j]->addFnAttr(Attribute::StackAlignment);
 
542
+#endif
 
543
 #endif
 
544
        }
 
545
        constType *I32Ty = Type::getInt32Ty(Context);
 
546
@@ -1534,7 +1600,11 @@ class LLVMCodegen {
 
547
                            }
 
548
                            CallInst *CI = Builder.CreateCall(DestF, ARRAYREF(Value*, args.begin(), args.end()));
 
549
                            CI->setCallingConv(CallingConv::Fast);
 
550
+#if LLVM_VERSION < 32
 
551
                            CI->setDoesNotThrow(true);
 
552
+#else
 
553
+                           CI->setDoesNotThrow();
 
554
+#endif
 
555
                            if (CI->getType()->getTypeID() != Type::VoidTyID)
 
556
                                Store(inst->dest, CI);
 
557
                            break;
 
558
@@ -1555,7 +1625,11 @@ class LLVMCodegen {
 
559
                                args.push_back(convertOperand(func, DestF->getFunctionType()->getParamType(a+1), op));
 
560
                            }
 
561
                            CallInst *CI = Builder.CreateCall(DestF, ARRAYREFVECTOR(Value*, args));
 
562
+#if LLVM_VERSION < 32
 
563
                            CI->setDoesNotThrow(true);
 
564
+#else
 
565
+                           CI->setDoesNotThrow();
 
566
+#endif
 
567
                            Store(inst->dest, CI);
 
568
                            }
 
569
                            break;
 
570
@@ -1688,7 +1762,11 @@ class LLVMCodegen {
 
571
                            Dst = Builder.CreatePointerCast(Dst, PointerType::getUnqual(Type::getInt8Ty(Context)));
 
572
                            Value *Src = convertOperand(func, inst, inst->u.three[1]);
 
573
                            Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context)));
 
574
+#if LLVM_VERSION < 32
 
575
                            Value *Len = convertOperand(func, EE->getTargetData()->getIntPtrType(Context), inst->u.three[2]);
 
576
+#else
 
577
+                           Value *Len = convertOperand(func, EE->getDataLayout()->getIntPtrType(Context), inst->u.three[2]);
 
578
+#endif
 
579
                            CallInst *c = Builder.CreateCall3(CF->FRealmemcmp, Dst, Src, Len);
 
580
                            c->setTailCall(true);
 
581
                            c->setDoesNotThrow();
 
582
@@ -1713,7 +1791,11 @@ class LLVMCodegen {
 
583
                            {
 
584
                                CallInst *C = Builder.CreateCall(CF->FBSwap16, convertOperand(func, inst, inst->u.unaryop));
 
585
                                C->setTailCall(true);
 
586
+#if LLVM_VERSION < 32
 
587
                                C->setDoesNotThrow(true);
 
588
+#else
 
589
+                               C->setDoesNotThrow();
 
590
+#endif
 
591
                                Store(inst->dest, C);
 
592
                                break;
 
593
                            }
 
594
@@ -1721,7 +1803,11 @@ class LLVMCodegen {
 
595
                            {
 
596
                                CallInst *C = Builder.CreateCall(CF->FBSwap32, convertOperand(func, inst, inst->u.unaryop));
 
597
                                C->setTailCall(true);
 
598
+#if LLVM_VERSION < 32
 
599
                                C->setDoesNotThrow(true);
 
600
+#else
 
601
+                               C->setDoesNotThrow();
 
602
+#endif
 
603
                                Store(inst->dest, C);
 
604
                                break;
 
605
                            }
 
606
@@ -1729,7 +1815,11 @@ class LLVMCodegen {
 
607
                            {
 
608
                                CallInst *C = Builder.CreateCall(CF->FBSwap64, convertOperand(func, inst, inst->u.unaryop));
 
609
                                C->setTailCall(true);
 
610
+#if LLVM_VERSION < 32
 
611
                                C->setDoesNotThrow(true);
 
612
+#else
 
613
+                               C->setDoesNotThrow();
 
614
+#endif
 
615
                                Store(inst->dest, C);
 
616
                                break;
 
617
                            }
 
618
@@ -1834,7 +1924,11 @@ class LLVMCodegen {
 
619
        // entrypoint can only be C, emit wrapper
 
620
        Function *F = Function::Create(Functions[0]->getFunctionType(),
 
621
                                       Function::ExternalLinkage,
 
622
+#if LLVM_VERSION < 33
 
623
                                       Functions[0]->getName()+"_wrap", M);
 
624
+#else
 
625
+                                      Functions[0]->getName().str()+"_wrap", M);
 
626
+#endif
 
627
        F->setDoesNotThrow();
 
628
        BasicBlock *BB = BasicBlock::Create(Context, "", F);
 
629
        std::vector<Value*> Args;
 
630
@@ -1893,8 +1987,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
 
631
                                          "clamjit.fail", M);
 
632
     CF->FHandler->setDoesNotReturn();
 
633
     CF->FHandler->setDoesNotThrow();
 
634
+#if LLVM_VERSION == 32
 
635
+    CF->FHandler->addFnAttr(Attributes::NoInline);
 
636
+#else
 
637
     CF->FHandler->addFnAttr(Attribute::NoInline);
 
638
-
 
639
+#endif
 
640
     EE->addGlobalMapping(CF->FHandler, (void*)(intptr_t)jit_exception_handler);
 
641
     EE->InstallLazyFunctionCreator(noUnknownFunctions);
 
642
     EE->getPointerToFunction(CF->FHandler);
 
643
@@ -1917,7 +2014,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
 
644
 #endif
 
645
                                         M);
 
646
     CF->FMemset->setDoesNotThrow();
 
647
+#if LLVM_VERSION < 32
 
648
     CF->FMemset->setDoesNotCapture(1, true);
 
649
+#else
 
650
+    CF->FMemset->setDoesNotCapture(1);
 
651
+#endif
 
652
 
 
653
     args.clear();
 
654
     args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
 
655
@@ -1937,7 +2038,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
 
656
 #endif
 
657
                                          M);
 
658
     CF->FMemmove->setDoesNotThrow();
 
659
+#if LLVM_VERSION < 32
 
660
     CF->FMemmove->setDoesNotCapture(1, true);
 
661
+#else
 
662
+    CF->FMemmove->setDoesNotCapture(1);
 
663
+#endif
 
664
 
 
665
     CF->FMemcpy = Function::Create(FuncTy_4, GlobalValue::ExternalLinkage,
 
666
 #ifdef LLVM30
 
667
@@ -1947,7 +2052,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
 
668
 #endif
 
669
                                         M);
 
670
     CF->FMemcpy->setDoesNotThrow();
 
671
+#if LLVM_VERSION < 32
 
672
     CF->FMemcpy->setDoesNotCapture(1, true);
 
673
+#else
 
674
+    CF->FMemcpy->setDoesNotCapture(1);
 
675
+#endif
 
676
 
 
677
     args.clear();
 
678
     args.push_back(Type::getInt16Ty(Context));
 
679
@@ -1987,7 +2096,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M
 
680
     args.clear();
 
681
     args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
 
682
     args.push_back(PointerType::getUnqual(Type::getInt8Ty(Context)));
 
683
+#if LLVM_VERSION < 32
 
684
     args.push_back(EE->getTargetData()->getIntPtrType(Context));
 
685
+#else
 
686
+    args.push_back(EE->getDataLayout()->getIntPtrType(Context));
 
687
+#endif
 
688
     FuncTy_5 = FunctionType::get(Type::getInt32Ty(Context),
 
689
                                 args, false);
 
690
     CF->FRealmemcmp = Function::Create(FuncTy_5, GlobalValue::ExternalLinkage, "memcmp", M);
 
691
@@ -2214,12 +2327,19 @@ static void setGuard(unsigned char* guardbuf)
 
692
 
 
693
     cl_hash_data("md5", salt, 48, guardbuf, NULL);
 
694
 }
 
695
-
 
696
+#if LLVM_VERSION < 32
 
697
 static void addFPasses(FunctionPassManager &FPM, bool trusted, const TargetData *TD)
 
698
+#else
 
699
+static void addFPasses(FunctionPassManager &FPM, bool trusted, const DataLayout *TD)
 
700
+#endif
 
701
 {
 
702
     // Set up the optimizer pipeline.  Start with registering info about how
 
703
     // the target lays out data structures.
 
704
+#if LLVM_VERSION < 32
 
705
     FPM.add(new TargetData(*TD));
 
706
+#else
 
707
+    FPM.add(new DataLayout(*TD));
 
708
+#endif
 
709
     // Promote allocas to registers.
 
710
     FPM.add(createPromoteMemoryToRegisterPass());
 
711
     FPM.add(new BrSimplifier());
 
712
@@ -2241,6 +2361,24 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
 
713
        // Create the JIT.
 
714
        std::string ErrorMsg;
 
715
        EngineBuilder builder(M);
 
716
+
 
717
+#if LLVM_VERSION >= 31
 
718
+       TargetOptions Options;
 
719
+#ifdef CL_DEBUG
 
720
+       //disable this for now, it leaks
 
721
+       Options.JITEmitDebugInfo = false;
 
722
+//     Options.JITEmitDebugInfo = true;
 
723
+#else
 
724
+       Options.JITEmitDebugInfo = false;
 
725
+#endif
 
726
+#if LLVM_VERSION < 34
 
727
+       Options.DwarfExceptionHandling = false;
 
728
+#else
 
729
+       // TODO: How to do this now?
 
730
+#endif
 
731
+       builder.setTargetOptions(Options);
 
732
+#endif
 
733
+
 
734
        builder.setErrorStr(&ErrorMsg);
 
735
        builder.setEngineKind(EngineKind::JIT);
 
736
        builder.setOptLevel(CodeGenOpt::Default);
 
737
@@ -2265,11 +2403,24 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
 
738
        addFunctionProtos(&CF, EE, M);
 
739
 
 
740
        FunctionPassManager OurFPM(M), OurFPMUnsigned(M);
 
741
+#if LLVM_VERSION < 32
 
742
        M->setDataLayout(EE->getTargetData()->getStringRepresentation());
 
743
+#else
 
744
+       M->setDataLayout(EE->getDataLayout()->getStringRepresentation());
 
745
+#endif
 
746
+#if LLVM_VERSION < 31
 
747
        M->setTargetTriple(sys::getHostTriple());
 
748
-
 
749
+#else
 
750
+       M->setTargetTriple(sys::getDefaultTargetTriple());
 
751
+#endif
 
752
+#if LLVM_VERSION < 32
 
753
        addFPasses(OurFPM, true, EE->getTargetData());
 
754
        addFPasses(OurFPMUnsigned, false, EE->getTargetData());
 
755
+#else
 
756
+       addFPasses(OurFPM, true, EE->getDataLayout());
 
757
+       addFPasses(OurFPMUnsigned, false, EE->getDataLayout());
 
758
+#endif
 
759
+
 
760
 
 
761
        //TODO: create a wrapper that calls pthread_getspecific
 
762
        unsigned maxh = cli_globals[0].offset + sizeof(struct cli_bc_hooks);
 
763
@@ -2376,7 +2527,11 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs)
 
764
            }
 
765
        }
 
766
        PassManager PM;
 
767
+#if LLVM_VERSION < 32
 
768
        PM.add(new TargetData(*EE->getTargetData()));
 
769
+#else
 
770
+       PM.add(new DataLayout(*EE->getDataLayout()));
 
771
+#endif
 
772
        // TODO: only run this on the untrusted bytecodes, not all of them...
 
773
        if (has_untrusted)
 
774
            PM.add(createClamBCRTChecks());
 
775
@@ -2441,11 +2596,17 @@ int bytecode_init(void)
 
776
     llvm_install_error_handler(llvm_error_handler);
 
777
 #ifdef CL_DEBUG
 
778
     sys::PrintStackTraceOnErrorSignal();
 
779
+#if LLVM_VERSION >= 34
 
780
+    llvm::EnablePrettyStackTrace();
 
781
+#endif
 
782
 #else
 
783
+#if LLVM_VERSION < 34
 
784
     llvm::DisablePrettyStackTrace = true;
 
785
 #endif
 
786
+#endif
 
787
     atexit(do_shutdown);
 
788
 
 
789
+#if LLVM_VERSION < 31
 
790
 #ifdef CL_DEBUG
 
791
     //disable this for now, it leaks
 
792
     llvm::JITEmitDebugInfo = false;
 
793
@@ -2454,6 +2615,7 @@ int bytecode_init(void)
 
794
     llvm::JITEmitDebugInfo = false;
 
795
 #endif
 
796
     llvm::DwarfExceptionHandling = false;
 
797
+#endif
 
798
     llvm_start_multithreaded();
 
799
 
 
800
     // If we have a native target, initialize it to ensure it is linked in and
 
801
@@ -2612,7 +2774,11 @@ namespace ClamBCModule {
 
802
 void stop(const char *msg, llvm::Function* F, llvm::Instruction* I)
 
803
 {
 
804
     if (F && F->hasName()) {
 
805
+#if LLVM_VERSION < 31
 
806
        cli_warnmsg("[Bytecode JIT] in function %s: %s", F->getNameStr().c_str(), msg);
 
807
+#else
 
808
+       cli_warnmsg("[Bytecode JIT] in function %s: %s", F->getName().str().c_str(), msg);
 
809
+#endif
 
810
     } else {
 
811
        cli_warnmsg("[Bytecode JIT] %s", msg);
 
812
     }
 
813
@@ -2679,7 +2845,12 @@ static const DbgDeclareInst *findDbgDeclare(const Value *V) {
 
814
 static bool getLocationInfo(const Value *V, std::string &DisplayName,
 
815
                             std::string &Type, unsigned &LineNo,
 
816
                             std::string &File, std::string &Dir) {
 
817
+#if LLVM_VERSION < 33
 
818
   DICompileUnit Unit;
 
819
+#else
 
820
+  StringRef G;
 
821
+  StringRef H;
 
822
+#endif
 
823
   DIType TypeD;
 
824
 
 
825
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) {
 
826
@@ -2691,7 +2862,12 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
 
827
     if (!D.empty())
 
828
       DisplayName = D;
 
829
     LineNo = Var.getLineNumber();
 
830
+#if LLVM_VERSION < 33
 
831
     Unit = Var.getCompileUnit();
 
832
+#else
 
833
+    G = Var.getFilename();
 
834
+    H = Var.getDirectory();
 
835
+#endif
 
836
     TypeD = Var.getType();
 
837
   } else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){
 
838
     Value *DIF = findDbgSubprogramDeclare(F);
 
839
@@ -2702,7 +2878,12 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
 
840
     if (!D.empty())
 
841
       DisplayName = D;
 
842
     LineNo = Var.getLineNumber();
 
843
+#if LLVM_VERSION < 33
 
844
     Unit = Var.getCompileUnit();
 
845
+#else
 
846
+    G = Var.getFilename();
 
847
+    H = Var.getDirectory();
 
848
+#endif
 
849
     TypeD = Var.getType();
 
850
   } else {
 
851
     const DbgDeclareInst *DDI = findDbgDeclare(V);
 
852
@@ -2713,19 +2894,27 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName,
 
853
     if (!D.empty())
 
854
       DisplayName = D;
 
855
     LineNo = Var.getLineNumber();
 
856
+#if LLVM_VERSION < 33
 
857
     Unit = Var.getCompileUnit();
 
858
+#else
 
859
+    // getFilename and getDirectory are not defined
 
860
+    G = StringRef();
 
861
+    H = StringRef();
 
862
+#endif
 
863
     TypeD = Var.getType();
 
864
   }
 
865
 
 
866
   StringRef T = TypeD.getName();
 
867
   if (!T.empty())
 
868
     Type = T;
 
869
-  StringRef F = Unit.getFilename();
 
870
-  if (!F.empty())
 
871
-    File = F;
 
872
-  StringRef D = Unit.getDirectory();
 
873
-  if (!D.empty())
 
874
-    Dir = D;
 
875
+#if LLVM_VERSION < 33
 
876
+  StringRef G = Unit.getFilename();
 
877
+  StringRef H = Unit.getDirectory();
 
878
+#endif
 
879
+  if (!G.empty())
 
880
+    File = G;
 
881
+  if (!H.empty())
 
882
+    Dir = H;
 
883
   return true;
 
884
 }
 
885
 #endif
 
886
diff --git a/libclamav/c++/configure.ac b/libclamav/c++/configure.ac
 
887
index db2b9cf..1c50ffd 100644
 
888
--- a/libclamav/c++/configure.ac
 
889
+++ b/libclamav/c++/configure.ac
 
890
@@ -16,7 +16,6 @@ dnl   MA 02110-1301, USA.
 
891
 AC_PREREQ([2.59])
 
892
 AC_INIT([libclamavc++],[devel],[http://bugs.clamav.net])
 
893
 AC_CONFIG_AUX_DIR([config])
 
894
-AC_CONFIG_SRCDIR([llvm/configure])
 
895
 AC_CONFIG_MACRO_DIR([m4])
 
896
 AC_CONFIG_HEADER([clamavcxx-config.h])
 
897
 AC_CANONICAL_TARGET
 
898
@@ -59,10 +58,7 @@ AC_ARG_WITH([system-llvm], AC_HELP_STRING([-with-system-llvm],
 
899
   *)
 
900
     llvmconfig="$withval"
 
901
     llvmver=`$llvmconfig --version`
 
902
-    if test "$llvmver" != "2.9" && test "$llvmver" != "3.0svn" &&
 
903
-       test "$llvmver" != "3.0"; then
 
904
-       AC_MSG_ERROR([LLVM 2.9 required, but "$llvmver" found])
 
905
-    fi
 
906
+
 
907
     AC_SUBST(LLVMCONFIG_CXXFLAGS, [`$llvmconfig --cxxflags`])
 
908
     AC_SUBST(LLVMCONFIG_LDFLAGS, [`$llvmconfig --ldflags`])
 
909
     AC_SUBST(LLVMCONFIG_LIBS, [`$llvmconfig --libs jit nativecodegen scalaropts ipo`])
 
910
@@ -75,9 +71,24 @@ AC_ARG_WITH([system-llvm], AC_HELP_STRING([-with-system-llvm],
 
911
   esac
 
912
 ])
 
913
 
 
914
+AC_MSG_CHECKING([for supported LLVM version])
 
915
 if test "x$llvmconfig" = "x"; then
 
916
     AC_CONFIG_SUBDIRS([llvm])
 
917
+    llvmver=`llvm/configure --version | sed -n 1p | sed 's/llvm configure //'`
 
918
+fi
 
919
+
 
920
+llvmver_int=`echo "$llvmver" | sed -e 's/\([[0-9]]\)\.\([[0-9]]\).*/\1\2/g'`
 
921
+
 
922
+if test $llvmver_int -lt 28; then
 
923
+    AC_MSG_RESULT([no ($llvmver)])
 
924
+    AC_MSG_ERROR([LLVM >= 2.8 required, but "$llvmver" found])
 
925
+elif test $llvmver_int -gt 34; then
 
926
+    AC_MSG_RESULT([no ($llvmver)])
 
927
+    AC_MSG_ERROR([LLVM <= 3.4 required, but "$llvmver" found])
 
928
+else
 
929
+AC_MSG_RESULT([ok ($llvmver; $llvmver_int)])
 
930
 fi
 
931
+AC_SUBST([LLVM_VERSION], [$llvmver_int])
 
932
 
 
933
 AC_ARG_ENABLE([llvm],AC_HELP_STRING([-enable-llvm],
 
934
                                    [Enable 'llvm' JIT/verifier support @<:@default=auto@:>@]),
 
935
diff --git a/libclamav/c++/detect.cpp b/libclamav/c++/detect.cpp
 
936
index 880255e..0dc6382 100644
 
937
--- a/libclamav/c++/detect.cpp
 
938
+++ b/libclamav/c++/detect.cpp
 
939
@@ -56,16 +56,27 @@ static void warn_assumptions(const char *msg, int a, int b)
 
940
 
 
941
 void cli_detect_env_jit(struct cli_environment *env)
 
942
 {
 
943
+#if LLVM_VERSION < 31
 
944
     std::string host_triple = sys::getHostTriple();
 
945
+#else
 
946
+    std::string host_triple = sys::getDefaultTargetTriple();
 
947
+#endif
 
948
     INIT_STRFIELD(env->triple, host_triple.c_str());
 
949
 
 
950
     std::string cpu = sys::getHostCPUName();
 
951
     INIT_STRFIELD(env->cpu, cpu.c_str());
 
952
 
 
953
+#if LLVM_VERSION < 33
 
954
     if (env->big_endian != (int)sys::isBigEndianHost()) {
 
955
        warn_assumptions("host endianness", env->big_endian, sys::isBigEndianHost());
 
956
        env->big_endian = sys::isBigEndianHost();
 
957
     }
 
958
+#else
 
959
+    if (env->big_endian != (int)sys::IsBigEndianHost) {
 
960
+       warn_assumptions("host endianness", env->big_endian, sys::IsBigEndianHost);
 
961
+       env->big_endian = sys::IsBigEndianHost;
 
962
+    }
 
963
+#endif
 
964
 
 
965
 #ifdef __GNUC__
 
966
     env->cpp_version = MAKE_VERSION(0, __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
 
967
@@ -149,7 +160,9 @@ void cli_detect_env_jit(struct cli_environment *env)
 
968
 #endif
 
969
        CASE_OS(NetBSD,  os_bsd);
 
970
        CASE_OS(OpenBSD, os_bsd);
 
971
+#if LLVM_VERSION < 31
 
972
        CASE_OS(Psp, os_unknown);
 
973
+#endif
 
974
        CASE_OS(Solaris, os_solaris);
 
975
        case Triple::Win32:
 
976
             env->os = llvm_os_Win32;