Commit e74dd00f authored by Tom Lane's avatar Tom Lane

Still further rethinking of build changes for macOS Mojave.

To avoid the sorts of problems complained of by Jakob Egger, it'd be
best if configure didn't emit any references to the sysroot path at all.
In the case of PL/Tcl, we can do that just by keeping our hands off the
TCL_INCLUDE_SPEC string altogether.  In the case of PL/Perl, we need to
substitute -iwithsysroot for -I in the compile commands, which is easily
handled if we change to using a configure output variable that includes
the switch not only the directory name.  Since PL/Tcl and PL/Python
already do it like that, this seems like good consistency cleanup anyway.

Hence, this replaces the advice given to Perl-related extensions in commit
5e221713; instead of writing "-I$(perl_archlibexp)/CORE", they should
just write "$(perl_includespec)".  (The old way continues to work, but not
on recent macOS.)

It's still the case that configure needs to be aware of the sysroot
path internally, but that's cleaner than what we had before.

As before, back-patch to all supported versions.

Discussion: https://postgr.es/m/20840.1537850987@sss.pgh.pa.us
parent 26cb8203
...@@ -668,7 +668,7 @@ python_majorversion ...@@ -668,7 +668,7 @@ python_majorversion
PYTHON PYTHON
perl_embed_ldflags perl_embed_ldflags
perl_embed_ccflags perl_embed_ccflags
perl_includedir perl_includespec
perl_useshrplib perl_useshrplib
perl_privlibexp perl_privlibexp
perl_archlibexp perl_archlibexp
...@@ -9775,11 +9775,12 @@ documentation for details. Use --without-perl to disable building ...@@ -9775,11 +9775,12 @@ 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 ... # On most platforms, archlibexp is also where the Perl include files live ...
perl_includedir="$perl_archlibexp" perl_includespec="-I$perl_archlibexp/CORE"
# ... but on some macOS versions, we must look under $PG_SYSROOT instead # ... but on newer macOS versions, we must use -iwithsysroot to look
if test x"$PG_SYSROOT" != x"" ; then # under $PG_SYSROOT
if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
perl_includedir="$PG_SYSROOT$perl_archlibexp" perl_includespec="-iwithsysroot $perl_archlibexp/CORE"
fi fi
fi fi
...@@ -18114,11 +18115,6 @@ eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUILD\" ...@@ -18114,11 +18115,6 @@ eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUILD\"
as_fn_error $? "cannot build PL/Tcl because Tcl is not a shared library as_fn_error $? "cannot build PL/Tcl because Tcl is not a shared library
Use --without-tcl to disable building PL/Tcl." "$LINENO" 5 Use --without-tcl to disable building PL/Tcl." "$LINENO" 5
fi fi
# Some macOS versions report an include spec that uses -iwithsysroot.
# We don't really want to use -isysroot, so translate that if we can.
if test x"$PG_SYSROOT" != x"" ; then
TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`"
fi
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h> # now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
ac_save_CPPFLAGS=$CPPFLAGS ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS" CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
...@@ -18136,7 +18132,7 @@ fi ...@@ -18136,7 +18132,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_includedir/CORE" CPPFLAGS="$CPPFLAGS $perl_includespec"
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 :
......
...@@ -1045,14 +1045,15 @@ documentation for details. Use --without-perl to disable building ...@@ -1045,14 +1045,15 @@ 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 ... # On most platforms, archlibexp is also where the Perl include files live ...
perl_includedir="$perl_archlibexp" perl_includespec="-I$perl_archlibexp/CORE"
# ... but on some macOS versions, we must look under $PG_SYSROOT instead # ... but on newer macOS versions, we must use -iwithsysroot to look
if test x"$PG_SYSROOT" != x"" ; then # under $PG_SYSROOT
if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
perl_includedir="$PG_SYSROOT$perl_archlibexp" perl_includespec="-iwithsysroot $perl_archlibexp/CORE"
fi fi
fi fi
AC_SUBST(perl_includedir)dnl AC_SUBST(perl_includespec)dnl
PGAC_CHECK_PERL_EMBED_CCFLAGS PGAC_CHECK_PERL_EMBED_CCFLAGS
PGAC_CHECK_PERL_EMBED_LDFLAGS PGAC_CHECK_PERL_EMBED_LDFLAGS
fi fi
...@@ -2211,11 +2212,6 @@ if test "$with_tcl" = yes; then ...@@ -2211,11 +2212,6 @@ if test "$with_tcl" = yes; then
AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library
Use --without-tcl to disable building PL/Tcl.]) Use --without-tcl to disable building PL/Tcl.])
fi fi
# Some macOS versions report an include spec that uses -iwithsysroot.
# We don't really want to use -isysroot, so translate that if we can.
if test x"$PG_SYSROOT" != x"" ; then
TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`"
fi
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h> # now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
ac_save_CPPFLAGS=$CPPFLAGS ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS" CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
...@@ -2226,7 +2222,7 @@ fi ...@@ -2226,7 +2222,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_includedir/CORE" CPPFLAGS="$CPPFLAGS $perl_includespec"
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.
......
...@@ -35,8 +35,5 @@ rpathdir = $(perl_archlibexp)/CORE ...@@ -35,8 +35,5 @@ rpathdir = $(perl_archlibexp)/CORE
SHLIB_LINK += $(perl_embed_ldflags) SHLIB_LINK += $(perl_embed_ldflags)
endif endif
# As with plperl we need to make sure that the CORE directory is included # As with plperl we need to include the perl_includespec directory last.
# last, probably because it sometimes contains some header files with names override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) $(perl_includespec)
# that clash with some of ours, or with some that we include, notably on
# Windows.
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE
...@@ -35,8 +35,5 @@ rpathdir = $(perl_archlibexp)/CORE ...@@ -35,8 +35,5 @@ rpathdir = $(perl_archlibexp)/CORE
SHLIB_LINK += $(perl_embed_ldflags) SHLIB_LINK += $(perl_embed_ldflags)
endif endif
# As with plperl we need to make sure that the CORE directory is included # As with plperl we need to include the perl_includespec directory last.
# last, probably because it sometimes contains some header files with names override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) $(perl_includespec)
# that clash with some of ours, or with some that we include, notably on
# Windows.
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE
...@@ -331,7 +331,7 @@ else ...@@ -331,7 +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_includespec = @perl_includespec@
perl_embed_ccflags = @perl_embed_ccflags@ perl_embed_ccflags = @perl_embed_ccflags@
perl_embed_ldflags = @perl_embed_ldflags@ perl_embed_ldflags = @perl_embed_ldflags@
......
...@@ -12,12 +12,13 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID ...@@ -12,12 +12,13 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID
override CPPFLAGS += -Wno-comment override CPPFLAGS += -Wno-comment
endif endif
# Note: we need to make sure that the CORE directory is included last, # Note: we need to include the perl_includespec directory last,
# 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_includedir)/CORE override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) $(perl_includespec)
# this is often, but not always, the same directory named by perl_includespec
rpathdir = $(perl_archlibexp)/CORE rpathdir = $(perl_archlibexp)/CORE
PGFILEDESC = "PL/Perl - procedural language" PGFILEDESC = "PL/Perl - procedural language"
......
...@@ -3,9 +3,8 @@ ...@@ -3,9 +3,8 @@
# 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 some include files should be sought. # Some configure tests require explicit knowledge of where the Xcode "sysroot"
# We may eventually be forced to use "-isysroot" with this value, # is. We try to avoid having this leak into configure's results, though.
# but for now, it only affects Perl and Tcl include files.
if test x"$PG_SYSROOT" = x"" ; then if test x"$PG_SYSROOT" = x"" ; then
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null` PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`
fi fi
......
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