Commit 5e221713 authored by Tom Lane's avatar Tom Lane

Make some fixes to allow building Postgres on macOS 10.14 ("Mojave").

Apple's latest rearrangements of the system-supplied headers have broken
building of PL/Perl and PL/Tcl.  The only practical way to fix PL/Tcl is to
start using the "-isysroot" compiler flag to point to SDK-supplied headers,
as Apple expects.  We must also start distinguishing where to find Perl's
headers from where to find its shared library; but that seems like good
cleanup anyway.

Extensions that formerly did something like -I$(perl_archlibexp)/CORE
should now do -I$(perl_includedir)/CORE instead.  perl_archlibexp
is still the place to look for libperl.so, though.

If for some reason you don't like the default -isysroot setting, you can
override that by setting PG_SYSROOT in configure's arguments.  I don't
currently think people would need to do so, unless maybe for cross-version
build purposes.

In addition, teach configure where to find tclConfig.sh.  Our traditional
method of searching $auto_path hasn't worked for the last couple of macOS
releases, and it now seems clear that Apple's not going to change that.
The workaround of manually specifying --with-tclconfig was annoying
already, but Mojave's made it a lot more so because the sysroot path now
has to be included as well.  Let's just wire the knowledge into configure
instead.  To avoid breaking builds against non-default Tcl installations
(e.g. MacPorts) wherein the $auto_path method probably still works,
arrange to try the additional case only after all else has failed.

Back-patch to all supported versions, since at least the buildfarm
cares about that.  The changes are set up to not do anything on macOS
releases that are old enough to not have functional sysroot trees.
parent 5b7e0367
...@@ -13,6 +13,10 @@ fi ...@@ -13,6 +13,10 @@ fi
# PGAC_PATH_TCLCONFIGSH([SEARCH-PATH]) # PGAC_PATH_TCLCONFIGSH([SEARCH-PATH])
# ------------------------------------ # ------------------------------------
# If the user doesn't specify $TCL_CONFIG_SH directly, search for it in
# the list of directories passed as parameter (from --with-tclconfig).
# If no list is given, try the Tcl shell's $auto_path.
AC_DEFUN([PGAC_PATH_TCLCONFIGSH], AC_DEFUN([PGAC_PATH_TCLCONFIGSH],
[AC_REQUIRE([PGAC_PATH_TCLSH])[]dnl [AC_REQUIRE([PGAC_PATH_TCLSH])[]dnl
AC_BEFORE([$0], [PGAC_PATH_TKCONFIGSH])[]dnl AC_BEFORE([$0], [PGAC_PATH_TKCONFIGSH])[]dnl
...@@ -24,7 +28,14 @@ if test -z "$TCL_CONFIG_SH"; then ...@@ -24,7 +28,14 @@ if test -z "$TCL_CONFIG_SH"; then
set X $pgac_test_dirs; shift set X $pgac_test_dirs; shift
if test $[#] -eq 0; then if test $[#] -eq 0; then
test -z "$TCLSH" && AC_MSG_ERROR([unable to locate tclConfig.sh because no Tcl shell was found]) test -z "$TCLSH" && AC_MSG_ERROR([unable to locate tclConfig.sh because no Tcl shell was found])
set X `echo 'puts $auto_path' | $TCLSH`; shift pgac_test_dirs=`echo 'puts $auto_path' | $TCLSH`
# On newer macOS, $auto_path frequently doesn't include the place
# where tclConfig.sh actually lives. Append that to the end, so as not
# to break cases where a non-default Tcl installation is being used.
if test -d "$PG_SYSROOT/System/Library/Frameworks/Tcl.framework" ; then
pgac_test_dirs="$pgac_test_dirs $PG_SYSROOT/System/Library/Frameworks/Tcl.framework"
fi
set X $pgac_test_dirs; shift
fi fi
for pgac_dir do for pgac_dir do
......
...@@ -668,6 +668,7 @@ python_majorversion ...@@ -668,6 +668,7 @@ python_majorversion
PYTHON PYTHON
perl_embed_ldflags perl_embed_ldflags
perl_embed_ccflags perl_embed_ccflags
perl_includedir
perl_useshrplib perl_useshrplib
perl_privlibexp perl_privlibexp
perl_archlibexp perl_archlibexp
...@@ -9773,6 +9774,14 @@ You might have to rebuild your Perl installation. Refer to the ...@@ -9773,6 +9774,14 @@ You might have to rebuild your Perl installation. Refer to the
documentation for details. Use --without-perl to disable building documentation for details. Use --without-perl to disable building
PL/Perl." "$LINENO" 5 PL/Perl." "$LINENO" 5
fi fi
# On most platforms, archlibexp is also where the Perl include files live ...
perl_includedir="$perl_archlibexp"
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
if test x"$PG_SYSROOT" != x"" ; then
if test -d "$PG_SYSROOT$perl_archlibexp" ; then
perl_includedir="$PG_SYSROOT$perl_archlibexp"
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLAGS recommended by Perl" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLAGS recommended by Perl" >&5
$as_echo_n "checking for CFLAGS recommended by Perl... " >&6; } $as_echo_n "checking for CFLAGS recommended by Perl... " >&6; }
...@@ -18306,7 +18315,14 @@ if test -z "$TCL_CONFIG_SH"; then ...@@ -18306,7 +18315,14 @@ if test -z "$TCL_CONFIG_SH"; then
set X $pgac_test_dirs; shift set X $pgac_test_dirs; shift
if test $# -eq 0; then if test $# -eq 0; then
test -z "$TCLSH" && as_fn_error $? "unable to locate tclConfig.sh because no Tcl shell was found" "$LINENO" 5 test -z "$TCLSH" && as_fn_error $? "unable to locate tclConfig.sh because no Tcl shell was found" "$LINENO" 5
set X `echo 'puts $auto_path' | $TCLSH`; shift pgac_test_dirs=`echo 'puts $auto_path' | $TCLSH`
# On newer macOS, $auto_path frequently doesn't include the place
# where tclConfig.sh actually lives. Append that to the end, so as not
# to break cases where a non-default Tcl installation is being used.
if test -d "$PG_SYSROOT/System/Library/Frameworks/Tcl.framework" ; then
pgac_test_dirs="$pgac_test_dirs $PG_SYSROOT/System/Library/Frameworks/Tcl.framework"
fi
set X $pgac_test_dirs; shift
fi fi
for pgac_dir do for pgac_dir do
...@@ -18355,7 +18371,7 @@ fi ...@@ -18355,7 +18371,7 @@ fi
# check for <perl.h> # check for <perl.h>
if test "$with_perl" = yes; then if test "$with_perl" = yes; then
ac_save_CPPFLAGS=$CPPFLAGS ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I$perl_archlibexp/CORE" CPPFLAGS="$CPPFLAGS -I$perl_includedir/CORE"
ac_fn_c_check_header_compile "$LINENO" "perl.h" "ac_cv_header_perl_h" "#include <EXTERN.h> ac_fn_c_check_header_compile "$LINENO" "perl.h" "ac_cv_header_perl_h" "#include <EXTERN.h>
" "
if test "x$ac_cv_header_perl_h" = xyes; then : if test "x$ac_cv_header_perl_h" = xyes; then :
......
...@@ -1044,6 +1044,15 @@ You might have to rebuild your Perl installation. Refer to the ...@@ -1044,6 +1044,15 @@ You might have to rebuild your Perl installation. Refer to the
documentation for details. Use --without-perl to disable building documentation for details. Use --without-perl to disable building
PL/Perl.]) PL/Perl.])
fi fi
# On most platforms, archlibexp is also where the Perl include files live ...
perl_includedir="$perl_archlibexp"
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
if test x"$PG_SYSROOT" != x"" ; then
if test -d "$PG_SYSROOT$perl_archlibexp" ; then
perl_includedir="$PG_SYSROOT$perl_archlibexp"
fi
fi
AC_SUBST(perl_includedir)dnl
PGAC_CHECK_PERL_EMBED_CCFLAGS PGAC_CHECK_PERL_EMBED_CCFLAGS
PGAC_CHECK_PERL_EMBED_LDFLAGS PGAC_CHECK_PERL_EMBED_LDFLAGS
fi fi
...@@ -2229,7 +2238,7 @@ fi ...@@ -2229,7 +2238,7 @@ fi
# check for <perl.h> # check for <perl.h>
if test "$with_perl" = yes; then if test "$with_perl" = yes; then
ac_save_CPPFLAGS=$CPPFLAGS ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I$perl_archlibexp/CORE" CPPFLAGS="$CPPFLAGS -I$perl_includedir/CORE"
AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file <perl.h> is required for Perl])], AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file <perl.h> is required for Perl])],
[#include <EXTERN.h>]) [#include <EXTERN.h>])
# While we're at it, check that we can link to libperl. # While we're at it, check that we can link to libperl.
......
...@@ -39,4 +39,4 @@ endif ...@@ -39,4 +39,4 @@ endif
# last, probably because it sometimes contains some header files with names # last, probably because it sometimes contains some header files with names
# that clash with some of ours, or with some that we include, notably on # that clash with some of ours, or with some that we include, notably on
# Windows. # Windows.
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_archlibexp)/CORE override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE
...@@ -39,4 +39,4 @@ endif ...@@ -39,4 +39,4 @@ endif
# last, probably because it sometimes contains some header files with names # last, probably because it sometimes contains some header files with names
# that clash with some of ours, or with some that we include, notably on # that clash with some of ours, or with some that we include, notably on
# Windows. # Windows.
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_archlibexp)/CORE override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE
...@@ -331,6 +331,7 @@ else ...@@ -331,6 +331,7 @@ else
endif endif
perl_archlibexp = @perl_archlibexp@ perl_archlibexp = @perl_archlibexp@
perl_privlibexp = @perl_privlibexp@ perl_privlibexp = @perl_privlibexp@
perl_includedir = @perl_includedir@
perl_embed_ccflags = @perl_embed_ccflags@ perl_embed_ccflags = @perl_embed_ccflags@
perl_embed_ldflags = @perl_embed_ldflags@ perl_embed_ldflags = @perl_embed_ldflags@
......
...@@ -16,7 +16,7 @@ endif ...@@ -16,7 +16,7 @@ endif
# probably because it sometimes contains some header files with names # probably because it sometimes contains some header files with names
# that clash with some of ours, or with some that we include, notably on # that clash with some of ours, or with some that we include, notably on
# Windows. # Windows.
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_archlibexp)/CORE override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE
rpathdir = $(perl_archlibexp)/CORE rpathdir = $(perl_archlibexp)/CORE
......
...@@ -3,6 +3,18 @@ ...@@ -3,6 +3,18 @@
# Note: Darwin is the original code name for macOS, also known as OS X. # Note: Darwin is the original code name for macOS, also known as OS X.
# We still use "darwin" as the port name, partly because config.guess does. # We still use "darwin" as the port name, partly because config.guess does.
# Select where system include files should be sought.
if test x"$PG_SYSROOT" = x"" ; then
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`
fi
if test x"$PG_SYSROOT" != x"" ; then
if test -d "$PG_SYSROOT" ; then
CPPFLAGS="$CPPFLAGS -isysroot $PG_SYSROOT"
else
PG_SYSROOT=""
fi
fi
# Select appropriate semaphore support. Darwin 6.0 (macOS 10.2) and up # Select appropriate semaphore support. Darwin 6.0 (macOS 10.2) and up
# support System V semaphores; before that we have to use named POSIX # support System V semaphores; before that we have to use named POSIX
# semaphores, which are less good for our purposes because they eat a # semaphores, which are less good for our purposes because they eat a
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment