From ae2370e7b83d82555471fee5bff28b184a6936c6 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Mon, 26 Sep 2022 15:39:40 -0700 Subject: [PATCH v2 4/5] solaris: Check for -Wl,-E directly instead of checking for gnu LD This allows us to get rid of the harder to support with_gnu_ld detection, simplifying meson PGXS compatibility. It's also nice to delete libtool.m4. Author: Reviewed-by: Discussion: https://postgr.es/m/ Backpatch: --- config/c-compiler.m4 | 16 ++++ config/libtool.m4 | 119 ---------------------------- src/makefiles/Makefile.solaris | 2 +- aclocal.m4 | 1 - configure | 140 +++++++++------------------------ configure.ac | 10 ++- src/Makefile.global.in | 2 +- 7 files changed, 64 insertions(+), 226 deletions(-) delete mode 100644 config/libtool.m4 diff --git a/config/c-compiler.m4 b/config/c-compiler.m4 index eb8cc8ce170..d798c385c44 100644 --- a/config/c-compiler.m4 +++ b/config/c-compiler.m4 @@ -491,6 +491,22 @@ fi undefine([Ac_cachevar])dnl ])# PGAC_PROG_CC_LDFLAGS_OPT + +# PGAC_PROG_CC_LD_EXPORT_DYNAMIC +# ------------------------ +# Checks if the compiler / linker supports -Wl,-E and set +# pgac_cv_prog_cc_ld_export_dynamic if so. +AC_DEFUN([PGAC_PROG_CC_LD_EXPORT_DYNAMIC], +[AC_CACHE_CHECK([whether $CC supports -Wl,-E], [pgac_cv_prog_cc_ld_export_dynamic], +[pgac_save_LDFLAGS=$LDFLAGS +LDFLAGS="$pgac_save_LDFLAGS -Wl,-E" +AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])], + [pgac_cv_prog_cc_ld_export_dynamic=yes], + [pgac_cv_prog_cc_ld_export_dynamic=no]) +LDFLAGS="$pgac_save_LDFLAGS"]) +])# PGAC_PROG_CC_LD_EXPORT_DYNAMIC + + # PGAC_HAVE_GCC__SYNC_CHAR_TAS # ---------------------------- # Check if the C compiler understands __sync_lock_test_and_set(char), diff --git a/config/libtool.m4 b/config/libtool.m4 deleted file mode 100644 index f6e426dbdf1..00000000000 --- a/config/libtool.m4 +++ /dev/null @@ -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 , 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 &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 ... diff --git a/src/makefiles/Makefile.solaris b/src/makefiles/Makefile.solaris index 3de73ebc010..ba8e57988a9 100644 --- a/src/makefiles/Makefile.solaris +++ b/src/makefiles/Makefile.solaris @@ -1,7 +1,7 @@ # src/makefiles/Makefile.solaris rpath = -Wl,-rpath,'$(rpathdir)' -ifeq ($(with_gnu_ld), yes) +ifeq ($(SOLARIS_EXPORT_DYNAMIC), yes) export_dynamic = -Wl,-E endif diff --git a/aclocal.m4 b/aclocal.m4 index 1c19c60c596..d05f8f9e3a8 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -4,7 +4,6 @@ m4_include([config/c-compiler.m4]) m4_include([config/c-library.m4]) m4_include([config/check_decls.m4]) m4_include([config/general.m4]) -m4_include([config/libtool.m4]) m4_include([config/llvm.m4]) m4_include([config/perl.m4]) m4_include([config/pkg.m4]) diff --git a/configure b/configure index 7eafefb062a..c8bf357e6f3 100755 --- a/configure +++ b/configure @@ -629,6 +629,7 @@ ac_subst_vars='LTLIBOBJS vpath_build PG_SYSROOT PG_VERSION_NUM +SOLARIS_EXPORT_DYNAMIC PROVE DBTOEPUB FOP @@ -691,7 +692,6 @@ AR STRIP_SHARED_LIB STRIP_STATIC_LIB STRIP -with_gnu_ld LDFLAGS_SL LDFLAGS_EX ZSTD_LIBS @@ -870,7 +870,6 @@ with_system_tzdata with_zlib with_lz4 with_zstd -with_gnu_ld with_ssl with_openssl enable_largefile @@ -1581,7 +1580,6 @@ Optional Packages: --without-zlib do not use Zlib --with-lz4 build with LZ4 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-openssl obsolete spelling of --with-ssl=openssl @@ -9364,105 +9362,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 &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 # 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 @@ -19096,6 +18995,43 @@ fi fi +# Check if linker on solaris supports -Wl,-E (gnu linker does, solaris linker +# doesn't). +if test "$PORTNAME" = "solaris"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-E" >&5 +$as_echo_n "checking whether $CC supports -Wl,-E... " >&6; } +if ${pgac_cv_prog_cc_ld_export_dynamic+:} false; then : + $as_echo_n "(cached) " >&6 +else + pgac_save_LDFLAGS=$LDFLAGS +LDFLAGS="$pgac_save_LDFLAGS -Wl,-E" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + pgac_cv_prog_cc_ld_export_dynamic=yes +else + pgac_cv_prog_cc_ld_export_dynamic=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LDFLAGS="$pgac_save_LDFLAGS" +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_cc_ld_export_dynamic" >&5 +$as_echo "$pgac_cv_prog_cc_ld_export_dynamic" >&6; } + + SOLARIS_EXPORT_DYNAMIC=$pgac_cv_prog_cc_ld_export_dynamic + +fi + # Create compiler version string if test x"$GCC" = x"yes" ; then cc_string=`${CC} --version | sed q` diff --git a/configure.ac b/configure.ac index 398eb422595..d87c9af77f8 100644 --- a/configure.ac +++ b/configure.ac @@ -1126,8 +1126,6 @@ LDFLAGS="$LDFLAGS $LIBDIRS" 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]) -PGAC_PROG_LD -AC_SUBST(with_gnu_ld) PGAC_CHECK_STRIP AC_CHECK_TOOL(AR, ar, ar) if test "$PORTNAME" = "win32"; then @@ -2366,6 +2364,14 @@ else PGAC_PROG_CC_LDFLAGS_OPT([-Wl,--as-needed], $link_test_func) fi +# Check if linker on solaris supports -Wl,-E (gnu linker does, solaris linker +# doesn't). +if test "$PORTNAME" = "solaris"; then + PGAC_PROG_CC_LD_EXPORT_DYNAMIC() + SOLARIS_EXPORT_DYNAMIC=$pgac_cv_prog_cc_ld_export_dynamic + AC_SUBST(SOLARIS_EXPORT_DYNAMIC) +fi + # Create compiler version string if test x"$GCC" = x"yes" ; then cc_string=`${CC} --version | sed q` diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 8107643578b..31294005235 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -289,7 +289,7 @@ LDAP_LIBS_FE = @LDAP_LIBS_FE@ LDAP_LIBS_BE = @LDAP_LIBS_BE@ UUID_LIBS = @UUID_LIBS@ LLVM_LIBS=@LLVM_LIBS@ -with_gnu_ld = @with_gnu_ld@ +SOLARIS_EXPORT_DYNAMIC=@SOLARIS_EXPORT_DYNAMIC@ # It's critical that within LDFLAGS, all -L switches pointing to build-tree # directories come before any -L switches pointing to external directories. -- 2.37.3.542.gdd3f6c4cae