Skip to content

Commit 640a4ba

Browse files
committed
Postpone LLVM-related uses of AC_CHECK_DECLS.
Calling AC_CHECK_DECLS before we've finished setting up the compiler's CFLAGS seems like a pretty risky proposition, especially now that the first use of that macro will result in a test to see whether the compiler gives warning or error for undeclared built-in functions. That answer could very easily get changed later than where PGAC_LLVM_SUPPORT is called; furthermore, it's hardly unlikely that flags such as -D_GNU_SOURCE could change visibility of declarations. Hence, be a little less cavalier about where to do LLVM-related tests. This results in v11 and HEAD doing the warning-or-error check at the same place in the script as older branches are doing it, which seems like a good thing. Per further thought about commits 0b59b0e and 16fbac3.
1 parent 6e5f8d4 commit 640a4ba

File tree

3 files changed

+230
-211
lines changed

3 files changed

+230
-211
lines changed

config/llvm.m4

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# config/llvm.m4
22

33
# PGAC_LLVM_SUPPORT
4-
# ---------------
4+
# -----------------
55
#
66
# Look for the LLVM installation, check that it's new enough, set the
77
# corresponding LLVM_{CFLAGS,CXXFLAGS,BINPATH} and LDFLAGS
8-
# variables. Also verifies that CLANG is available, to transform C
8+
# variables. Also verify that CLANG is available, to transform C
99
# into bitcode.
1010
#
1111
AC_DEFUN([PGAC_LLVM_SUPPORT],
@@ -91,14 +91,6 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
9191
9292
LLVM_BINPATH=`$LLVM_CONFIG --bindir`
9393
94-
# Check which functionality is present
95-
SAVE_CPPFLAGS="$CPPFLAGS"
96-
CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
97-
AC_CHECK_DECLS([LLVMOrcGetSymbolAddressIn], [], [], [[#include <llvm-c/OrcBindings.h>]])
98-
AC_CHECK_DECLS([LLVMGetHostCPUName, LLVMGetHostCPUFeatures], [], [], [[#include <llvm-c/TargetMachine.h>]])
99-
AC_CHECK_DECLS([LLVMCreateGDBRegistrationListener, LLVMCreatePerfJITEventListener], [], [], [[#include <llvm-c/ExecutionEngine.h>]])
100-
CPPFLAGS="$SAVE_CPPFLAGS"
101-
10294
# LLVM_CONFIG, CLANG are already output via AC_ARG_VAR
10395
AC_SUBST(LLVM_LIBS)
10496
AC_SUBST(LLVM_CPPFLAGS)
@@ -107,3 +99,22 @@ AC_DEFUN([PGAC_LLVM_SUPPORT],
10799
AC_SUBST(LLVM_BINPATH)
108100
109101
])# PGAC_LLVM_SUPPORT
102+
103+
104+
# PGAC_CHECK_LLVM_FUNCTIONS
105+
# -------------------------
106+
#
107+
# Check presence of some optional LLVM functions.
108+
# (This shouldn't happen until we're ready to run AC_CHECK_DECLS tests;
109+
# because PGAC_LLVM_SUPPORT runs very early, it's not an appropriate place.)
110+
#
111+
AC_DEFUN([PGAC_CHECK_LLVM_FUNCTIONS],
112+
[
113+
# Check which functionality is present
114+
SAVE_CPPFLAGS="$CPPFLAGS"
115+
CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
116+
AC_CHECK_DECLS([LLVMOrcGetSymbolAddressIn], [], [], [[#include <llvm-c/OrcBindings.h>]])
117+
AC_CHECK_DECLS([LLVMGetHostCPUName, LLVMGetHostCPUFeatures], [], [], [[#include <llvm-c/TargetMachine.h>]])
118+
AC_CHECK_DECLS([LLVMCreateGDBRegistrationListener, LLVMCreatePerfJITEventListener], [], [], [[#include <llvm-c/ExecutionEngine.h>]])
119+
CPPFLAGS="$SAVE_CPPFLAGS"
120+
])# PGAC_CHECK_LLVM_FUNCTIONS

0 commit comments

Comments
 (0)