]> granicus.if.org Git - postgresql/commitdiff
Add configure infrastructure (--with-llvm) to enable LLVM support.
authorAndres Freund <andres@anarazel.de>
Wed, 21 Mar 2018 00:26:25 +0000 (17:26 -0700)
committerAndres Freund <andres@anarazel.de>
Wed, 21 Mar 2018 00:26:25 +0000 (17:26 -0700)
LLVM will be used for *optional* Just-in-time compilation
support. This commit just adds the configure infrastructure that
detects LLVM.

No documentation has been added for the --with-llvm flag, that'll be
added after the actual supporting code has been added.

Author: Andres Freund
Discussion: https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de

aclocal.m4
config/llvm.m4 [new file with mode: 0644]
configure
configure.in
src/Makefile.global.in
src/include/pg_config.h.in
src/include/pg_config.h.win32

index 0e95ed4b4d35d26c465f3ba6210c90688ad8326f..a517e949f1579de796725d5cf4fab48d85e6201a 100644 (file)
@@ -7,6 +7,7 @@ m4_include([config/c-library.m4])
 m4_include([config/docbook.m4])
 m4_include([config/general.m4])
 m4_include([config/libtool.m4])
+m4_include([config/llvm.m4])
 m4_include([config/perl.m4])
 m4_include([config/pkg.m4])
 m4_include([config/programs.m4])
diff --git a/config/llvm.m4 b/config/llvm.m4
new file mode 100644 (file)
index 0000000..e25ffec
--- /dev/null
@@ -0,0 +1,108 @@
+# config/llvm.m4
+
+# PGAC_LLVM_SUPPORT
+# ---------------
+#
+# Look for the LLVM installation, check that it's new enough, set the
+# corresponding LLVM_{CFLAGS,CXXFLAGS,BINPATH} and LDFLAGS
+# variables. Also verifies that CLANG is available, to transform C
+# into bitcode.
+#
+AC_DEFUN([PGAC_LLVM_SUPPORT],
+[
+  AC_REQUIRE([AC_PROG_AWK])
+
+  AC_ARG_VAR(LLVM_CONFIG, [path to llvm-config command])
+  PGAC_PATH_PROGS(LLVM_CONFIG, llvm-config llvm-config-6.0 llvm-config-5.0 llvm-config-4.0 llvm-config-3.9)
+
+  # no point continuing if llvm wasn't found
+  if test -z "$LLVM_CONFIG"; then
+    AC_MSG_ERROR([llvm-config not found, but required when compiling --with-llvm, specify with LLVM_CONFIG=])
+  fi
+  # check if detected $LLVM_CONFIG is executable
+  pgac_llvm_version="$($LLVM_CONFIG --version 2> /dev/null || echo no)"
+  if test "x$pgac_llvm_version" = "xno"; then
+    AC_MSG_ERROR([$LLVM_CONFIG does not work])
+  fi
+  # and whether the version is supported
+  if echo $pgac_llvm_version | $AWK -F '.' '{ if ([$]1 >= 4 || ([$]1 == 3 && [$]2 >= 9)) exit 1; else exit 0;}';then
+    AC_MSG_ERROR([$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required])
+  fi
+
+  # need clang to create some bitcode files
+  AC_ARG_VAR(CLANG, [path to clang compiler to generate bitcode])
+  PGAC_PATH_PROGS(CLANG, clang clang-6.0 clang-5.0 clang-4.0 clang-3.9)
+  if test -z "$CLANG"; then
+    AC_MSG_ERROR([clang not found, but required when compiling --with-llvm, specify with CLANG=])
+  fi
+  # make sure clang is executable
+  if test "x$($CLANG --version 2> /dev/null || echo no)" = "xno"; then
+    AC_MSG_ERROR([$CLANG does not work])
+  fi
+  # Could check clang version, but it doesn't seem that
+  # important. Systems with a new enough LLVM version are usually
+  # going to have a decent clang version too. It's also not entirely
+  # clear what the minimum version is.
+
+  # Collect compiler flags necessary to build the LLVM dependent
+  # shared library.
+  for pgac_option in `$LLVM_CONFIG --cppflags`; do
+    case $pgac_option in
+      -I*|-D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";;
+    esac
+  done
+
+  for pgac_option in `$LLVM_CONFIG --ldflags`; do
+    case $pgac_option in
+      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+    esac
+  done
+
+  # ABI influencing options, standard influencing options
+  for pgac_option in `$LLVM_CONFIG --cxxflags`; do
+    case $pgac_option in
+      -fno-rtti*) LLVM_CXXFLAGS="$LLVM_CXXFLAGS $pgac_option";;
+      -std=*) LLVM_CXXFLAGS="$LLVM_CXXFLAGS $pgac_option";;
+    esac
+  done
+
+  # Look for components we're interested in, collect necessary
+  # libs. As some components are optional, we can't just list all of
+  # them as it'd raise an error.
+  pgac_components='';
+  for pgac_component in `$LLVM_CONFIG --components`; do
+    case $pgac_component in
+      engine) pgac_components="$pgac_components $pgac_component";;
+      debuginfodwarf) pgac_components="$pgac_components $pgac_component";;
+      orcjit) pgac_components="$pgac_components $pgac_component";;
+      passes) pgac_components="$pgac_components $pgac_component";;
+      perfjitevents) pgac_components="$pgac_components $pgac_component";;
+    esac
+  done;
+
+  # And then get the libraries that need to be linked in for the
+  # selected components.  They're large libraries, we only want to
+  # link them into the LLVM using shared library.
+  for pgac_option in `$LLVM_CONFIG --libs --system-libs $pgac_components`; do
+    case $pgac_option in
+      -l*) LLVM_LIBS="$LLVM_LIBS $pgac_option";;
+    esac
+  done
+
+  LLVM_BINPATH=`$LLVM_CONFIG --bindir`
+
+  # Check which functionality is present
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
+  AC_CHECK_DECLS([LLVMOrcGetSymbolAddressIn, LLVMOrcRegisterGDB, LLVMOrcRegisterPerf], [], [], [[#include <llvm-c/OrcBindings.h>]])
+  AC_CHECK_DECLS([LLVMGetHostCPUName], [], [], [[#include <llvm-c/TargetMachine.h>]])
+  CPPFLAGS="$SAVE_CPPFLAGS"
+
+  # LLVM_CONFIG, CLANG are already output via AC_ARG_VAR
+  AC_SUBST(LLVM_LIBS)
+  AC_SUBST(LLVM_CPPFLAGS)
+  AC_SUBST(LLVM_CFLAGS)
+  AC_SUBST(LLVM_CXXFLAGS)
+  AC_SUBST(LLVM_BINPATH)
+
+])# PGAC_LLVM_SUPPORT
index 8214a3c1744fc035339fbe8790fbf691a83c3d2e..83b4d718fc6a140e41bf22a34b6984ed229f4f67 100755 (executable)
--- a/configure
+++ b/configure
@@ -676,7 +676,6 @@ FLEX
 BISONFLAGS
 BISON
 MKDIR_P
-AWK
 LN_S
 TAR
 install_bin
@@ -727,7 +726,18 @@ autodepend
 TAS
 GCC
 CPP
+BITCODE_CXXFLAGS
+BITCODE_CFLAGS
 CFLAGS_VECTOR
+LLVM_BINPATH
+LLVM_CXXFLAGS
+LLVM_CFLAGS
+LLVM_CPPFLAGS
+LLVM_LIBS
+CLANG
+LLVM_CONFIG
+AWK
+with_llvm
 SUN_STUDIO_CC
 ac_ct_CXX
 CXXFLAGS
@@ -826,6 +836,7 @@ with_blocksize
 with_segsize
 with_wal_blocksize
 with_CC
+with_llvm
 enable_depend
 enable_cassert
 enable_thread_safety
@@ -867,6 +878,8 @@ CPPFLAGS
 CXX
 CXXFLAGS
 CCC
+LLVM_CONFIG
+CLANG
 CPP
 PKG_CONFIG
 PKG_CONFIG_PATH
@@ -1525,6 +1538,7 @@ Optional Packages:
   --with-wal-blocksize=BLOCKSIZE
                           set WAL block size in kB [8]
   --with-CC=CMD           set compiler (deprecated)
+  --with-llvm             build with LLVM based JIT support
   --with-icu              build with ICU support
   --with-tcl              build Tcl modules (PL/Tcl)
   --with-tclconfig=DIR    tclConfig.sh is in DIR
@@ -1562,6 +1576,8 @@ Some influential environment variables:
               you have headers in a nonstandard directory <include dir>
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  LLVM_CONFIG path to llvm-config command
+  CLANG       path to clang compiler to generate bitcode
   CPP         C preprocessor
   PKG_CONFIG  path to pkg-config utility
   PKG_CONFIG_PATH
@@ -1731,6 +1747,52 @@ fi
 
 } # ac_fn_cxx_try_compile
 
+# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
+# ---------------------------------------------
+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
+# accordingly.
+ac_fn_c_check_decl ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  as_decl_name=`echo $2|sed 's/ *(.*//'`
+  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
+$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
+if eval \${$3+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+#ifndef $as_decl_name
+#ifdef __cplusplus
+  (void) $as_decl_use;
+#else
+  (void) $as_decl_name;
+#endif
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_decl
+
 # ac_fn_c_try_link LINENO
 # -----------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
@@ -2338,52 +2400,6 @@ rm -f conftest.val
   as_fn_set_status $ac_retval
 
 } # ac_fn_c_compute_int
-
-# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES
-# ---------------------------------------------
-# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
-# accordingly.
-ac_fn_c_check_decl ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  as_decl_name=`echo $2|sed 's/ *(.*//'`
-  as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
-$as_echo_n "checking whether $as_decl_name is declared... " >&6; }
-if eval \${$3+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-$4
-int
-main ()
-{
-#ifndef $as_decl_name
-#ifdef __cplusplus
-  (void) $as_decl_use;
-#else
-  (void) $as_decl_name;
-#endif
-#endif
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  eval "$3=yes"
-else
-  eval "$3=no"
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-eval ac_res=\$$3
-              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-
-} # ac_fn_c_check_decl
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
@@ -4686,34 +4702,359 @@ _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
   ICC=yes
 else
-  ICC=no
+  ICC=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+# Check if it's Sun Studio compiler. We assume that
+# __SUNPRO_C will be defined for Sun Studio compilers
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __SUNPRO_C
+choke me
+#endif
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  SUN_STUDIO_CC=yes
+else
+  SUN_STUDIO_CC=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+
+
+#
+# LLVM
+#
+# Checked early because subsequent tests depend on it.
+
+
+
+# Check whether --with-llvm was given.
+if test "${with_llvm+set}" = set; then :
+  withval=$with_llvm;
+  case $withval in
+    yes)
+
+$as_echo "#define USE_LLVM 1" >>confdefs.h
+
+      ;;
+    no)
+      :
+      ;;
+    *)
+      as_fn_error $? "no argument expected for --with-llvm option" "$LINENO" 5
+      ;;
+  esac
+
+else
+  with_llvm=no
+
+fi
+
+
+
+if test "$with_llvm" = yes ; then
+   for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AWK+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+
+
+
+
+  if test -z "$LLVM_CONFIG"; then
+  for ac_prog in llvm-config llvm-config-6.0 llvm-config-5.0 llvm-config-4.0 llvm-config-3.9
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_LLVM_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $LLVM_CONFIG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_LLVM_CONFIG="$LLVM_CONFIG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_LLVM_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+LLVM_CONFIG=$ac_cv_path_LLVM_CONFIG
+if test -n "$LLVM_CONFIG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM_CONFIG" >&5
+$as_echo "$LLVM_CONFIG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$LLVM_CONFIG" && break
+done
+
+else
+  # Report the value of LLVM_CONFIG in configure's output in all cases.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for LLVM_CONFIG" >&5
+$as_echo_n "checking for LLVM_CONFIG... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LLVM_CONFIG" >&5
+$as_echo "$LLVM_CONFIG" >&6; }
+fi
+
+
+  # no point continuing if llvm wasn't found
+  if test -z "$LLVM_CONFIG"; then
+    as_fn_error $? "llvm-config not found, but required when compiling --with-llvm, specify with LLVM_CONFIG=" "$LINENO" 5
+  fi
+  # check if detected $LLVM_CONFIG is executable
+  pgac_llvm_version="$($LLVM_CONFIG --version 2> /dev/null || echo no)"
+  if test "x$pgac_llvm_version" = "xno"; then
+    as_fn_error $? "$LLVM_CONFIG does not work" "$LINENO" 5
+  fi
+  # and whether the version is supported
+  if echo $pgac_llvm_version | $AWK -F '.' '{ if ($1 >= 4 || ($1 == 3 && $2 >= 9)) exit 1; else exit 0;}';then
+    as_fn_error $? "$LLVM_CONFIG version is $pgac_llvm_version but at least 3.9 is required" "$LINENO" 5
+  fi
+
+  # need clang to create some bitcode files
+
+  if test -z "$CLANG"; then
+  for ac_prog in clang clang-6.0 clang-5.0 clang-4.0 clang-3.9
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_CLANG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $CLANG in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_CLANG="$CLANG" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_CLANG="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+CLANG=$ac_cv_path_CLANG
+if test -n "$CLANG"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLANG" >&5
+$as_echo "$CLANG" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$CLANG" && break
+done
+
+else
+  # Report the value of CLANG in configure's output in all cases.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CLANG" >&5
+$as_echo_n "checking for CLANG... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CLANG" >&5
+$as_echo "$CLANG" >&6; }
+fi
+
+  if test -z "$CLANG"; then
+    as_fn_error $? "clang not found, but required when compiling --with-llvm, specify with CLANG=" "$LINENO" 5
+  fi
+  # make sure clang is executable
+  if test "x$($CLANG --version 2> /dev/null || echo no)" = "xno"; then
+    as_fn_error $? "$CLANG does not work" "$LINENO" 5
+  fi
+  # Could check clang version, but it doesn't seem that
+  # important. Systems with a new enough LLVM version are usually
+  # going to have a decent clang version too. It's also not entirely
+  # clear what the minimum version is.
+
+  # Collect compiler flags necessary to build the LLVM dependent
+  # shared library.
+  for pgac_option in `$LLVM_CONFIG --cppflags`; do
+    case $pgac_option in
+      -I*|-D*) LLVM_CPPFLAGS="$pgac_option $LLVM_CPPFLAGS";;
+    esac
+  done
+
+  for pgac_option in `$LLVM_CONFIG --ldflags`; do
+    case $pgac_option in
+      -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+    esac
+  done
+
+  # ABI influencing options, standard influencing options
+  for pgac_option in `$LLVM_CONFIG --cxxflags`; do
+    case $pgac_option in
+      -fno-rtti*) LLVM_CXXFLAGS="$LLVM_CXXFLAGS $pgac_option";;
+      -std=*) LLVM_CXXFLAGS="$LLVM_CXXFLAGS $pgac_option";;
+    esac
+  done
+
+  # Look for components we're interested in, collect necessary
+  # libs. As some components are optional, we can't just list all of
+  # them as it'd raise an error.
+  pgac_components='';
+  for pgac_component in `$LLVM_CONFIG --components`; do
+    case $pgac_component in
+      engine) pgac_components="$pgac_components $pgac_component";;
+      debuginfodwarf) pgac_components="$pgac_components $pgac_component";;
+      orcjit) pgac_components="$pgac_components $pgac_component";;
+      passes) pgac_components="$pgac_components $pgac_component";;
+      perfjitevents) pgac_components="$pgac_components $pgac_component";;
+    esac
+  done;
+
+  # And then get the libraries that need to be linked in for the
+  # selected components.  They're large libraries, we only want to
+  # link them into the LLVM using shared library.
+  for pgac_option in `$LLVM_CONFIG --libs --system-libs $pgac_components`; do
+    case $pgac_option in
+      -l*) LLVM_LIBS="$LLVM_LIBS $pgac_option";;
+    esac
+  done
+
+  LLVM_BINPATH=`$LLVM_CONFIG --bindir`
+
+  # Check which functionality is present
+  SAVE_CPPFLAGS="$CPPFLAGS"
+  CPPFLAGS="$CPPFLAGS $LLVM_CPPFLAGS"
+  ac_fn_c_check_decl "$LINENO" "LLVMOrcGetSymbolAddressIn" "ac_cv_have_decl_LLVMOrcGetSymbolAddressIn" "#include <llvm-c/OrcBindings.h>
+"
+if test "x$ac_cv_have_decl_LLVMOrcGetSymbolAddressIn" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "LLVMOrcRegisterGDB" "ac_cv_have_decl_LLVMOrcRegisterGDB" "#include <llvm-c/OrcBindings.h>
+"
+if test "x$ac_cv_have_decl_LLVMOrcRegisterGDB" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-# Check if it's Sun Studio compiler. We assume that
-# __SUNPRO_C will be defined for Sun Studio compilers
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_LLVMORCREGISTERGDB $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "LLVMOrcRegisterPerf" "ac_cv_have_decl_LLVMOrcRegisterPerf" "#include <llvm-c/OrcBindings.h>
+"
+if test "x$ac_cv_have_decl_LLVMOrcRegisterPerf" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
 
