Skip to content

Commit da05eb5

Browse files
committed
Fix LLVM related headers to compile standalone (to fix cpluspluscheck).
Previously llvmjit.h #error'ed when USE_LLVM was not defined, to prevent it from being included from code not having #ifdef USE_LLVM guards - but that's not actually that useful after, during the development of JIT support, LLVM related code was moved into a separately compiled .so. Having that #error means cpluspluscheck doesn't work when llvm support isn't enabled, which isn't great. Similarly add USE_LLVM guards to llvmjit_emit.h, and additionally make sure it compiles standalone. Per complaint from Tom Lane. Author: Andres Freund Discussion: https://postgr.es/m/19808.1548692361@sss.pgh.pa.us Backpatch: 11, where JIT support was added
1 parent 6842005 commit da05eb5

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/include/jit/llvmjit.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@
1111
#ifndef LLVMJIT_H
1212
#define LLVMJIT_H
1313

14-
#ifndef USE_LLVM
15-
#error "llvmjit.h should only be included by code dealing with llvm"
16-
#endif
14+
/*
15+
* To avoid breaking cpluspluscheck, allow including the file even when LLVM
16+
* is not available.
17+
*/
18+
#ifdef USE_LLVM
1719

1820
#include <llvm-c/Types.h>
1921

@@ -140,4 +142,5 @@ extern char *LLVMGetHostCPUFeatures(void);
140142
} /* extern "C" */
141143
#endif
142144

145+
#endif /* USE_LLVM */
143146
#endif /* LLVMJIT_H */

src/include/jit/llvmjit_emit.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,17 @@
99
#ifndef LLVMJIT_EMIT_H
1010
#define LLVMJIT_EMIT_H
1111

12+
/*
13+
* To avoid breaking cpluspluscheck, allow including the file even when LLVM
14+
* is not available.
15+
*/
16+
#ifdef USE_LLVM
1217

1318
#include <llvm-c/Core.h>
1419

20+
#include "fmgr.h"
21+
#include "jit/llvmjit.h"
22+
1523

1624
/*
1725
* Emit a non-LLVM pointer as an LLVM constant.
@@ -263,4 +271,5 @@ l_funcvalue(LLVMBuilderRef b, LLVMValueRef v_fcinfo, size_t argno)
263271
return LLVMBuildLoad(b, l_funcvaluep(b, v_fcinfo, argno), "");
264272
}
265273

274+
#endif /* USE_LLVM */
266275
#endif

0 commit comments

Comments
 (0)