diff options
author | Andres Freund | 2019-01-29 02:05:52 +0000 |
---|---|---|
committer | Andres Freund | 2019-01-29 02:05:52 +0000 |
commit | da05eb51debd5d4b0284bcafa728244183c303ae (patch) | |
tree | 3f2074a5262026fad9bcbccd7a89aed390f708fb | |
parent | 684200543b4cbfe1ac002c9962e90683d4ea4691 (diff) |
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/[email protected]
Backpatch: 11, where JIT support was added
-rw-r--r-- | src/include/jit/llvmjit.h | 9 | ||||
-rw-r--r-- | src/include/jit/llvmjit_emit.h | 9 |
2 files changed, 15 insertions, 3 deletions
diff --git a/src/include/jit/llvmjit.h b/src/include/jit/llvmjit.h index 6af5fe7438..726ec99130 100644 --- a/src/include/jit/llvmjit.h +++ b/src/include/jit/llvmjit.h @@ -11,9 +11,11 @@ #ifndef LLVMJIT_H #define LLVMJIT_H -#ifndef USE_LLVM -#error "llvmjit.h should only be included by code dealing with llvm" -#endif +/* + * To avoid breaking cpluspluscheck, allow including the file even when LLVM + * is not available. + */ +#ifdef USE_LLVM #include <llvm-c/Types.h> @@ -140,4 +142,5 @@ extern char *LLVMGetHostCPUFeatures(void); } /* extern "C" */ #endif +#endif /* USE_LLVM */ #endif /* LLVMJIT_H */ diff --git a/src/include/jit/llvmjit_emit.h b/src/include/jit/llvmjit_emit.h index 41145fc517..9569da6fbf 100644 --- a/src/include/jit/llvmjit_emit.h +++ b/src/include/jit/llvmjit_emit.h @@ -9,9 +9,17 @@ #ifndef LLVMJIT_EMIT_H #define LLVMJIT_EMIT_H +/* + * To avoid breaking cpluspluscheck, allow including the file even when LLVM + * is not available. + */ +#ifdef USE_LLVM #include <llvm-c/Core.h> +#include "fmgr.h" +#include "jit/llvmjit.h" + /* * Emit a non-LLVM pointer as an LLVM constant. @@ -263,4 +271,5 @@ l_funcvalue(LLVMBuilderRef b, LLVMValueRef v_fcinfo, size_t argno) return LLVMBuildLoad(b, l_funcvaluep(b, v_fcinfo, argno), ""); } +#endif /* USE_LLVM */ #endif |