Skip to content

Commit 34f9944

Browse files
committed
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 5e22171; 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
1 parent 5d91d78 commit 34f9944

File tree

6 files changed

+22
-33
lines changed

6 files changed

+22
-33
lines changed

configure

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ python_majorversion
669669
PYTHON
670670
perl_embed_ldflags
671671
perl_embed_ccflags
672-
perl_includedir
672+
perl_includespec
673673
perl_useshrplib
674674
perl_privlibexp
675675
perl_archlibexp
@@ -7973,11 +7973,12 @@ documentation for details. Use --without-perl to disable building
79737973
PL/Perl." "$LINENO" 5
79747974
fi
79757975
# On most platforms, archlibexp is also where the Perl include files live ...
7976-
perl_includedir="$perl_archlibexp"
7977-
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
7978-
if test x"$PG_SYSROOT" != x"" ; then
7976+
perl_includespec="-I$perl_archlibexp/CORE"
7977+
# ... but on newer macOS versions, we must use -iwithsysroot to look
7978+
# under $PG_SYSROOT
7979+
if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
79797980
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
7980-
perl_includedir="$PG_SYSROOT$perl_archlibexp"
7981+
perl_includespec="-iwithsysroot $perl_archlibexp/CORE"
79817982
fi
79827983
fi
79837984

@@ -16207,11 +16208,6 @@ eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUILD\"
1620716208
as_fn_error $? "cannot build PL/Tcl because Tcl is not a shared library
1620816209
Use --without-tcl to disable building PL/Tcl." "$LINENO" 5
1620916210
fi
16210-
# Some macOS versions report an include spec that uses -iwithsysroot.
16211-
# We don't really want to use -isysroot, so translate that if we can.
16212-
if test x"$PG_SYSROOT" != x"" ; then
16213-
TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`"
16214-
fi
1621516211
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
1621616212
ac_save_CPPFLAGS=$CPPFLAGS
1621716213
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
@@ -16229,7 +16225,7 @@ fi
1622916225
# check for <perl.h>
1623016226
if test "$with_perl" = yes; then
1623116227
ac_save_CPPFLAGS=$CPPFLAGS
16232-
CPPFLAGS="$CPPFLAGS -I$perl_includedir/CORE"
16228+
CPPFLAGS="$CPPFLAGS $perl_includespec"
1623316229
ac_fn_c_check_header_compile "$LINENO" "perl.h" "ac_cv_header_perl_h" "#include <EXTERN.h>
1623416230
"
1623516231
if test "x$ac_cv_header_perl_h" = xyes; then :

configure.in

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -969,14 +969,15 @@ documentation for details. Use --without-perl to disable building
969969
PL/Perl.])
970970
fi
971971
# On most platforms, archlibexp is also where the Perl include files live ...
972-
perl_includedir="$perl_archlibexp"
973-
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
974-
if test x"$PG_SYSROOT" != x"" ; then
972+
perl_includespec="-I$perl_archlibexp/CORE"
973+
# ... but on newer macOS versions, we must use -iwithsysroot to look
974+
# under $PG_SYSROOT
975+
if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
975976
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
976-
perl_includedir="$PG_SYSROOT$perl_archlibexp"
977+
perl_includespec="-iwithsysroot $perl_archlibexp/CORE"
977978
fi
978979
fi
979-
AC_SUBST(perl_includedir)dnl
980+
AC_SUBST(perl_includespec)dnl
980981
PGAC_CHECK_PERL_EMBED_CCFLAGS
981982
PGAC_CHECK_PERL_EMBED_LDFLAGS
982983
fi
@@ -2102,11 +2103,6 @@ if test "$with_tcl" = yes; then
21022103
AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library
21032104
Use --without-tcl to disable building PL/Tcl.])
21042105
fi
2105-
# Some macOS versions report an include spec that uses -iwithsysroot.
2106-
# We don't really want to use -isysroot, so translate that if we can.
2107-
if test x"$PG_SYSROOT" != x"" ; then
2108-
TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`"
2109-
fi
21102106
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
21112107
ac_save_CPPFLAGS=$CPPFLAGS
21122108
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
@@ -2117,7 +2113,7 @@ fi
21172113
# check for <perl.h>
21182114
if test "$with_perl" = yes; then
21192115
ac_save_CPPFLAGS=$CPPFLAGS
2120-
CPPFLAGS="$CPPFLAGS -I$perl_includedir/CORE"
2116+
CPPFLAGS="$CPPFLAGS $perl_includespec"
21212117
AC_CHECK_HEADER(perl.h, [], [AC_MSG_ERROR([header file <perl.h> is required for Perl])],
21222118
[#include <EXTERN.h>])
21232119
# While we're at it, check that we can link to libperl.

contrib/hstore_plperl/Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,5 @@ rpathdir = $(perl_archlibexp)/CORE
3434
SHLIB_LINK += $(perl_embed_ldflags)
3535
endif
3636

37-
# As with plperl we need to make sure that the CORE directory is included
38-
# last, probably because it sometimes contains some header files with names
39-
# that clash with some of ours, or with some that we include, notably on
40-
# Windows.
41-
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) -I$(perl_includedir)/CORE
37+
# As with plperl we need to include the perl_includespec directory last.
38+
override CPPFLAGS := $(CPPFLAGS) $(perl_embed_ccflags) $(perl_includespec)

src/Makefile.global.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ else
313313
endif
314314
perl_archlibexp = @perl_archlibexp@
315315
perl_privlibexp = @perl_privlibexp@
316-
perl_includedir = @perl_includedir@
316+
perl_includespec = @perl_includespec@
317317
perl_embed_ccflags = @perl_embed_ccflags@
318318
perl_embed_ldflags = @perl_embed_ldflags@
319319

src/pl/plperl/GNUmakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@ override CPPFLAGS += -DPLPERL_HAVE_UID_GID
1212
override CPPFLAGS += -Wno-comment
1313
endif
1414

15-
# Note: we need to make sure that the CORE directory is included last,
15+
# Note: we need to include the perl_includespec directory last,
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_includedir)/CORE
19+
override CPPFLAGS := -I. -I$(srcdir) $(CPPFLAGS) $(perl_embed_ccflags) $(perl_includespec)
2020

21+
# this is often, but not always, the same directory named by perl_includespec
2122
rpathdir = $(perl_archlibexp)/CORE
2223

2324
PGFILEDESC = "PL/Perl - procedural language"

src/template/darwin

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
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 some include files should be sought.
7-
# We may eventually be forced to use "-isysroot" with this value,
8-
# but for now, it only affects Perl and Tcl include files.
6+
# Some configure tests require explicit knowledge of where the Xcode "sysroot"
7+
# is. We try to avoid having this leak into configure's results, though.
98
if test x"$PG_SYSROOT" = x"" ; then
109
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`
1110
fi

0 commit comments

Comments
 (0)