-int
-main ()
-{
-#ifndef __SUNPRO_C
-choke me
-#endif
-  ;
-  return 0;
-}
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_LLVMORCREGISTERPERF $ac_have_decl
 _ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  SUN_STUDIO_CC=yes
+
+  ac_fn_c_check_decl "$LINENO" "LLVMGetHostCPUName" "ac_cv_have_decl_LLVMGetHostCPUName" "#include <llvm-c/TargetMachine.h>
+"
+if test "x$ac_cv_have_decl_LLVMGetHostCPUName" = xyes; then :
+  ac_have_decl=1
 else
-  SUN_STUDIO_CC=no
+  ac_have_decl=0
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_LLVMGETHOSTCPUNAME $ac_have_decl
+_ACEOF
+
+  CPPFLAGS="$SAVE_CPPFLAGS"
+
+  # LLVM_CONFIG, CLANG are already output via AC_ARG_VAR
+
+
+
 
 
 
+
+fi
+
+
 unset CFLAGS
 
 #
@@ -4758,11 +5099,32 @@ else
   fi
 fi
 
+# When generating bitcode (for inlining) we always want to use -O2
+# even when --enable-debug is specified. The bitcode it's not going to
+# be used for line-by-line debugging, and JIT inlining doesn't work
+# without at least -O1 (otherwise clang will emit 'noinline'
+# attributes everywhere), which is bad for testing.  Still allow the
+# environment to override if done explicitly.
+if test "$ac_env_BITCODE_CFLAGS_set" = set; then
+  BITCODE_CFLAGS=$ac_env_BITCODE_CFLAGS_value
+else
+  BITCODE_CFLAGS="-O2 $BITCODE_CFLAGS"
+fi
+if test "$ac_env_BITCODE_CXXFLAGS_set" = set; then
+  BITCODE_CXXFLAGS=$ac_env_BITCODE_CXXFLAGS_value
+else
+  BITCODE_CXXFLAGS="-O2 BITCODE_CXXFLAGS"
+fi
+
 # C[XX]FLAGS we determined above will be added back at the end
 user_CFLAGS=$CFLAGS
 CFLAGS=""
 user_CXXFLAGS=$CXXFLAGS
 CXXFLAGS=""
+user_BITCODE_CFLAGS=$BITCODE_CFLAGS
+BITCODE_CFLAGS=""
+user_BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS
+BITCODE_CXXFLAGS=""
 
 # set CFLAGS_VECTOR from the environment, if available
 if test "$ac_env_CFLAGS_VECTOR_set" = set; then
@@ -5962,6 +6324,278 @@ fi
 CFLAGS_VECTOR=$CFLAGS_VECTOR
 
 
+# Determine flags used to emit bitcode for JIT inlining. Need to test
+# for behaviour changing compiler flags, to keep compatibility with
+# compiler used for normal postgres code.
+if test "$with_llvm" = yes ; then
+  CLANGXX="$CLANG -xc++"
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -fno-strict-aliasing, for BITCODE_CFLAGS" >&5
+$as_echo_n "checking whether ${CLANG} supports -fno-strict-aliasing, for BITCODE_CFLAGS... " >&6; }
+if ${pgac_cv_prog_CLANG_cflags__fno_strict_aliasing+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  pgac_save_CFLAGS=$CFLAGS
+pgac_save_CC=$CC
+CC=${CLANG}
+CFLAGS="${BITCODE_CFLAGS} -fno-strict-aliasing"
+ac_save_c_werror_flag=$ac_c_werror_flag
+ac_c_werror_flag=yes
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  pgac_cv_prog_CLANG_cflags__fno_strict_aliasing=yes
+else
+  pgac_cv_prog_CLANG_cflags__fno_strict_aliasing=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_c_werror_flag=$ac_save_c_werror_flag
+CFLAGS="$pgac_save_CFLAGS"
+CC="$pgac_save_CC"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__fno_strict_aliasing" >&5
+$as_echo "$pgac_cv_prog_CLANG_cflags__fno_strict_aliasing" >&6; }
+if test x"$pgac_cv_prog_CLANG_cflags__fno_strict_aliasing" = x"yes"; then
+  BITCODE_CFLAGS="${BITCODE_CFLAGS} -fno-strict-aliasing"
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANGXX} supports -fno-strict-aliasing, for BITCODE_CXXFLAGS" >&5
+$as_echo_n "checking whether ${CLANGXX} supports -fno-strict-aliasing, for BITCODE_CXXFLAGS... " >&6; }
+if ${pgac_cv_prog_CLANGXX_cxxflags__fno_strict_aliasing+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  pgac_save_CXXFLAGS=$CXXFLAGS
+pgac_save_CXX=$CXX
+CXX=${CLANGXX}
+CXXFLAGS="${BITCODE_CXXFLAGS} -fno-strict-aliasing"
+ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ac_cxx_werror_flag=yes
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  pgac_cv_prog_CLANGXX_cxxflags__fno_strict_aliasing=yes
+else
+  pgac_cv_prog_CLANGXX_cxxflags__fno_strict_aliasing=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+CXXFLAGS="$pgac_save_CXXFLAGS"
+CXX="$pgac_save_CXX"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANGXX_cxxflags__fno_strict_aliasing" >&5
+$as_echo "$pgac_cv_prog_CLANGXX_cxxflags__fno_strict_aliasing" >&6; }
+if test x"$pgac_cv_prog_CLANGXX_cxxflags__fno_strict_aliasing" = x"yes"; then
+  BITCODE_CXXFLAGS="${BITCODE_CXXFLAGS} -fno-strict-aliasing"
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -fwrapv, for BITCODE_CFLAGS" >&5
+$as_echo_n "checking whether ${CLANG} supports -fwrapv, for BITCODE_CFLAGS... " >&6; }
+if ${pgac_cv_prog_CLANG_cflags__fwrapv+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  pgac_save_CFLAGS=$CFLAGS
+pgac_save_CC=$CC
+CC=${CLANG}
+CFLAGS="${BITCODE_CFLAGS} -fwrapv"
+ac_save_c_werror_flag=$ac_c_werror_flag
+ac_c_werror_flag=yes
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  pgac_cv_prog_CLANG_cflags__fwrapv=yes
+else
+  pgac_cv_prog_CLANG_cflags__fwrapv=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_c_werror_flag=$ac_save_c_werror_flag
+CFLAGS="$pgac_save_CFLAGS"
+CC="$pgac_save_CC"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__fwrapv" >&5
+$as_echo "$pgac_cv_prog_CLANG_cflags__fwrapv" >&6; }
+if test x"$pgac_cv_prog_CLANG_cflags__fwrapv" = x"yes"; then
+  BITCODE_CFLAGS="${BITCODE_CFLAGS} -fwrapv"
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANGXX} supports -fwrapv, for BITCODE_CXXFLAGS" >&5
+$as_echo_n "checking whether ${CLANGXX} supports -fwrapv, for BITCODE_CXXFLAGS... " >&6; }
+if ${pgac_cv_prog_CLANGXX_cxxflags__fwrapv+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  pgac_save_CXXFLAGS=$CXXFLAGS
+pgac_save_CXX=$CXX
+CXX=${CLANGXX}
+CXXFLAGS="${BITCODE_CXXFLAGS} -fwrapv"
+ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ac_cxx_werror_flag=yes
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  pgac_cv_prog_CLANGXX_cxxflags__fwrapv=yes
+else
+  pgac_cv_prog_CLANGXX_cxxflags__fwrapv=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+CXXFLAGS="$pgac_save_CXXFLAGS"
+CXX="$pgac_save_CXX"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANGXX_cxxflags__fwrapv" >&5
+$as_echo "$pgac_cv_prog_CLANGXX_cxxflags__fwrapv" >&6; }
+if test x"$pgac_cv_prog_CLANGXX_cxxflags__fwrapv" = x"yes"; then
+  BITCODE_CXXFLAGS="${BITCODE_CXXFLAGS} -fwrapv"
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANG} supports -fexcess-precision=standard, for BITCODE_CFLAGS" >&5
+$as_echo_n "checking whether ${CLANG} supports -fexcess-precision=standard, for BITCODE_CFLAGS... " >&6; }
+if ${pgac_cv_prog_CLANG_cflags__fexcess_precision_standard+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  pgac_save_CFLAGS=$CFLAGS
+pgac_save_CC=$CC
+CC=${CLANG}
+CFLAGS="${BITCODE_CFLAGS} -fexcess-precision=standard"
+ac_save_c_werror_flag=$ac_c_werror_flag
+ac_c_werror_flag=yes
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  pgac_cv_prog_CLANG_cflags__fexcess_precision_standard=yes
+else
+  pgac_cv_prog_CLANG_cflags__fexcess_precision_standard=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_c_werror_flag=$ac_save_c_werror_flag
+CFLAGS="$pgac_save_CFLAGS"
+CC="$pgac_save_CC"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANG_cflags__fexcess_precision_standard" >&5
+$as_echo "$pgac_cv_prog_CLANG_cflags__fexcess_precision_standard" >&6; }
+if test x"$pgac_cv_prog_CLANG_cflags__fexcess_precision_standard" = x"yes"; then
+  BITCODE_CFLAGS="${BITCODE_CFLAGS} -fexcess-precision=standard"
+fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CLANGXX} supports -fexcess-precision=standard, for BITCODE_CXXFLAGS" >&5
+$as_echo_n "checking whether ${CLANGXX} supports -fexcess-precision=standard, for BITCODE_CXXFLAGS... " >&6; }
+if ${pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  pgac_save_CXXFLAGS=$CXXFLAGS
+pgac_save_CXX=$CXX
+CXX=${CLANGXX}
+CXXFLAGS="${BITCODE_CXXFLAGS} -fexcess-precision=standard"
+ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ac_cxx_werror_flag=yes
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard=yes
+else
+  pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+CXXFLAGS="$pgac_save_CXXFLAGS"
+CXX="$pgac_save_CXX"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard" >&5
+$as_echo "$pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard" >&6; }
+if test x"$pgac_cv_prog_CLANGXX_cxxflags__fexcess_precision_standard" = x"yes"; then
+  BITCODE_CXXFLAGS="${BITCODE_CXXFLAGS} -fexcess-precision=standard"
+fi
+
+fi
+
 # supply -g if --enable-debug
 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
   CFLAGS="$CFLAGS -g"
