Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 5e22171

Browse files
committed
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.
1 parent 5b7e036 commit 5e22171

File tree

8 files changed

+56
-7
lines changed

8 files changed

+56
-7
lines changed

config/tcl.m4

+12-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ fi
1313

1414
# PGAC_PATH_TCLCONFIGSH([SEARCH-PATH])
1515
# ------------------------------------
16+
# If the user doesn't specify $TCL_CONFIG_SH directly, search for it in
17+
# the list of directories passed as parameter (from --with-tclconfig).
18+
# If no list is given, try the Tcl shell's $auto_path.
19+
1620
AC_DEFUN([PGAC_PATH_TCLCONFIGSH],
1721
[AC_REQUIRE([PGAC_PATH_TCLSH])[]dnl
1822
AC_BEFORE([$0], [PGAC_PATH_TKCONFIGSH])[]dnl
@@ -24,7 +28,14 @@ if test -z "$TCL_CONFIG_SH"; then
2428
set X $pgac_test_dirs; shift
2529
if test $[#] -eq 0; then
2630
test -z "$TCLSH" && AC_MSG_ERROR([unable to locate tclConfig.sh because no Tcl shell was found])
27-
set X `echo 'puts $auto_path' | $TCLSH`; shift
31+
pgac_test_dirs=`echo 'puts $auto_path' | $TCLSH`
32+
# On newer macOS, $auto_path frequently doesn't include the place
33+
# where tclConfig.sh actually lives. Append that to the end, so as not
34+
# to break cases where a non-default Tcl installation is being used.
35+
if test -d "$PG_SYSROOT/System/Library/Frameworks/Tcl.framework" ; then
36+
pgac_test_dirs="$pgac_test_dirs $PG_SYSROOT/System/Library/Frameworks/Tcl.framework"
37+
fi
38+
set X $pgac_test_dirs; shift
2839
fi
2940
3041
for pgac_dir do

configure

+18-2
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,7 @@ python_majorversion
668668
PYTHON
669669
perl_embed_ldflags
670670
perl_embed_ccflags
671+
perl_includedir
671672
perl_useshrplib
672673
perl_privlibexp
673674
perl_archlibexp
@@ -9773,6 +9774,14 @@ You might have to rebuild your Perl installation. Refer to the
97739774
documentation for details. Use --without-perl to disable building
97749775
PL/Perl." "$LINENO" 5
97759776
fi
9777+
# On most platforms, archlibexp is also where the Perl include files live ...
9778+
perl_includedir="$perl_archlibexp"
9779+
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
9780+
if test x"$PG_SYSROOT" != x"" ; then
9781+
if test -d "$PG_SYSROOT$perl_archlibexp" ; then
9782+
perl_includedir="$PG_SYSROOT$perl_archlibexp"
9783+
fi
9784+
fi
97769785

97779786
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CFLAGS recommended by Perl" >&5
97789787
$as_echo_n "checking for CFLAGS recommended by Perl... " >&6; }
@@ -18306,7 +18315,14 @@ if test -z "$TCL_CONFIG_SH"; then
1830618315
set X $pgac_test_dirs; shift
1830718316
if test $# -eq 0; then
1830818317
test -z "$TCLSH" && as_fn_error $? "unable to locate tclConfig.sh because no Tcl shell was found" "$LINENO" 5
18309-
set X `echo 'puts $auto_path' | $TCLSH`; shift
18318+
pgac_test_dirs=`echo 'puts $auto_path' | $TCLSH`
18319+
# On newer macOS, $auto_path frequently doesn't include the place
18320+
# where tclConfig.sh actually lives. Append that to the end, so as not
18321+
# to break cases where a non-default Tcl installation is being used.
18322+
if test -d "$PG_SYSROOT/System/Library/Frameworks/Tcl.framework" ; then
18323+
pgac_test_dirs="$pgac_test_dirs $PG_SYSROOT/System/Library/Frameworks/Tcl.framework"
18324+
fi
18325+
set X $pgac_test_dirs; shift
1831018326
fi
1831118327

1831218328
for pgac_dir do
@@ -18355,7 +18371,7 @@ fi
1835518371
# check for <perl.h>
1835618372
if test "$with_perl" = yes; then
1835718373
ac_save_CPPFLAGS=$CPPFLAGS
18358-
CPPFLAGS="$CPPFLAGS -I$perl_archlibexp/CORE"
18374+
CPPFLAGS="$CPPFLAGS -I$perl_includedir/CORE"
1835918375
ac_fn_c_check_header_compile "$LINENO" "perl.h" "ac_cv_header_perl_h" "#include <EXTERN.h>
1836018376
"
1836118377
if test "x$ac_cv_header_perl_h" = xyes; then :

configure.in

+10-1
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,15 @@ You might have to rebuild your Perl installation. Refer to the
10441044
documentation for details. Use --without-perl to disable building
10451045
PL/Perl.])
10461046
fi
1047+
# On most platforms, archlibexp is also where the Perl include files live ...
1048+
perl_includedir="$perl_archlibexp"
1049+
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
1050+
if test x"$PG_SYSROOT" != x"" ; then
1051+
if test -d "$PG_SYSROOT$perl_archlibexp" ; then
1052+
perl_includedir="$PG_SYSROOT$perl_archlibexp"
1053+
fi
1054+
fi
1055+
AC_SUBST(perl_includedir)dnl
10471056
PGAC_CHECK_PERL_EMBED_CCFLAGS
10481057
PGAC_CHECK_PERL_EMBED_LDFLAGS
10491058
fi
@@ -2229,7 +2238,7 @@ fi
22292238
# check for <perl.h>
22302239
if test "$with_perl" = yes; then
22312240
ac_save_CPPFLAGS=$CPPFLAGS
2232-
CPPFLAGS="$CPPFLAGS -I$perl_archlibexp/CORE"
2241+
CPPFLAGS="$CPPFLAGS -I$perl_includedir/CORE"
22332242
AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file <perl.h> is required for Perl])],
22342243
[#include <EXTERN.h>])
22352244
# While we're at it, check that we can link to libperl.

contrib/hstore_plperl/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ endif
3939
# last, probably because it sometimes contains some header files with names
4040
# that clash with some of ours, or with some that we include, notably on
4141
# Windows.
42-
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_archlibexp)/CORE
42+
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE

contrib/jsonb_plperl/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ endif
3939
# last, probably because it sometimes contains some header files with names
4040
# that clash with some of ours, or with some that we include, notably on
4141
# Windows.
42-
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_archlibexp)/CORE
42+
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE

src/Makefile.global.in

+1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ else
331331
endif
332332
perl_archlibexp = @perl_archlibexp@
333333
perl_privlibexp = @perl_privlibexp@
334+
perl_includedir = @perl_includedir@
334335
perl_embed_ccflags = @perl_embed_ccflags@
335336
perl_embed_ldflags = @perl_embed_ldflags@
336337

src/pl/plperl/GNUmakefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ endif
1616
# probably because it sometimes contains some header files with names
1717
# that clash with some of ours, or with some that we include, notably on
1818
# Windows.
19-
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_archlibexp)/CORE
19+
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE
2020

2121
rpathdir = $(perl_archlibexp)/CORE
2222

src/template/darwin

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
# Note: Darwin is the original code name for macOS, also known as OS X.
44
# We still use "darwin" as the port name, partly because config.guess does.
55

6+
# Select where system include files should be sought.
7+
if test x"$PG_SYSROOT" = x"" ; then
8+
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`
9+
fi
10+
if test x"$PG_SYSROOT" != x"" ; then
11+
if test -d "$PG_SYSROOT" ; then
12+
CPPFLAGS="$CPPFLAGS -isysroot $PG_SYSROOT"
13+
else
14+
PG_SYSROOT=""
15+
fi
16+
fi
17+
618
# Select appropriate semaphore support. Darwin 6.0 (macOS 10.2) and up
719
# support System V semaphores; before that we have to use named POSIX
820
# semaphores, which are less good for our purposes because they eat a

0 commit comments

Comments
 (0)