Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd445b41

Browse files
author
Neil Conway
committed
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 forexample, if one executable requires `libreadline', all executables arelinked against it.The easiest fix is to make use of GNU ld's --as-needed flag, whichignores linker arguments that are not actually needed by the specifiedobject files. The attached patch modifies configure to check for thisflag (when using GNU ld), and if ld supports it, adds the flag toLDFLAGS (we need to do the check since only relatively recent versionsof GNU ld support this capability). Currently only GNU ld is supported;I'm not aware of any other linkers that support this functionality.
1 parentdb70a31 commitd445b41

File tree

2 files changed

+94
-9
lines changed

2 files changed

+94
-9
lines changed

‎configure

Lines changed: 68 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3622,11 +3622,6 @@ rm -f conftest*
36223622
CPPFLAGS="$CPPFLAGS $INCLUDES"
36233623
LDFLAGS="$LDFLAGS $LIBDIRS"
36243624

3625-
{ echo "$as_me:$LINENO: using CPPFLAGS=$CPPFLAGS" >&5
3626-
echo "$as_me: using CPPFLAGS=$CPPFLAGS" >&6;}
3627-
{ echo "$as_me:$LINENO: using LDFLAGS=$LDFLAGS" >&5
3628-
echo "$as_me: using LDFLAGS=$LDFLAGS" >&6;}
3629-
36303625

36313626

36323627
for ac_prog in gawk mawk nawk awk
@@ -3856,6 +3851,7 @@ with_gnu_ld=$ac_cv_prog_gnu_ld
38563851

38573852

38583853

3854+
38593855
case $host_os in sysv5*)
38603856
echo "$as_me:$LINENO: checking whether ld -R works" >&5
38613857
echo $ECHO_N "checking whether ld -R works... $ECHO_C" >&6
@@ -3909,6 +3905,68 @@ echo "${ECHO_T}$pgac_cv_prog_ld_R" >&6
39093905
ld_R_works=$pgac_cv_prog_ld_R
39103906

39113907
esac
3908+
3909+
# To simplify the build system, we specify the maximal set of
3910+
# libraries to link against when building any executable. The linker
3911+
# on some platforms optionally allows unused link arguments to be
3912+
# elided from the resulting executable, so enable that capability if
3913+
# it exists.
3914+
# XXX: currently we only support GNU ld; do any other linkers support
3915+
# an equivalent feature?
3916+
if test "$with_gnu_ld"; then
3917+
echo "$as_me:$LINENO: checking whether ld --as-needed works" >&5
3918+
echo $ECHO_N "checking whether ld --as-needed works... $ECHO_C" >&6
3919+
if test "${pgac_cv_prog_ld_as_needed+set}" = set; then
3920+
echo $ECHO_N "(cached) $ECHO_C" >&6
3921+
else
3922+
3923+
pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,--as-needed"
3924+
cat >conftest.$ac_ext <<_ACEOF
3925+
#line $LINENO "configure"
3926+
#include "confdefs.h"
3927+
3928+
#ifdef F77_DUMMY_MAIN
3929+
# ifdef __cplusplus
3930+
extern "C"
3931+
# endif
3932+
int F77_DUMMY_MAIN() { return 1; }
3933+
#endif
3934+
int
3935+
main ()
3936+
{
3937+
3938+
;
3939+
return 0;
3940+
}
3941+
_ACEOF
3942+
rm -f conftest.$ac_objext conftest$ac_exeext
3943+
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
3944+
(eval $ac_link) 2>&5
3945+
ac_status=$?
3946+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
3947+
(exit $ac_status); } &&
3948+
{ ac_try='test -s conftest$ac_exeext'
3949+
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
3950+
(eval $ac_try) 2>&5
3951+
ac_status=$?
3952+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
3953+
(exit $ac_status); }; }; then
3954+
pgac_cv_prog_ld_as_needed=yes
3955+
else
3956+
echo "$as_me: failed program was:" >&5
3957+
cat conftest.$ac_ext >&5
3958+
pgac_cv_prog_ld_as_needed=no
3959+
fi
3960+
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
3961+
if test x"$pgac_cv_prog_ld_as_needed" = x"no"; then
3962+
LDFLAGS=$pgac_save_LDFLAGS
3963+
fi
3964+
3965+
fi
3966+
echo "$as_me:$LINENO: result: $pgac_cv_prog_ld_as_needed" >&5
3967+
echo "${ECHO_T}$pgac_cv_prog_ld_as_needed" >&6
3968+
fi
3969+
39123970
if test -n "$ac_tool_prefix"; then
39133971
# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
39143972
set dummy ${ac_tool_prefix}ranlib; ac_word=$2
@@ -4167,6 +4225,11 @@ echo "${ECHO_T}no" >&6
41674225

41684226

41694227

4228+
{ echo "$as_me:$LINENO: using CPPFLAGS=$CPPFLAGS" >&5
4229+
echo "$as_me: using CPPFLAGS=$CPPFLAGS" >&6;}
4230+
{ echo "$as_me:$LINENO: using LDFLAGS=$LDFLAGS" >&5
4231+
echo "$as_me: using LDFLAGS=$LDFLAGS" >&6;}
4232+
41704233
for ac_prog in 'bison -y'
41714234
do
41724235
# Extract the first word of "$ac_prog", so it can be a program name with args.

‎configure.in

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dnl Process this file with autoconf to produce a configure script.
2-
dnl $PostgreSQL: pgsql/configure.in,v 1.407 2005/03/25 00:34:19 tgl Exp $
2+
dnl $PostgreSQL: pgsql/configure.in,v 1.408 2005/05/05 11:50:18 neilc Exp $
33
dnl
44
dnl Developers, please strive to achieve this order:
55
dnl
@@ -539,9 +539,6 @@ AC_SUBST(ELF_SYS)
539539
CPPFLAGS="$CPPFLAGS $INCLUDES"
540540
LDFLAGS="$LDFLAGS $LIBDIRS"
541541

542-
AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
543-
AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
544-
545542
AC_ARG_VAR(LDFLAGS_SL)
546543

547544
AC_PROG_AWK
@@ -550,6 +547,7 @@ AC_PROG_LN_S
550547
PGAC_PROG_LD
551548
AC_SUBST(LD)
552549
AC_SUBST(with_gnu_ld)
550+
553551
case $host_os in sysv5*)
554552
AC_CACHE_CHECK([whether ld -R works], [pgac_cv_prog_ld_R],
555553
[
@@ -560,11 +558,35 @@ case $host_os in sysv5*)
560558
ld_R_works=$pgac_cv_prog_ld_R
561559
AC_SUBST(ld_R_works)
562560
esac
561+
562+
# To simplify the build system, we specify the maximal set of
563+
# libraries to link against when building any executable. The linker
564+
# on some platforms optionally allows unused link arguments to be
565+
# elided from the resulting executable, so enable that capability if
566+
# it exists.
567+
# XXX: currently we only support GNU ld; do any other linkers support
568+
# an equivalent feature?
569+
if test "$with_gnu_ld"; then
570+
AC_CACHE_CHECK([whether ld --as-needed works], [pgac_cv_prog_ld_as_needed],
571+
[
572+
pgac_save_LDFLAGS=$LDFLAGS; LDFLAGS="$LDFLAGS -Wl,--as-needed"
573+
AC_TRY_LINK([], [],
574+
[pgac_cv_prog_ld_as_needed=yes],
575+
[pgac_cv_prog_ld_as_needed=no])
576+
if test x"$pgac_cv_prog_ld_as_needed" = x"no"; then
577+
LDFLAGS=$pgac_save_LDFLAGS
578+
fi
579+
])
580+
fi
581+
563582
AC_PROG_RANLIB
564583
AC_CHECK_PROGS(LORDER, lorder)
565584
AC_PATH_PROG(TAR, tar)
566585
PGAC_CHECK_STRIP
567586

587+
AC_MSG_NOTICE([using CPPFLAGS=$CPPFLAGS])
588+
AC_MSG_NOTICE([using LDFLAGS=$LDFLAGS])
589+
568590
AC_CHECK_PROGS(YACC, ['bison -y'])
569591

570592
if test "$YACC"; then

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp