From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Daniel Gustafsson <daniel@yesql.se>
Cc: Jakob Egger <jakob@eggerapps.at>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: PG vs macOS Mojave
Date: Thu, 01 Nov 2018 18:13:37 -0400
Message-ID: <8453.1541110417@sss.pgh.pa.us> (raw)
In-Reply-To: <8164.1541110113@sss.pgh.pa.us>
References: <20840.1537850987@sss.pgh.pa.us>
<DF261D4E-DFB6-4474-9B35-7BBEC93AD959@eggerapps.at>
<29535.1539698523@sss.pgh.pa.us>
<486.1539702831@sss.pgh.pa.us>
<5BE313A1-1318-4A68-A183-5F60CA968CF1@eggerapps.at>
<30776.1539786526@sss.pgh.pa.us>
<687EAD19-E8F0-464C-9F2B-BE536B81985E@eggerapps.at>
<2429.1539842651@sss.pgh.pa.us>
<25039.1539874646@sss.pgh.pa.us>
<11941.1541042255@sss.pgh.pa.us>
<529860F6-243F-4B6F-B6D6-4376291D1593@yesql.se>
<6712.1541081675@sss.pgh.pa.us>
<F53307F8-1D9A-4E1D-865D-A27B99EC1BBF@yesql.se>
<8198.1541083983@sss.pgh.pa.us>
<371F44FD-BCD0-4DD2-A261-346809E3CEE7@yesql.se>
<4844.1541107036@sss.pgh.pa.us>
<a623ee37-eae8-298c-f43f-f81a182d1548@2ndquadrant.com>
<8164.1541110113@sss.pgh.pa.us>
I wrote:
> Peter Eisentraut <peter.eisentraut@2ndquadrant.com> writes:
>> On 01/11/2018 22:17, Tom Lane wrote:
>>> The other idea that's occurred to me is to go back to the scheme of
>>> commit 68fc227dd, where we inject the sysroot path into just the -I
>>> switches used for PL/Perl and PL/Tcl. We could improve on that
>>> commit by injecting it symbolically similar to what I did here, ie
>>> what ends up in the configure output is
>> How does that work when building against a non-system Perl or Tcl?
> It does nothing, because configure will not find that it needs to
> inject any sysroot reference in order to find such a Perl or Tcl's
> headers.
Here's a lightly-tested patch for that approach.
regards, tom lane
Attachments:other-way-to-fix-mojave-build.patch (text/x-diff, 8.3K) downloaddiff --git a/configure b/configureindex 43ae8c8..db50751 100755
*** a/configure
--- b/configure
*************** CPP
*** 731,736 ****
--- 731,737 ----
BITCODE_CXXFLAGS
BITCODE_CFLAGS
CFLAGS_VECTOR
+ PG_SYSROOT
LLVM_BINPATH
LLVM_CXXFLAGS
LLVM_CFLAGS
*************** unset CXXFLAGS
*** 5261,5266 ****
--- 5262,5270 ----
#
. "$srcdir/src/template/$template" || exit
+ # Record PG_SYSROOT in Makefile.global, if set by user or template.+ +
# C[XX]FLAGS are selected so:
# If the user specifies something in the environment, that is used.
# else: If the template file set something, that is used.
*************** PL/Perl." "$LINENO" 5
*** 9776,9786 ****
fi
# On most platforms, archlibexp is also where the Perl include files live ...
perl_includespec="-I$perl_archlibexp/CORE"
! # ... but on newer macOS versions, we must use -iwithsysroot to look
! # under $PG_SYSROOT
if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
! perl_includespec="-iwithsysroot $perl_archlibexp/CORE"
fi
fi
--- 9780,9789 ----
fi
# On most platforms, archlibexp is also where the Perl include files live ...
perl_includespec="-I$perl_archlibexp/CORE"
! # ... but on newer macOS versions, we must look under $PG_SYSROOT instead
if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
! perl_includespec="-I$PG_SYSROOT$perl_archlibexp/CORE"
fi
fi
*************** eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUIL
*** 18115,18120 ****
--- 18118,18128 ----
as_fn_error $? "cannot build PL/Tcl because Tcl is not a shared library
Use --without-tcl to disable building PL/Tcl." "$LINENO" 5
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>
ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
*************** fi
*** 18127,18132 ****
--- 18135,18147 ----
CPPFLAGS=$ac_save_CPPFLAGS
+ # If we are inserting PG_SYSROOT into TCL_INCLUDE_SPEC, do so symbolically+ # not literally, so that it's possible to override it at build time using a+ # command like "make ... PG_SYSROOT=path". This has to be done after we've+ # finished all configure checks that depend on TCL_INCLUDE_SPEC.+ if test x"$PG_SYSROOT" != x; then+ TCL_INCLUDE_SPEC=`echo "$TCL_INCLUDE_SPEC" | sed -e "s|-I$PG_SYSROOT/|-I\\\$(PG_SYSROOT)/|"`+ fi
fi
# check for <perl.h>
*************** rm -f core conftest.err conftest.$ac_obj
*** 18176,18181 ****
--- 18191,18203 ----
conftest$ac_exeext conftest.$ac_ext
LIBS=$pgac_save_LIBS
CPPFLAGS=$ac_save_CPPFLAGS
+ # If we are inserting PG_SYSROOT into perl_includespec, do so symbolically+ # not literally, so that it's possible to override it at build time using a+ # command like "make ... PG_SYSROOT=path". This has to be done after we've+ # finished all configure checks that depend on perl_includespec.+ if test x"$PG_SYSROOT" != x; then+ perl_includespec=`echo "$perl_includespec" | sed -e "s|-I$PG_SYSROOT/|-I\\\$(PG_SYSROOT)/|"`+ fi
fi
# check for <Python.h>
diff --git a/configure.in b/configure.inindex 519ecd5..b895f7d 100644
*** a/configure.in
--- b/configure.in
*************** unset CXXFLAGS
*** 404,409 ****
--- 404,412 ----
#
. "$srcdir/src/template/$template" || exit
+ # Record PG_SYSROOT in Makefile.global, if set by user or template.+ AC_SUBST(PG_SYSROOT)+
# C[XX]FLAGS are selected so:
# If the user specifies something in the environment, that is used.
# else: If the template file set something, that is used.
*************** PL/Perl.])
*** 1046,1056 ****
fi
# On most platforms, archlibexp is also where the Perl include files live ...
perl_includespec="-I$perl_archlibexp/CORE"
! # ... but on newer macOS versions, we must use -iwithsysroot to look
! # under $PG_SYSROOT
if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
! perl_includespec="-iwithsysroot $perl_archlibexp/CORE"
fi
fi
AC_SUBST(perl_includespec)dnl
--- 1049,1058 ----
fi
# On most platforms, archlibexp is also where the Perl include files live ...
perl_includespec="-I$perl_archlibexp/CORE"
! # ... but on newer macOS versions, we must look under $PG_SYSROOT instead
if test \! -f "$perl_archlibexp/CORE/perl.h" ; then
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
! perl_includespec="-I$PG_SYSROOT$perl_archlibexp/CORE"
fi
fi
AC_SUBST(perl_includespec)dnl
*************** if test "$with_tcl" = yes; then
*** 2212,2222 ****
--- 2214,2236 ----
AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library
Use --without-tcl to disable building PL/Tcl.])
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>
ac_save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
AC_CHECK_HEADER(tcl.h, [], [AC_MSG_ERROR([header file <tcl.h> is required for Tcl])])
CPPFLAGS=$ac_save_CPPFLAGS
+ # If we are inserting PG_SYSROOT into TCL_INCLUDE_SPEC, do so symbolically+ # not literally, so that it's possible to override it at build time using a+ # command like "make ... PG_SYSROOT=path". This has to be done after we've+ # finished all configure checks that depend on TCL_INCLUDE_SPEC.+ if test x"$PG_SYSROOT" != x; then+ TCL_INCLUDE_SPEC=`echo "$TCL_INCLUDE_SPEC" | sed -e "s|-I$PG_SYSROOT/|-I\\\$(PG_SYSROOT)/|"`+ fi
fi
# check for <perl.h>
*************** if test "$with_perl" = yes; then
*** 2241,2246 ****
--- 2255,2267 ----
AC_MSG_ERROR([libperl library is required for Perl])])
LIBS=$pgac_save_LIBS
CPPFLAGS=$ac_save_CPPFLAGS
+ # If we are inserting PG_SYSROOT into perl_includespec, do so symbolically+ # not literally, so that it's possible to override it at build time using a+ # command like "make ... PG_SYSROOT=path". This has to be done after we've+ # finished all configure checks that depend on perl_includespec.+ if test x"$PG_SYSROOT" != x; then+ perl_includespec=`echo "$perl_includespec" | sed -e "s|-I$PG_SYSROOT/|-I\\\$(PG_SYSROOT)/|"`+ fi
fi
# check for <Python.h>
diff --git a/src/Makefile.global.in b/src/Makefile.global.inindex bdf394b..2f8c869 100644
*** a/src/Makefile.global.in
--- b/src/Makefile.global.in
*************** host_tuple = @host@
*** 496,501 ****
--- 496,504 ----
host_os = @host_os@
host_cpu = @host_cpu@
+ # On macOS, we may need to find include files here+ PG_SYSROOT = @PG_SYSROOT@+
# Make HAVE_IPV6 available for initdb script creation
HAVE_IPV6= @HAVE_IPV6@
diff --git a/src/template/darwin b/src/template/darwinindex 159d8bb..7022733 100644
*** a/src/template/darwin
--- b/src/template/darwin
***************
*** 3,10 ****
# 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.
! # Some configure tests require explicit knowledge of where the Xcode "sysroot"
! # is. We try to avoid having this leak into configure's results, though.
if test x"$PG_SYSROOT" = x"" ; then
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`
fi
--- 3,11 ----
# 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.
! # Select where some include files should be sought.
! # We may eventually be forced to use "-isysroot" with this value,
! # but for now, it only affects Perl and Tcl include files.
if test x"$PG_SYSROOT" = x"" ; then
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`
fi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, peter.eisentraut@2ndquadrant.com, daniel@yesql.se, jakob@eggerapps.at, pgsql-hackers@lists.postgresql.org
Subject: Re: PG vs macOS Mojave
In-Reply-To: <8453.1541110417@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox