Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix LLVM related headers to compile standalone (to fix cpluspluscheck).
authorAndres Freund <andres@anarazel.de>
Tue, 29 Jan 2019 02:05:52 +0000 (18:05 -0800)
committerAndres Freund <andres@anarazel.de>
Tue, 29 Jan 2019 02:14:45 +0000 (18:14 -0800)
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

src/include/jit/llvmjit.h
src/include/jit/llvmjit_emit.h

index c81cff8a35f2bec8cc4adf13482634f084343543..94e6612823b8f2c8af48da1a82834ec9f0ea9663 100644 (file)
 #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>
 
@@ -135,4 +137,5 @@ extern char *LLVMGetHostCPUFeatures(void);
 } /* extern "C" */
 #endif
 
+#endif                         /* USE_LLVM */
 #endif                         /* LLVMJIT_H */
index 0d1b246f42ace87b40592c1e7afc16da5e7a8fd7..fdc51b1e907c0c376047b0ad49861e55f2d92e32 100644 (file)
@@ -9,9 +9,16 @@
 #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 "jit/llvmjit.h"
+
 
 /*
  * Emit a non-LLVM pointer as an LLVM constant.
@@ -208,4 +215,6 @@ l_mcxt_switch(LLVMModuleRef mod, LLVMBuilderRef b, LLVMValueRef nc)
 
    return ret;
 }
+
+#endif                         /* USE_LLVM */
 #endif