autoconf: Move export_dynamic determination to configure

Previously export_dynamic was set in src/makefiles/Makefile.$port. For solaris
this required exporting with_gnu_ld. The determination of with_gnu_ld would be
nontrivial to copy for meson PGXS compatibility.  It's also nice to delete
libtool.m4.

This uses -Wl,--export-dynamic on all platforms, previously all platforms but
FreeBSD used -Wl,-E. The likelihood of a name conflict seems lower with the
longer spelling.

Discussion: https://postgr.es/m/20221005200710.luvw5evhwf6clig6@awork3.anarazel.de
This commit is contained in:
Andres Freund 2022-12-06 18:55:28 -08:00
parent 8018ffbf58
commit 9db49fc5bf
12 changed files with 108 additions and 276 deletions

1
aclocal.m4 vendored
View File

@ -4,7 +4,6 @@ m4_include([config/c-compiler.m4])
m4_include([config/c-library.m4]) m4_include([config/c-library.m4])
m4_include([config/check_decls.m4]) m4_include([config/check_decls.m4])
m4_include([config/general.m4]) m4_include([config/general.m4])
m4_include([config/libtool.m4])
m4_include([config/llvm.m4]) m4_include([config/llvm.m4])
m4_include([config/perl.m4]) m4_include([config/perl.m4])
m4_include([config/pkg.m4]) m4_include([config/pkg.m4])

View File

@ -468,29 +468,38 @@ AC_DEFUN([PGAC_PROG_CXX_CFLAGS_OPT],
# PGAC_PROG_CC_LDFLAGS_OPT # PGAC_PROG_CC_LD_VARFLAGS_OPT
# ------------------------ # ------------------------
# Given a string, check if the compiler supports the string as a # Given a string, check if the compiler supports the string as a
# command-line option. If it does, add the string to LDFLAGS. # command-line option. If it does, add to the given variable.
# For reasons you'd really rather not know about, this checks whether # For reasons you'd really rather not know about, this checks whether
# you can link to a particular function, not just whether you can link. # you can link to a particular function, not just whether you can link.
# In fact, we must actually check that the resulting program runs :-( # In fact, we must actually check that the resulting program runs :-(
AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT], AC_DEFUN([PGAC_PROG_CC_LD_VARFLAGS_OPT],
[define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_ldflags_$1])])dnl [define([Ac_cachevar], [AS_TR_SH([pgac_cv_prog_cc_$1_$2])])dnl
AC_CACHE_CHECK([whether $CC supports $1], [Ac_cachevar], AC_CACHE_CHECK([whether $CC supports $2, for $1], [Ac_cachevar],
[pgac_save_LDFLAGS=$LDFLAGS [pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS $1" LDFLAGS="$pgac_save_LDFLAGS $2"
AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void $2 (); void (*fptr) () = $2;],[])], AC_RUN_IFELSE([AC_LANG_PROGRAM([extern void $3 (); void (*fptr) () = $3;],[])],
[Ac_cachevar=yes], [Ac_cachevar=yes],
[Ac_cachevar=no], [Ac_cachevar=no],
[Ac_cachevar="assuming no"]) [Ac_cachevar="assuming no"])
LDFLAGS="$pgac_save_LDFLAGS"]) LDFLAGS="$pgac_save_LDFLAGS"])
if test x"$Ac_cachevar" = x"yes"; then if test x"$Ac_cachevar" = x"yes"; then
LDFLAGS="$LDFLAGS $1" $1="${$1} $2"
fi fi
undefine([Ac_cachevar])dnl undefine([Ac_cachevar])dnl
])# PGAC_PROG_CC_LD_VARFLAGS_OPT
# PGAC_PROG_CC_LDFLAGS_OPT
# ------------------------
# Convenience wrapper around PGAC_PROG_CC_LD_VARFLAGS_OPT that adds to
# LDFLAGS.
AC_DEFUN([PGAC_PROG_CC_LDFLAGS_OPT],
[PGAC_PROG_CC_LD_VARFLAGS_OPT(LDFLAGS, [$1], [$2])
])# PGAC_PROG_CC_LDFLAGS_OPT ])# PGAC_PROG_CC_LDFLAGS_OPT
# PGAC_HAVE_GCC__SYNC_CHAR_TAS # PGAC_HAVE_GCC__SYNC_CHAR_TAS
# ---------------------------- # ----------------------------
# Check if the C compiler understands __sync_lock_test_and_set(char), # Check if the C compiler understands __sync_lock_test_and_set(char),

119
config/libtool.m4 vendored
View File

@ -1,119 +0,0 @@
## libtool.m4 - Configure libtool for the host system. -*-Shell-script-*-
## Copyright (C) 1996-1999,2000 Free Software Foundation, Inc.
## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
##
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
##
## As a special exception to the GNU General Public License, if you
## distribute this file as part of a program that contains a
## configuration script generated by Autoconf, you may include it under
## the same distribution terms that you use for the rest of that program.
# No, PostgreSQL doesn't use libtool (yet), we just borrow stuff from it.
# This file was taken on 2000-10-20 from the multi-language branch (since
# that is the branch that PostgreSQL would most likely adopt anyway).
# --petere
# ... bunch of stuff removed here ...
# PGAC_PROG_LD - find the path to the GNU or non-GNU linker
AC_DEFUN([PGAC_PROG_LD],
[AC_ARG_WITH(gnu-ld,
[ --with-gnu-ld assume the C compiler uses GNU ld [[default=no]]],
test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AC_CANONICAL_HOST])dnl
dnl ###not for PostgreSQL### AC_REQUIRE([AC_CANONICAL_BUILD])dnl
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
AC_MSG_CHECKING([for ld used by GCC])
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case "$ac_prog" in
# Accept absolute paths.
changequote(,)dnl
[\\/]* | [A-Za-z]:[\\/]*)
re_direlt='/[^/][^/]*/\.\./'
changequote([,])dnl
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
AC_MSG_CHECKING([for GNU ld])
else
AC_MSG_CHECKING([for non-GNU ld])
fi
AC_CACHE_VAL(ac_cv_path_LD,
[if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH; do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
ac_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
test "$with_gnu_ld" != no && break
else
test "$with_gnu_ld" != yes && break
fi
fi
done
IFS="$ac_save_ifs"
else
ac_cv_path_LD="$LD" # Let the user override the test with a path.
fi])
LD="$ac_cv_path_LD"
if test -n "$LD"; then
AC_MSG_RESULT($LD)
else
AC_MSG_RESULT(no)
fi
test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
PGAC_PROG_LD_GNU
])
AC_DEFUN([PGAC_PROG_LD_GNU],
[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
ac_cv_prog_gnu_ld=yes
else
ac_cv_prog_gnu_ld=no
fi])
with_gnu_ld=$ac_cv_prog_gnu_ld
])
# ... more stuff removed ...

209
configure vendored
View File

@ -629,6 +629,7 @@ ac_subst_vars='LTLIBOBJS
vpath_build vpath_build
PG_SYSROOT PG_SYSROOT
PG_VERSION_NUM PG_VERSION_NUM
LDFLAGS_EX_BE
PROVE PROVE
DBTOEPUB DBTOEPUB
FOP FOP
@ -692,7 +693,6 @@ AR
STRIP_SHARED_LIB STRIP_SHARED_LIB
STRIP_STATIC_LIB STRIP_STATIC_LIB
STRIP STRIP
with_gnu_ld
LDFLAGS_SL LDFLAGS_SL
LDFLAGS_EX LDFLAGS_EX
ZSTD_LIBS ZSTD_LIBS
@ -871,7 +871,6 @@ with_system_tzdata
with_zlib with_zlib
with_lz4 with_lz4
with_zstd with_zstd
with_gnu_ld
with_ssl with_ssl
with_openssl with_openssl
enable_largefile enable_largefile
@ -1582,7 +1581,6 @@ Optional Packages:
--without-zlib do not use Zlib --without-zlib do not use Zlib
--with-lz4 build with LZ4 support --with-lz4 build with LZ4 support
--with-zstd build with ZSTD support --with-zstd build with ZSTD support
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-ssl=LIB use LIB for SSL/TLS support (openssl) --with-ssl=LIB use LIB for SSL/TLS support (openssl)
--with-openssl obsolete spelling of --with-ssl=openssl --with-openssl obsolete spelling of --with-ssl=openssl
@ -9545,105 +9543,6 @@ LDFLAGS="$LDFLAGS $LIBDIRS"
# Check whether --with-gnu-ld was given.
if test "${with_gnu_ld+set}" = set; then :
withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
else
with_gnu_ld=no
fi
ac_prog=ld
if test "$GCC" = yes; then
# Check if gcc -print-prog-name=ld gives a path.
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
$as_echo_n "checking for ld used by GCC... " >&6; }
case $host in
*-*-mingw*)
# gcc leaves a trailing carriage return which upsets mingw
ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
*)
ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
esac
case "$ac_prog" in
# Accept absolute paths.
[\\/]* | [A-Za-z]:[\\/]*)
re_direlt='/[^/][^/]*/\.\./'
# Canonicalize the path of ld
ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
done
test -z "$LD" && LD="$ac_prog"
;;
"")
# If it fails, then pretend we aren't using GCC.
ac_prog=ld
;;
*)
# If it is relative, then search for the first ld in PATH.
with_gnu_ld=unknown
;;
esac
elif test "$with_gnu_ld" = yes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
$as_echo_n "checking for GNU ld... " >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
$as_echo_n "checking for non-GNU ld... " >&6; }
fi
if ${ac_cv_path_LD+:} false; then :
$as_echo_n "(cached) " >&6
else
if test -z "$LD"; then
IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
for ac_dir in $PATH; do
test -z "$ac_dir" && ac_dir=.
if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
ac_cv_path_LD="$ac_dir/$ac_prog"
# Check to see if the program is GNU ld. I'd rather use --version,
# but apparently some GNU ld's only accept -v.
# Break only if it was the GNU/non-GNU ld that we prefer.
if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
test "$with_gnu_ld" != no && break
else
test "$with_gnu_ld" != yes && break
fi
fi
done
IFS="$ac_save_ifs"
else
ac_cv_path_LD="$LD" # Let the user override the test with a path.
fi
fi
LD="$ac_cv_path_LD"
if test -n "$LD"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
$as_echo "$LD" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
if ${ac_cv_prog_gnu_ld+:} false; then :
$as_echo_n "(cached) " >&6
else
# I'd rather use --version here, but apparently some GNU ld's only accept -v.
if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
ac_cv_prog_gnu_ld=yes
else
ac_cv_prog_gnu_ld=no
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gnu_ld" >&5
$as_echo "$ac_cv_prog_gnu_ld" >&6; }
with_gnu_ld=$ac_cv_prog_gnu_ld
if test -n "$ac_tool_prefix"; then if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
set dummy ${ac_tool_prefix}strip; ac_word=$2 set dummy ${ac_tool_prefix}strip; ac_word=$2
@ -19213,15 +19112,15 @@ else
fi fi
if test "$PORTNAME" = "darwin"; then if test "$PORTNAME" = "darwin"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-dead_strip_dylibs" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-dead_strip_dylibs, for LDFLAGS" >&5
$as_echo_n "checking whether $CC supports -Wl,-dead_strip_dylibs... " >&6; } $as_echo_n "checking whether $CC supports -Wl,-dead_strip_dylibs, for LDFLAGS... " >&6; }
if ${pgac_cv_prog_cc_ldflags__Wl__dead_strip_dylibs+:} false; then : if ${pgac_cv_prog_cc_LDFLAGS__Wl__dead_strip_dylibs+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
pgac_save_LDFLAGS=$LDFLAGS pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,-dead_strip_dylibs" LDFLAGS="$pgac_save_LDFLAGS -Wl,-dead_strip_dylibs"
if test "$cross_compiling" = yes; then : if test "$cross_compiling" = yes; then :
pgac_cv_prog_cc_ldflags__Wl__dead_strip_dylibs="assuming no" pgac_cv_prog_cc_LDFLAGS__Wl__dead_strip_dylibs="assuming no"
else else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -19235,9 +19134,9 @@ main ()
} }
_ACEOF _ACEOF
if ac_fn_c_try_run "$LINENO"; then : if ac_fn_c_try_run "$LINENO"; then :
pgac_cv_prog_cc_ldflags__Wl__dead_strip_dylibs=yes pgac_cv_prog_cc_LDFLAGS__Wl__dead_strip_dylibs=yes
else else
pgac_cv_prog_cc_ldflags__Wl__dead_strip_dylibs=no pgac_cv_prog_cc_LDFLAGS__Wl__dead_strip_dylibs=no
fi fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext conftest.$ac_objext conftest.beam conftest.$ac_ext
@ -19245,22 +19144,23 @@ fi
LDFLAGS="$pgac_save_LDFLAGS" LDFLAGS="$pgac_save_LDFLAGS"
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_ldflags__Wl__dead_strip_dylibs" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_LDFLAGS__Wl__dead_strip_dylibs" >&5
$as_echo "$pgac_cv_prog_cc_ldflags__Wl__dead_strip_dylibs" >&6; } $as_echo "$pgac_cv_prog_cc_LDFLAGS__Wl__dead_strip_dylibs" >&6; }
if test x"$pgac_cv_prog_cc_ldflags__Wl__dead_strip_dylibs" = x"yes"; then if test x"$pgac_cv_prog_cc_LDFLAGS__Wl__dead_strip_dylibs" = x"yes"; then
LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs" LDFLAGS="${LDFLAGS} -Wl,-dead_strip_dylibs"
fi fi
elif test "$PORTNAME" = "openbsd"; then elif test "$PORTNAME" = "openbsd"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-Bdynamic" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-Bdynamic, for LDFLAGS" >&5
$as_echo_n "checking whether $CC supports -Wl,-Bdynamic... " >&6; } $as_echo_n "checking whether $CC supports -Wl,-Bdynamic, for LDFLAGS... " >&6; }
if ${pgac_cv_prog_cc_ldflags__Wl__Bdynamic+:} false; then : if ${pgac_cv_prog_cc_LDFLAGS__Wl__Bdynamic+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
pgac_save_LDFLAGS=$LDFLAGS pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,-Bdynamic" LDFLAGS="$pgac_save_LDFLAGS -Wl,-Bdynamic"
if test "$cross_compiling" = yes; then : if test "$cross_compiling" = yes; then :
pgac_cv_prog_cc_ldflags__Wl__Bdynamic="assuming no" pgac_cv_prog_cc_LDFLAGS__Wl__Bdynamic="assuming no"
else else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -19274,9 +19174,9 @@ main ()
} }
_ACEOF _ACEOF
if ac_fn_c_try_run "$LINENO"; then : if ac_fn_c_try_run "$LINENO"; then :
pgac_cv_prog_cc_ldflags__Wl__Bdynamic=yes pgac_cv_prog_cc_LDFLAGS__Wl__Bdynamic=yes
else else
pgac_cv_prog_cc_ldflags__Wl__Bdynamic=no pgac_cv_prog_cc_LDFLAGS__Wl__Bdynamic=no
fi fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext conftest.$ac_objext conftest.beam conftest.$ac_ext
@ -19284,22 +19184,23 @@ fi
LDFLAGS="$pgac_save_LDFLAGS" LDFLAGS="$pgac_save_LDFLAGS"
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_ldflags__Wl__Bdynamic" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_LDFLAGS__Wl__Bdynamic" >&5
$as_echo "$pgac_cv_prog_cc_ldflags__Wl__Bdynamic" >&6; } $as_echo "$pgac_cv_prog_cc_LDFLAGS__Wl__Bdynamic" >&6; }
if test x"$pgac_cv_prog_cc_ldflags__Wl__Bdynamic" = x"yes"; then if test x"$pgac_cv_prog_cc_LDFLAGS__Wl__Bdynamic" = x"yes"; then
LDFLAGS="$LDFLAGS -Wl,-Bdynamic" LDFLAGS="${LDFLAGS} -Wl,-Bdynamic"
fi fi
else else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--as-needed" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--as-needed, for LDFLAGS" >&5
$as_echo_n "checking whether $CC supports -Wl,--as-needed... " >&6; } $as_echo_n "checking whether $CC supports -Wl,--as-needed, for LDFLAGS... " >&6; }
if ${pgac_cv_prog_cc_ldflags__Wl___as_needed+:} false; then : if ${pgac_cv_prog_cc_LDFLAGS__Wl___as_needed+:} false; then :
$as_echo_n "(cached) " >&6 $as_echo_n "(cached) " >&6
else else
pgac_save_LDFLAGS=$LDFLAGS pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,--as-needed" LDFLAGS="$pgac_save_LDFLAGS -Wl,--as-needed"
if test "$cross_compiling" = yes; then : if test "$cross_compiling" = yes; then :
pgac_cv_prog_cc_ldflags__Wl___as_needed="assuming no" pgac_cv_prog_cc_LDFLAGS__Wl___as_needed="assuming no"
else else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */ /* end confdefs.h. */
@ -19313,9 +19214,9 @@ main ()
} }
_ACEOF _ACEOF
if ac_fn_c_try_run "$LINENO"; then : if ac_fn_c_try_run "$LINENO"; then :
pgac_cv_prog_cc_ldflags__Wl___as_needed=yes pgac_cv_prog_cc_LDFLAGS__Wl___as_needed=yes
else else
pgac_cv_prog_cc_ldflags__Wl___as_needed=no pgac_cv_prog_cc_LDFLAGS__Wl___as_needed=no
fi fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext conftest.$ac_objext conftest.beam conftest.$ac_ext
@ -19323,14 +19224,58 @@ fi
LDFLAGS="$pgac_save_LDFLAGS" LDFLAGS="$pgac_save_LDFLAGS"
fi fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_ldflags__Wl___as_needed" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_LDFLAGS__Wl___as_needed" >&5
$as_echo "$pgac_cv_prog_cc_ldflags__Wl___as_needed" >&6; } $as_echo "$pgac_cv_prog_cc_LDFLAGS__Wl___as_needed" >&6; }
if test x"$pgac_cv_prog_cc_ldflags__Wl___as_needed" = x"yes"; then if test x"$pgac_cv_prog_cc_LDFLAGS__Wl___as_needed" = x"yes"; then
LDFLAGS="$LDFLAGS -Wl,--as-needed" LDFLAGS="${LDFLAGS} -Wl,--as-needed"
fi fi
fi fi
# For linkers that understand --export-dynamic, add that to the LDFLAGS_EX_BE
# (backend specific ldflags). One some platforms this will always fail (e.g.,
# windows), but on others it depends on the choice of linker (e.g., solaris).
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,--export-dynamic, for LDFLAGS_EX_BE" >&5
$as_echo_n "checking whether $CC supports -Wl,--export-dynamic, for LDFLAGS_EX_BE... " >&6; }
if ${pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic+:} false; then :
$as_echo_n "(cached) " >&6
else
pgac_save_LDFLAGS=$LDFLAGS
LDFLAGS="$pgac_save_LDFLAGS -Wl,--export-dynamic"
if test "$cross_compiling" = yes; then :
pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic="assuming no"
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
extern void $link_test_func (); void (*fptr) () = $link_test_func;
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic=yes
else
pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic=no
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
LDFLAGS="$pgac_save_LDFLAGS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic" >&5
$as_echo "$pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic" >&6; }
if test x"$pgac_cv_prog_cc_LDFLAGS_EX_BE__Wl___export_dynamic" = x"yes"; then
LDFLAGS_EX_BE="${LDFLAGS_EX_BE} -Wl,--export-dynamic"
fi
# Create compiler version string # Create compiler version string
if test x"$GCC" = x"yes" ; then if test x"$GCC" = x"yes" ; then
cc_string=`${CC} --version | sed q` cc_string=`${CC} --version | sed q`

View File

@ -1131,8 +1131,6 @@ LDFLAGS="$LDFLAGS $LIBDIRS"
AC_ARG_VAR(LDFLAGS_EX, [extra linker flags for linking executables only]) AC_ARG_VAR(LDFLAGS_EX, [extra linker flags for linking executables only])
AC_ARG_VAR(LDFLAGS_SL, [extra linker flags for linking shared libraries only]) AC_ARG_VAR(LDFLAGS_SL, [extra linker flags for linking shared libraries only])
PGAC_PROG_LD
AC_SUBST(with_gnu_ld)
PGAC_CHECK_STRIP PGAC_CHECK_STRIP
AC_CHECK_TOOL(AR, ar, ar) AC_CHECK_TOOL(AR, ar, ar)
if test "$PORTNAME" = "win32"; then if test "$PORTNAME" = "win32"; then
@ -2372,6 +2370,12 @@ else
PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed], $link_test_func) PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed], $link_test_func)
fi fi
# For linkers that understand --export-dynamic, add that to the LDFLAGS_EX_BE
# (backend specific ldflags). One some platforms this will always fail (e.g.,
# windows), but on others it depends on the choice of linker (e.g., solaris).
PGAC_PROG_CC_LD_VARFLAGS_OPT(LDFLAGS_EX_BE, [-Wl,--export-dynamic], $link_test_func)
AC_SUBST(LDFLAGS_EX_BE)
# Create compiler version string # Create compiler version string
if test x"$GCC" = x"yes" ; then if test x"$GCC" = x"yes" ; then
cc_string=`${CC} --version | sed q` cc_string=`${CC} --version | sed q`

View File

@ -289,7 +289,6 @@ LDAP_LIBS_FE = @LDAP_LIBS_FE@
LDAP_LIBS_BE = @LDAP_LIBS_BE@ LDAP_LIBS_BE = @LDAP_LIBS_BE@
UUID_LIBS = @UUID_LIBS@ UUID_LIBS = @UUID_LIBS@
LLVM_LIBS=@LLVM_LIBS@ LLVM_LIBS=@LLVM_LIBS@
with_gnu_ld = @with_gnu_ld@
# It's critical that within LDFLAGS, all -L switches pointing to build-tree # It's critical that within LDFLAGS, all -L switches pointing to build-tree
# directories come before any -L switches pointing to external directories. # directories come before any -L switches pointing to external directories.
@ -313,6 +312,7 @@ endif
LDFLAGS = $(LDFLAGS_INTERNAL) @LDFLAGS@ LDFLAGS = $(LDFLAGS_INTERNAL) @LDFLAGS@
LDFLAGS_EX = @LDFLAGS_EX@ LDFLAGS_EX = @LDFLAGS_EX@
LDFLAGS_EX_BE = @LDFLAGS_EX_BE@
# LDFLAGS_SL might have already been assigned by calling makefile # LDFLAGS_SL might have already been assigned by calling makefile
LDFLAGS_SL += @LDFLAGS_SL@ LDFLAGS_SL += @LDFLAGS_SL@
WINDRES = @WINDRES@ WINDRES = @WINDRES@

View File

@ -55,6 +55,8 @@ ifeq ($(with_systemd),yes)
LIBS += -lsystemd LIBS += -lsystemd
endif endif
override LDFLAGS := $(LDFLAGS) $(LDFLAGS_EX) $(LDFLAGS_EX_BE)
########################################################################## ##########################################################################
all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP) all: submake-libpgport submake-catalog-headers submake-utils-headers postgres $(POSTGRES_IMP)
@ -64,7 +66,7 @@ ifneq ($(PORTNAME), win32)
ifneq ($(PORTNAME), aix) ifneq ($(PORTNAME), aix)
postgres: $(OBJS) postgres: $(OBJS)
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(LIBS) -o $@ $(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o $@
endif endif
endif endif
@ -73,7 +75,7 @@ endif
ifeq ($(PORTNAME), cygwin) ifeq ($(PORTNAME), cygwin)
postgres: $(OBJS) postgres: $(OBJS)
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) -Wl,--stack,$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(LIBS) -o $@ $(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) -Wl,--stack,$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(LIBS) -o $@
# libpostgres.a is actually built in the preceding rule, but we need this to # libpostgres.a is actually built in the preceding rule, but we need this to
# ensure it's newer than postgres; see notes in src/backend/parser/Makefile # ensure it's newer than postgres; see notes in src/backend/parser/Makefile
@ -86,7 +88,7 @@ ifeq ($(PORTNAME), win32)
LIBS += -lsecur32 LIBS += -lsecur32
postgres: $(OBJS) $(WIN32RES) postgres: $(OBJS) $(WIN32RES)
$(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LDFLAGS) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(LIBS) -o $@$(X)
# libpostgres.a is actually built in the preceding rule, but we need this to # libpostgres.a is actually built in the preceding rule, but we need this to
# ensure it's newer than postgres; see notes in src/backend/parser/Makefile # ensure it's newer than postgres; see notes in src/backend/parser/Makefile
@ -98,7 +100,7 @@ endif # win32
ifeq ($(PORTNAME), aix) ifeq ($(PORTNAME), aix)
postgres: $(POSTGRES_IMP) postgres: $(POSTGRES_IMP)
$(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) $(LDFLAGS_EX) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -Wl,-brtllib -o $@ $(CC) $(CFLAGS) $(call expand_subsys,$(OBJS)) $(LDFLAGS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -Wl,-brtllib -o $@
# Linking to a single .o with -r is a lot faster than building a .a or passing # Linking to a single .o with -r is a lot faster than building a .a or passing
# all objects to MKLDEXPORT. # all objects to MKLDEXPORT.
@ -320,4 +322,4 @@ maintainer-clean: distclean
# are up to date. It saves the time of doing all the submakes. # are up to date. It saves the time of doing all the submakes.
.PHONY: quick .PHONY: quick
quick: $(OBJS) quick: $(OBJS)
$(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LDFLAGS_EX) $(export_dynamic) $(LIBS) -o postgres $(CC) $(CFLAGS) $(call expand_subsys,$^) $(LDFLAGS) $(LIBS) -o postgres

View File

@ -1,4 +1,3 @@
export_dynamic = -Wl,-export-dynamic
rpath = -Wl,-R'$(rpathdir)' rpath = -Wl,-R'$(rpathdir)'
# extra stuff for $(with_temp_install) # extra stuff for $(with_temp_install)

View File

@ -1,4 +1,3 @@
export_dynamic = -Wl,-E
# Use --enable-new-dtags to generate DT_RUNPATH instead of DT_RPATH. # Use --enable-new-dtags to generate DT_RUNPATH instead of DT_RPATH.
# This allows LD_LIBRARY_PATH to still work when needed. # This allows LD_LIBRARY_PATH to still work when needed.
rpath = -Wl,-rpath,'$(rpathdir)',--enable-new-dtags rpath = -Wl,-rpath,'$(rpathdir)',--enable-new-dtags

View File

@ -1,4 +1,3 @@
export_dynamic = -Wl,-E
rpath = -Wl,-R'$(rpathdir)' rpath = -Wl,-R'$(rpathdir)'

View File

@ -1,4 +1,3 @@
export_dynamic = -Wl,-E
rpath = -Wl,-R'$(rpathdir)' rpath = -Wl,-R'$(rpathdir)'

View File

@ -1,10 +1,6 @@
# src/makefiles/Makefile.solaris # src/makefiles/Makefile.solaris
rpath = -Wl,-rpath,'$(rpathdir)' rpath = -Wl,-rpath,'$(rpathdir)'
ifeq ($(with_gnu_ld), yes)
export_dynamic = -Wl,-E
endif
# Rule for building a shared library from a single .o file # Rule for building a shared library from a single .o file
%.so: %.o %.so: %.o
$(CC) $(CFLAGS) $< $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@ $(CC) $(CFLAGS) $< $(LDFLAGS) $(LDFLAGS_SL) -shared -o $@