@@ -6004,6 +6638,13 @@ fi
 # the automatic additions.
 CFLAGS="$CFLAGS $user_CFLAGS"
 CXXFLAGS="$CXXFLAGS $user_CXXFLAGS"
+BITCODE_CFLAGS="$BITCODE_CFLAGS $user_BITCODE_CFLAGS"
+BITCODE_CXXFLAGS="$BITCODE_CXXFLAGS $user_BITCODE_CXXFLAGS"
+
+BITCODE_CFLAGS=$BITCODE_CFLAGS
+
+BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS
+
 
 # Check if the compiler still works with the final flag settings
 # (note, we're not checking that for CXX, which is optional)
@@ -17844,12 +18485,23 @@ _ACEOF
 $as_echo "$as_me: using compiler=$cc_string" >&6;}
 { $as_echo "$as_me:${as_lineno-$LINENO}: using CFLAGS=$CFLAGS" >&5
 $as_echo "$as_me: using CFLAGS=$CFLAGS" >&6;}
-{ $as_echo "$as_me:${as_lineno-$LINENO}: using CXXFLAGS=$CXXFLAGS" >&5
-$as_echo "$as_me: using CXXFLAGS=$CXXFLAGS" >&6;}
 { $as_echo "$as_me:${as_lineno-$LINENO}: using CPPFLAGS=$CPPFLAGS" >&5
 $as_echo "$as_me: using CPPFLAGS=$CPPFLAGS" >&6;}
 { $as_echo "$as_me:${as_lineno-$LINENO}: using LDFLAGS=$LDFLAGS" >&5
 $as_echo "$as_me: using LDFLAGS=$LDFLAGS" >&6;}
+# Currently only used when LLVM is used
+if test "$with_llvm" = yes ; then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: using CXX=$CXX" >&5
+$as_echo "$as_me: using CXX=$CXX" >&6;}
+   { $as_echo "$as_me:${as_lineno-$LINENO}: using CXXFLAGS=$CXXFLAGS" >&5
+$as_echo "$as_me: using CXXFLAGS=$CXXFLAGS" >&6;}
+   { $as_echo "$as_me:${as_lineno-$LINENO}: using CLANG=$CLANG" >&5
+$as_echo "$as_me: using CLANG=$CLANG" >&6;}
+   { $as_echo "$as_me:${as_lineno-$LINENO}: using BITCODE_CFLAGS=$BITCODE_CFLAGS" >&5
+$as_echo "$as_me: using BITCODE_CFLAGS=$BITCODE_CFLAGS" >&6;}
+   { $as_echo "$as_me:${as_lineno-$LINENO}: using BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS" >&5
+$as_echo "$as_me: using BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS" >&6;}
+fi
 
 # prepare build tree if outside source tree
 # Note 1: test -ef might not exist, but it's more reliable than `pwd`.
index 1dd7d723e1ac6df55468b41bec4ad4527b7f52d1..592d7aee861e5c8fcad1f7ec74e1696c0446440d 100644 (file)
@@ -375,6 +375,19 @@ choke me
 
 AC_SUBST(SUN_STUDIO_CC)
 
+
+#
+# LLVM
+#
+# Checked early because subsequent tests depend on it.
+PGAC_ARG_BOOL(with, llvm, no, [build with LLVM based JIT support],
+              [AC_DEFINE([USE_LLVM], 1, [Define to 1 to build with LLVM based JIT support. (--with-llvm)])])
+AC_SUBST(with_llvm)
+if test "$with_llvm" = yes ; then
+   PGAC_LLVM_SUPPORT()
+fi
+
+
 unset CFLAGS
 
 #
@@ -419,11 +432,32 @@ else
   fi
 fi
 
+# When generating bitcode (for inlining) we always want to use -O2
+# even when --enable-debug is specified. The bitcode it's not going to
+# be used for line-by-line debugging, and JIT inlining doesn't work
+# without at least -O1 (otherwise clang will emit 'noinline'
+# attributes everywhere), which is bad for testing.  Still allow the
+# environment to override if done explicitly.
+if test "$ac_env_BITCODE_CFLAGS_set" = set; then
+  BITCODE_CFLAGS=$ac_env_BITCODE_CFLAGS_value
+else
+  BITCODE_CFLAGS="-O2 $BITCODE_CFLAGS"
+fi
+if test "$ac_env_BITCODE_CXXFLAGS_set" = set; then
+  BITCODE_CXXFLAGS=$ac_env_BITCODE_CXXFLAGS_value
+else
+  BITCODE_CXXFLAGS="-O2 BITCODE_CXXFLAGS"
+fi
+
 # C[XX]FLAGS we determined above will be added back at the end
 user_CFLAGS=$CFLAGS
 CFLAGS=""
 user_CXXFLAGS=$CXXFLAGS
 CXXFLAGS=""
+user_BITCODE_CFLAGS=$BITCODE_CFLAGS
+BITCODE_CFLAGS=""
+user_BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS
+BITCODE_CXXFLAGS=""
 
 # set CFLAGS_VECTOR from the environment, if available
 if test "$ac_env_CFLAGS_VECTOR_set" = set; then
@@ -490,6 +524,20 @@ fi
 
 AC_SUBST(CFLAGS_VECTOR, $CFLAGS_VECTOR)
 
+# Determine flags used to emit bitcode for JIT inlining. Need to test
+# for behaviour changing compiler flags, to keep compatibility with
+# compiler used for normal postgres code.
+if test "$with_llvm" = yes ; then
+  CLANGXX="$CLANG -xc++"
+
+  PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fno-strict-aliasing])
+  PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fno-strict-aliasing])
+  PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fwrapv])
+  PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fwrapv])
+  PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-fexcess-precision=standard])
+  PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-fexcess-precision=standard])
+fi
+
 # supply -g if --enable-debug
 if test "$enable_debug" = yes && test "$ac_cv_prog_cc_g" = yes; then
   CFLAGS="$CFLAGS -g"
@@ -531,6 +579,11 @@ fi
 # the automatic additions.
 CFLAGS="$CFLAGS $user_CFLAGS"
 CXXFLAGS="$CXXFLAGS $user_CXXFLAGS"
+BITCODE_CFLAGS="$BITCODE_CFLAGS $user_BITCODE_CFLAGS"
+BITCODE_CXXFLAGS="$BITCODE_CXXFLAGS $user_BITCODE_CXXFLAGS"
+
+AC_SUBST(BITCODE_CFLAGS, $BITCODE_CFLAGS)
+AC_SUBST(BITCODE_CXXFLAGS, $BITCODE_CXXFLAGS)
 
 # Check if the compiler still works with the final flag settings
 # (note, we're not checking that for CXX, which is optional)
@@ -2246,9 +2299,16 @@ AC_SUBST(PG_VERSION_NUM)
 
 AC_MSG_NOTICE([using compiler=$cc_string])
 AC_MSG_NOTICE([using CFLAGS=$CFLAGS])
-AC_MSG_NOTICE([using CXXFLAGS=$CXXFLAGS])
 AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
 AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
+# Currently only used when LLVM is used
+if test "$with_llvm" = yes ; then
+   AC_MSG_NOTICE([using CXX=$CXX])
+   AC_MSG_NOTICE([using CXXFLAGS=$CXXFLAGS])
+   AC_MSG_NOTICE([using CLANG=$CLANG])
+   AC_MSG_NOTICE([using BITCODE_CFLAGS=$BITCODE_CFLAGS])
+   AC_MSG_NOTICE([using BITCODE_CXXFLAGS=$BITCODE_CXXFLAGS])
+fi
 
 # prepare build tree if outside source tree
 # Note 1: test -ef might not exist, but it's more reliable than `pwd`.
index 1ac18e459363cec574aceae436408349657b0fb4..3bbdf17b7447733a892315c878b5a9382220e181 100644 (file)
@@ -191,6 +191,7 @@ with_krb_srvnam     = @with_krb_srvnam@
 with_ldap      = @with_ldap@
 with_libxml    = @with_libxml@
 with_libxslt   = @with_libxslt@
+with_llvm      = @with_llvm@
 with_system_tzdata = @with_system_tzdata@
 with_uuid      = @with_uuid@
 with_zlib      = @with_zlib@
@@ -225,6 +226,11 @@ TCL_SHLIB_LD_LIBS  = @TCL_SHLIB_LD_LIBS@
 PTHREAD_CFLAGS         = @PTHREAD_CFLAGS@
 PTHREAD_LIBS           = @PTHREAD_LIBS@
 
+LLVM_CONFIG = @LLVM_CONFIG@
+LLVM_BINPATH = @LLVM_BINPATH@
+CLANG = @CLANG@
+BITCODE_CFLAGS = @BITCODE_CFLAGS@
+BITCODE_CXXFLAGS = @BITCODE_CXXFLAGS@
 
 ##########################################################################
 #
@@ -255,6 +261,10 @@ CFLAGS_VECTOR = @CFLAGS_VECTOR@
 CFLAGS_SSE42 = @CFLAGS_SSE42@
 CXXFLAGS = @CXXFLAGS@
 
+LLVM_CPPFLAGS = @LLVM_CPPFLAGS@
+LLVM_CFLAGS = @LLVM_CFLAGS@
+LLVM_CXXFLAGS = @LLVM_CXXFLAGS@
+
 # Kind-of compilers
 
 BISON = @BISON@
@@ -275,6 +285,7 @@ LDAP_LIBS_FE = @LDAP_LIBS_FE@
 LDAP_LIBS_BE = @LDAP_LIBS_BE@
 UUID_LIBS = @UUID_LIBS@
 UUID_EXTRA_OBJS = @UUID_EXTRA_OBJS@
+LLVM_LIBS=@LLVM_LIBS@
 LD = @LD@
 with_gnu_ld = @with_gnu_ld@
 
index ea3b2b6ce770e8e45fe2b5e2e25e37ab03b5e92f..c5db5430b9dc3c73c090f1f3ff979563ca99164a 100644 (file)
    don't. */
 #undef HAVE_DECL_F_FULLFSYNC
 
+/* Define to 1 if you have the declaration of `LLVMGetHostCPUName', and to 0
+   if you don't. */
+#undef HAVE_DECL_LLVMGETHOSTCPUNAME
+
+/* Define to 1 if you have the declaration of `LLVMOrcGetSymbolAddressIn', and
+   to 0 if you don't. */
+#undef HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN
+
+/* Define to 1 if you have the declaration of `LLVMOrcRegisterGDB', and to 0
+   if you don't. */
+#undef HAVE_DECL_LLVMORCREGISTERGDB
+
+/* Define to 1 if you have the declaration of `LLVMOrcRegisterPerf', and to 0
+   if you don't. */
+#undef HAVE_DECL_LLVMORCREGISTERPERF
+
 /* Define to 1 if you have the declaration of `posix_fadvise', and to 0 if you
    don't. */
 #undef HAVE_DECL_POSIX_FADVISE
    (--with-libxslt) */
 #undef USE_LIBXSLT
 
+/* Define to 1 to build with LLVM based JIT support. (--with-llvm) */
+#undef USE_LLVM
+
 /* Define to select named POSIX semaphores. */
 #undef USE_NAMED_POSIX_SEMAPHORES
 
index 7150f7614f2145f15b403cab00a5ffde309244e2..e934cf87bd2c4a0f4abac02c9d21418715077cf8 100644 (file)
    don't. */
 #define HAVE_DECL_F_FULLFSYNC 0
 
+/* Define to 1 if you have the declaration of `LLVMGetHostCPUName', and to 0
+   if you don't. */
+#define HAVE_DECL_LLVMGETHOSTCPUNAME 0
+
+/* Define to 1 if you have the declaration of `LLVMOrcGetSymbolAddressIn', and
+   to 0 if you don't. */
+#define HAVE_DECL_LLVMORCGETSYMBOLADDRESSIN 0
+
+/* Define to 1 if you have the declaration of `LLVMOrcRegisterGDB', and to 0
+   if you don't. */
+#define HAVE_DECL_LLVMORCREGISTERGDB 0
+
+/* Define to 1 if you have the declaration of `LLVMOrcRegisterPerf', and to 0
+   if you don't. */
+#define HAVE_DECL_LLVMORCREGISTERPERF 0
+
 /* Define to 1 if you have the declaration of `snprintf', and to 0 if you
    don't. */
 #define HAVE_DECL_SNPRINTF 1
 /* Define to 1 to build with LDAP support. (--with-ldap) */
 /* #undef USE_LDAP */
 
+/* Define to 1 to build with LLVM based JIT support. (--with-llvm) */
+/* #undef USE_LLVM */
+
 /* Define to select named POSIX semaphores. */
 /* #undef USE_NAMED_POSIX_SEMAPHORES */