WIP: Add configure infrastructure to enable LLVM.
authorAndres Freund <andres@anarazel.de>
Tue, 14 Mar 2017 03:22:10 +0000 (20:22 -0700)
committerAndres Freund <andres@anarazel.de>
Fri, 1 Sep 2017 06:22:35 +0000 (23:22 -0700)
configure
configure.in
src/Makefile.global.in
src/backend/Makefile
src/include/pg_config.h.in

index a2f9a256b4f840476cc91fa1a30d3d29e72189ce..fe905e294bd92a12bc389e2e824a748417e2d207 100755 (executable)
--- a/configure
+++ b/configure
@@ -700,6 +700,9 @@ LDFLAGS_EX
 ELF_SYS
 EGREP
 GREP
+with_llvm
+LLVM_LIBS
+LLVM_CONFIG
 with_zlib
 with_system_tzdata
 with_libxslt
@@ -848,6 +851,7 @@ with_libxml
 with_libxslt
 with_system_tzdata
 with_zlib
+with_llvm
 with_gnu_ld
 enable_largefile
 enable_float4_byval
@@ -1546,6 +1550,7 @@ Optional Packages:
   --with-system-tzdata=DIR
                           use system time zone data in DIR
   --without-zlib          do not use Zlib
+  --with-llvm             build with llvm (JIT) support
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
 
 Some influential environment variables:
@@ -6460,6 +6465,98 @@ fi
 
 
 
+
+
+
+# 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 llvm-config
+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_LLVM_CONFIG+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$LLVM_CONFIG"; then
+  ac_cv_prog_LLVM_CONFIG="$LLVM_CONFIG" # 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_LLVM_CONFIG="$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
+LLVM_CONFIG=$ac_cv_prog_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
+
+  if test -n "$LLVM_CONFIG"; then
+    for pgac_option in `$LLVM_CONFIG --cflags`; do
+      case $pgac_option in
+        -I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;
+      esac
+    done
+    for pgac_option in `$LLVM_CONFIG --ldflags`; do
+      case $pgac_option in
+        -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      esac
+    done
+    for pgac_option in `$LLVM_CONFIG --libs --system-libs engine`; do
+      case $pgac_option in
+        -l*) LLVM_LIBS="$LLVM_LIBS $pgac_option";;
+      esac
+    done
+  fi
+fi
+
+
+
+
 #
 # Elf
 #
index e94fba5235cc29636021ae59257ff9e85a1e1fce..a99da9dff3ca672b0a98c693eff31f199fffe0cc 100644 (file)
@@ -856,6 +856,33 @@ PGAC_ARG_BOOL(with, zlib, yes,
               [do not use Zlib])
 AC_SUBST(with_zlib)
 
+PGAC_ARG_BOOL(with, llvm, no, [build with llvm (JIT) support],
+              [AC_DEFINE([USE_LLVM], 1, [Define to 1 to build with llvm support. (--with-llvm)])])
+
+if test "$with_llvm" = yes ; then
+  AC_CHECK_PROGS(LLVM_CONFIG, llvm-config)
+  if test -n "$LLVM_CONFIG"; then
+    for pgac_option in `$LLVM_CONFIG --cflags`; do
+      case $pgac_option in
+        -I*|-D*) CPPFLAGS="$CPPFLAGS $pgac_option";;
+      esac
+    done
+    for pgac_option in `$LLVM_CONFIG --ldflags`; do
+      case $pgac_option in
+        -L*) LDFLAGS="$LDFLAGS $pgac_option";;
+      esac
+    done
+    for pgac_option in `$LLVM_CONFIG --libs --system-libs engine`; do
+      case $pgac_option in
+        -l*) LLVM_LIBS="$LLVM_LIBS $pgac_option";;
+      esac
+    done
+  fi
+fi
+AC_SUBST(LLVM_LIBS)
+AC_SUBST(with_llvm)
+
+
 #
 # Elf
 #
index e8b3a519cb4fa9194124cd8e582ef23189481ff6..ab5862b472d26f02ff89e6b62b30be06d4cbaf87 100644 (file)
@@ -186,6 +186,7 @@ with_tcl    = @with_tcl@
 with_openssl   = @with_openssl@
 with_selinux   = @with_selinux@
 with_systemd   = @with_systemd@
+with_llvm  = @with_llvm@
 with_libxml    = @with_libxml@
 with_libxslt   = @with_libxslt@
 with_system_tzdata = @with_system_tzdata@
@@ -270,6 +271,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 aab676dbbdf7ff01f2444aeaed0f983ce1b8877f..c82ad75bdaa3a83f995c51d88652868b57c51220 100644 (file)
@@ -45,6 +45,10 @@ LIBS := $(filter-out -lpgport -lpgcommon, $(LIBS)) $(LDAP_LIBS_BE) $(ICU_LIBS)
 # The backend doesn't need everything that's in LIBS, however
 LIBS := $(filter-out -lz -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS))
 
+# Only the backend needs LLVM (if enabled) and it's a big library, so
+# only specify here
+LIBS += $(LLVM_LIBS)
+
 ifeq ($(with_systemd),yes)
 LIBS += -lsystemd
 endif
index dcb7a1a3209ccf42b8ff529bbf233a5c5fc1cac1..633c670de903e60cb54c0e8cbb063016c8022ed0 100644 (file)
    (--with-libxslt) */
 #undef USE_LIBXSLT
 
+/* Define to 1 to build with llvm support. (--with-llvm) */
+#undef USE_LLVM
+
 /* Define to select named POSIX semaphores. */
 #undef USE_NAMED_POSIX_SEMAPHORES