From 94afeb62c01d40566c263b7fa19e9c367f4ff87c Mon Sep 17 00:00:00 2001 From: Jesse Zhang and Omer Arap Date: Mon, 8 May 2017 12:23:39 -0700 Subject: [PATCH] Adds a check for Greenplum patched Xerces [#138725549] If gpdb is configured to build with orca it requires a Greenplum patched version of Xerces library. This commit adds an explicit check for the patched Xerces. This also gives us an opportunity to be more idiomatic in doing autoconf: we are replacing the manual manipulation of LIBS in src/backend/Makefile with `AC_CHECK_LIB` in `configure.in`. --- aclocal.m4 | 1 + config/orca.m4 | 23 ++++++++ configure | 136 +++++++++++++++++++++++++++++++++++++++++++ configure.in | 1 + src/backend/Makefile | 1 - 5 files changed, 161 insertions(+), 1 deletion(-) create mode 100644 config/orca.m4 diff --git a/aclocal.m4 b/aclocal.m4 index 4b3fe4f40a..280e801a5c 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -13,3 +13,4 @@ m4_include([config/python.m4]) m4_include([config/tcl.m4]) m4_include([config/curl.m4]) m4_include([config/ax_python_module.m4]) +m4_include([config/orca.m4]) diff --git a/config/orca.m4 b/config/orca.m4 new file mode 100644 index 0000000000..3977ce5160 --- /dev/null +++ b/config/orca.m4 @@ -0,0 +1,23 @@ +# PGAC_CHECK_ORCA_XERCES +# --------------------- +# Check if the Greenplum patched version of Xerces-C is found +AC_DEFUN([PGAC_CHECK_ORCA_XERCES], +[ +AC_CHECK_LIB(xerces-c, strnicmp, [], + [AC_MSG_ERROR([library xerces-c is required for Pivotal Query Optimizer to build, you can build it from https://github.com/greenplum-db/gp-xerces])] +) +AC_MSG_CHECKING([[for Greenplum patched Xerces-C]]) +AC_LANG_PUSH([C++]) +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ +#include "xercesc/util/XMemory.hpp" +#include "xercesc/dom/DOMImplementationList.hpp" +]], +[ +xercesc::DOMImplementationList* derived_ptr = NULL; +xercesc::XMemory* base_ptr = derived_ptr; +])], +[AC_MSG_RESULT([[ok]])], +[AC_MSG_ERROR([Your Xerces is not patched, you can build it from https://github.com/greenplum-db/gp-xerces])] +) +AC_LANG_POP([C++]) +])# PGAC_CHECK_ORCA_XERCES diff --git a/configure b/configure index 66f95e80c1..30ba3ffd43 100755 --- a/configure +++ b/configure @@ -2035,6 +2035,52 @@ $as_echo "$ac_res" >&6; } } # ac_fn_c_check_header_compile +# ac_fn_cxx_try_link LINENO +# ------------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_cxx_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_cxx_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_cxx_try_link + # ac_fn_c_check_func LINENO FUNC VAR # ---------------------------------- # Tests whether FUNC exists, setting the cache variable VAR accordingly @@ -10969,6 +11015,96 @@ fi done +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strnicmp in -lxerces-c" >&5 +$as_echo_n "checking for strnicmp in -lxerces-c... " >&6; } +if ${ac_cv_lib_xerces_c_strnicmp+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lxerces-c $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char strnicmp (); +int +main () +{ +return strnicmp (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_xerces_c_strnicmp=yes +else + ac_cv_lib_xerces_c_strnicmp=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_xerces_c_strnicmp" >&5 +$as_echo "$ac_cv_lib_xerces_c_strnicmp" >&6; } +if test "x$ac_cv_lib_xerces_c_strnicmp" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBXERCES_C 1 +_ACEOF + + LIBS="-lxerces-c $LIBS" + +else + as_fn_error $? "library xerces-c is required for Pivotal Query Optimizer to build, you can build it from https://github.com/greenplum-db/gp-xerces" "$LINENO" 5 + +fi + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Greenplum patched Xerces-C" >&5 +$as_echo_n "checking for Greenplum patched Xerces-C... " >&6; } +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. */ + +#include "xercesc/util/XMemory.hpp" +#include "xercesc/dom/DOMImplementationList.hpp" + +int +main () +{ + +xercesc::DOMImplementationList* derived_ptr = NULL; +xercesc::XMemory* base_ptr = derived_ptr; + + ; + return 0; +} +_ACEOF +if ac_fn_cxx_try_link "$LINENO"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } +else + as_fn_error $? "Your Xerces is not patched, you can build it from https://github.com/greenplum-db/gp-xerces" "$LINENO" 5 + +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext 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 + + + fi # fi for ac_header in atomic.h crypt.h dld.h endian.h fp_class.h getopt.h ieeefp.h ifaddrs.h langinfo.h mbarrier.h poll.h pwd.h sys/ioctl.h sys/ipc.h sys/poll.h sys/pstat.h sys/resource.h sys/select.h sys/sem.h sys/shm.h sys/socket.h sys/sockio.h sys/tas.h sys/time.h sys/un.h termios.h ucred.h utime.h wchar.h wctype.h kernel/OS.h kernel/image.h SupportDefs.h diff --git a/configure.in b/configure.in index 6c9e10657b..d072b8cd52 100644 --- a/configure.in +++ b/configure.in @@ -1298,6 +1298,7 @@ AS_IF([test "$enable_orca" = yes], [ # then AC_CHECK_HEADERS(gpopt/init.h, [], [AC_MSG_ERROR([gpopt/init.h GPOPT header file is required for Greenplum Query Optimizer (orca)])]) AC_CHECK_HEADERS(gpos/config.h, [], [AC_MSG_ERROR([gpos/config.h GPOS header file is required for Greenplum Query Optimizer (orca)])]) + PGAC_CHECK_ORCA_XERCES ]) # fi dnl sys/socket.h is required by AC_FUNC_ACCEPT_ARGTYPES diff --git a/src/backend/Makefile b/src/backend/Makefile index 940b81ea80..6cc43055d2 100644 --- a/src/backend/Makefile +++ b/src/backend/Makefile @@ -65,7 +65,6 @@ LIBS := $(filter-out -lreadline -ledit -ltermcap -lncurses -lcurses, $(LIBS)) # ORCA libraries. ifeq ($(enable_orca),yes) LIBS := $(LIBS) -lgpopt -lnaucrates -lgpdbcost -lgpos -LIBS := $(LIBS) -lxerces-c-3.1 endif # adding codegen libraries -- GitLab