Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 6a5c0bb

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 453be7d commit 6a5c0bb

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

@@ -135,4 +137,5 @@ extern char *LLVMGetHostCPUFeatures(void);
135137
} /* extern "C" */
136138
#endif
137139

140+
#endif /* USE_LLVM */
138141
#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,16 @@
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 "jit/llvmjit.h"
21+
1522

1623
/*
1724
* Emit a non-LLVM pointer as an LLVM constant.
@@ -208,4 +215,6 @@ l_mcxt_switch(LLVMModuleRef mod, LLVMBuilderRef b, LLVMValueRef nc)
208215

209216
return ret;
210217
}
218+
219+
#endif /* USE_LLVM */
211220
#endif

0 commit comments

Comments
 (0)