diff options
| author | Neil Conway <neilc@samurai.com> | 2005-05-05 11:50:18 +0000 |
|---|---|---|
| committer | Neil Conway <neilc@samurai.com> | 2005-05-05 11:50:18 +0000 |
| commit | d445b413c6e2a7afeb77b9e30a1c9241edb1af53 (patch) | |
| tree | 1732f8a59ce708be311ca8e2f927d9c012a9df27 /configure.in | |
| parent | db70a312941d7e20d9fff6bbe7d6e9ccf59294e0 (diff) | |
| download | postgresql-d445b413c6e2a7afeb77b9e30a1c9241edb1af53.tar.gz | |
The issue has been raised in the past that our build system links each
executable against the maximal set of libraries it might need. So for
example, if one executable requires `libreadline', all executables are
linked against it.
The easiest fix is to make use of GNU ld's --as-needed flag, which
ignores linker arguments that are not actually needed by the specified
object files. The attached patch modifies configure to check for this
flag (when using GNU ld), and if ld supports it, adds the flag to
LDFLAGS (we need to do the check since only relatively recent versions
of GNU ld support this capability). Currently only GNU ld is supported;
I'm not aware of any other linkers that support this functionality.
Diffstat (limited to 'configure.in')
| -rw-r--r-- | configure.in | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/configure.in b/configure.in index d8da7cd4ff..39ed00a1ab 100644 --- a/configure.in +++ b/configure.in @@ -1,5 +1,5 @@ dnl Process this file with autoconf to produce a configure script. -dnl $PostgreSQL: pgsql/configure.in,v 1.407 2005/03/25 00:34:19 tgl Exp $ +dnl $PostgreSQL: pgsql/configure.in,v 1.408 2005/05/05 11:50:18 neilc Exp $ dnl dnl Developers, please strive to achieve this order: dnl @@ -539,9 +539,6 @@ AC_SUBST(ELF_SYS) CPPFLAGS="$CPPFLAGS $INCLUDES" LDFLAGS="$LDFLAGS $LIBDIRS" -AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS]) -AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS]) - AC_ARG_VAR(LDFLAGS_SL) AC_PROG_AWK @@ -550,6 +547,7 @@ AC_PROG_LN_S PGAC_PROG_LD AC_SUBST(LD) AC_SUBST(with_gnu_ld) + case $host_os in sysv5*) AC_CACHE_CHECK([whether ld -R works], [pgac_cv_prog_ld_R], [ @@ -560,11 +558,35 @@ case $host_os in sysv5*) ld_R_works=$pgac_cv_prog_ld_R AC_SUBST(ld_R_works) esac + +# To simplify the build system, we specify the maximal set of +# libraries to link against when building any executable. The linker +# on some platforms optionally allows unused link arguments to be +# elided from the resulting executable, so enable that capability if +# it exists. +# XXX: currently we only support GNU ld; do any other linkers support +# an equivalent feature? +if test "$with_gnu_ld"; then + AC_CACHE_CHECK([whether ld --as-needed works], [pgac_cv_prog_ld_as_needed], + [ + pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,--as-needed" + AC_TRY_LINK([], [], + [pgac_cv_prog_ld_as_needed=yes], + [pgac_cv_prog_ld_as_needed=no]) + if test x"$pgac_cv_prog_ld_as_needed" = x"no"; then + LDFLAGS=$pgac_save_LDFLAGS + fi + ]) +fi + AC_PROG_RANLIB AC_CHECK_PROGS(LORDER, lorder) AC_PATH_PROG(TAR, tar) PGAC_CHECK_STRIP +AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS]) +AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS]) + AC_CHECK_PROGS(YACC, ['bison -y']) if test "$YACC"; then |
