You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2016/04/27 19:05:22 UTC

[trafficserver] branch master updated: TS-4375: Fix PCRE link issues on Darwin.

This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

The following commit(s) were added to refs/heads/master by this push:
       new  cbf10fd   TS-4375: Fix PCRE link issues on Darwin.
cbf10fd is described below

commit cbf10fd45fa8429dc9b700252fff1a749d252bfa
Author: James Peach <jp...@apache.org>
AuthorDate: Wed Apr 27 09:42:15 2016 -0700

    TS-4375: Fix PCRE link issues on Darwin.
    
    Darwin has a copy of PCRE in the SDK, but it has JIT disabled. When
    we use pkg-config to find the PCRE version, we find the Homebrew
    version in /usr/local which does have JIT enabled. Now, we end up
    searching for Expat in the SDK so the SDK ends up in our library
    search path causing us to find the wrong version of libpcre. Link
    failures ensue.
    
    Since it is so trivial to just use expat from Homebrew, remove the
    SDK path search and tidy up the XML m4 macros to be a bit more
    informative.
---
 build/xml.m4 | 75 ++++++++++++++++++++++++++++++++++--------------------------
 configure.ac |  5 +---
 2 files changed, 44 insertions(+), 36 deletions(-)

diff --git a/build/xml.m4 b/build/xml.m4
index 2793fea..43fbc30 100644
--- a/build/xml.m4
+++ b/build/xml.m4
@@ -22,30 +22,43 @@ dnl
 dnl TS_CHECK_XML: look for xml libraries and headers
 dnl
 AC_DEFUN([TS_CHECK_XML], [
-  enable_xml=no
-  AC_MSG_CHECKING(["For XML parser"])
+  _xml_parser=none
+
   AC_ARG_WITH(xml, [AC_HELP_STRING([--with-xml=(expat|libxml2)],[select XML parser])],
   [
     if test "$withval" = "expat" ; then
-      TS_CHECK_XML_EXPAT
+      TS_CHECK_XML_EXPAT([_xml_parser=expat])
     elif test "$withval" = "libxml2" ; then
-      TS_CHECK_XML_LIBXML2
+      TS_CHECK_XML_LIBXML2([_xml_parser=libxlm2])
     else
       AC_MSG_ERROR([Unrecognised --with-xml option])
     fi
   ],
   [
-    TS_CHECK_XML_LIBXML2
-    if test "$enable_xml" = "no"; then
-      TS_CHECK_XML_EXPAT
-    fi
+    # Default to preferring libxml2 over expat.
+    TS_CHECK_XML_LIBXML2([_xml_parser=libxml2],[
+      TS_CHECK_XML_EXPAT([_xml_parser=expat])
+    ])
   ])
-  if test "$enable_xml" = "no"; then
-    AC_MSG_ERROR([An XML parser (expat or libxml2) is required.])
-  fi
+
+  AC_MSG_CHECKING([for an XML parser])
+  AC_MSG_RESULT([$_xml_parser])
+
+  AS_IF([test "$_xml_parser" = "none"], [
+    AC_MSG_ERROR([missing XML parser
+
+An XML parser (expat or libxml2) is required. Use the
+--with-xml option to select between libxml2 and expat.
+Use the --with-libxml2 or --with-expat options to select
+a specific installation of each library.
+    ])
+  ])
+
+  unset _xml_parser
 ])
 dnl
 
+dnl TS_CHECK_XML_LIBXML2(action-if-found, action-if-not-found)
 AC_DEFUN([TS_CHECK_XML_LIBXML2], [
   enable_libxml2=no
   libxml2_include=""
@@ -95,13 +108,17 @@ AC_DEFUN([TS_CHECK_XML_LIBXML2], [
         TS_ADDTO_RPATH(${libxml2_ldflags})
       fi
       TS_ADDTO(LIBS, -lxml2)
-      enable_xml=yes
+      # libxml action-if-found
+      $1
     else
-      AC_MSG_WARN(["Failed to find libxml2"])
+      AC_MSG_WARN([failed to find libxml2])
+      # libxml action-if-not-found
+      $2
     fi
   fi
 ])
 
+dnl TS_CHECK_XML_EXPAT(action-if-found, action-if-not-found)
 AC_DEFUN([TS_CHECK_XML_EXPAT], [
 enable_expat=no
 AC_ARG_WITH(expat, [AC_HELP_STRING([--with-expat=DIR],[use a specific Expat library])],
@@ -130,24 +147,15 @@ if test "x$expat_base_dir" = "x"; then
   AC_MSG_CHECKING([for Expat location])
   AC_CACHE_VAL(ats_cv_expat_dir,[
   _expat_dir_list=""
-  case $host_os_def in
-    darwin)
-    for dir in /usr/local /usr "`xcrun -show-sdk-path 2>/dev/null`/usr" ; do
-      if test -d $dir && test -f $dir/include/expat.h; then
-        ats_cv_expat_dir=$dir
-        break
-      fi
-    done
-    ;;
-    *)
-    for dir in /usr/local /usr; do
-      if test -d $dir && test -f $dir/include/expat.h; then
-        ats_cv_expat_dir=$dir
-        break
-      fi
-    done
-    ;;
-  esac
+  # On Darwin we used to check the OS XSDK for expat, but this causes us
+  # to accidentally link the wrong version of pcre (see TS-4385). Best to
+  # just avoid the SDK in most cases.
+  for dir in /usr/local /usr; do
+    if test -d $dir && test -f $dir/include/expat.h; then
+      ats_cv_expat_dir=$dir
+      break
+    fi
+  done
 
   unset _expat_dir_list
   ])
@@ -186,14 +194,17 @@ if test "$enable_expat" != "no"; then
       AC_CHECK_HEADERS(expat.h, [expat_have_headers=1])
   fi
   if test "$expat_have_headers" != "0"; then
-    enable_xml=yes
 
     AC_SUBST([LIBEXPAT],["-lexpat"])
     AC_DEFINE([HAVE_LIBEXPAT],[1],[Define to 1 if you have Expat library])
+    # expat action-if-found
+    $1
   else
     enable_expat=no
     CPPFLAGS=$saved_cppflags
     LDFLAGS=$saved_ldflags
+    # expat action-if-not-found
+    $2
   fi
 fi
 AC_SUBST(expath)
diff --git a/configure.ac b/configure.ac
index 75e391d..aef9905 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1188,12 +1188,9 @@ if test "x${TCL_INCLUDE_SPEC}" != "x-I/usr/include"; then
 fi
 
 #
-# Check for XML parser
+# Check for XML parser. Required.
 #
 TS_CHECK_XML
-if test "x${enable_xml}" != "xyes"; then
-  AC_MSG_ERROR([Need at least one XML library, --with-expat is supported])
-fi
 
 AC_CHECK_FUNCS([clock_gettime kqueue epoll_ctl posix_memalign posix_fadvise posix_madvise posix_fallocate inotify_init])
 AC_CHECK_FUNCS([lrand48_r srand48_r port_create strlcpy strlcat sysconf sysctlbyname getpagesize])

-- 
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].