This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Fix LD test FAIL: bootstrap with --static on Cygwin
- From: Dave Korn <dave dot korn dot cygwin at googlemail dot com>
- To: binutils at sourceware dot org
- Date: Sat, 14 Mar 2009 04:29:23 +0000
- Subject: [PATCH] Fix LD test FAIL: bootstrap with --static on Cygwin
Hello again,
The ld boostrap --static test fails on Cygwin with:
Executing on host: sh -c {/gnu/binutils/obj1908-i686-pc-cygwin/ld/ld-new -m
i386pe -o tmpdir/ld1 /lib/crt0.o --static -liconv tmpdir/ld-partial.o
../bfd/.libs/libbfd.a ../libiberty/libiberty.a -lintl -lz --start-group
/usr/lib/gcc/i686-pc-cygwin/4.3.2/libgcc.a
/usr/lib/gcc/i686-pc-cygwin/4.3.2/libgcc_eh.a -lc --end-group -lcygwin
-L/usr/lib/w32api -luser32 -lkernel32 -ladvapi32 -lshell32
/usr/lib/gcc/i686-pc-cygwin/4.3.2/libgcc.a 2>&1} /dev/null ld.tmp (timeout = 300)
/usr/lib/libintl.a(dcigettext.o):dcigettext.c:(.text+0x744): undefined
reference to `libiconv'
/usr/lib/libintl.a(dcigettext.o):dcigettext.c:(.text+0x913): undefined
reference to `libiconv_open'
/usr/lib/libintl.a(dcigettext.o):dcigettext.c:(.text+0xaaa): undefined
reference to `libiconv_open'
/usr/lib/libintl.a(relocatable.o):relocatable.c:(.text+0x57): undefined
reference to `libiconv_set_relocation_prefix'
On Cygwin, statically linking against -lintl means you have to explicitly
add -liconv. (In dynamic linking, the libintl import lib contains import
sections for the functions it needs from the libiconv dll that resolve these
references. When static linking there are no such DLL import tables in the
library .a file so any dependencies must be explicitly added). The attached
patch does just that.
Tested natively on i686-pc-cygwin and i686-pc-linux-gnu with one fix and no
regressions. Ok for HEAD?
cheers,
DaveK
Index: ld/testsuite/ld-bootstrap/bootstrap.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-bootstrap/bootstrap.exp,v
retrieving revision 1.15
diff -p -u -r1.15 bootstrap.exp
--- ld/testsuite/ld-bootstrap/bootstrap.exp 6 Jul 2007 14:09:42 -0000 1.15
+++ ld/testsuite/ld-bootstrap/bootstrap.exp 14 Mar 2009 03:31:12 -0000
@@ -83,13 +83,21 @@ foreach flags {"" "strip" "--static" "--
}
}
+ # On Cygwin, -lintl may require -liconv when linking statically.
+ set extralibs ""
+ if { [istarget "*-*-cygwin*"]} {
+ if {"$flags" == "--static"} {
+ set extralibs "-liconv"
+ }
+ }
+
# On Irix 5, linking with --static only works if all the files are
# compiled using -non_shared.
if {"$flags" == "--static"} {
setup_xfail "mips*-*-irix5*"
}
- if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY"] {
+ if ![ld_link $ld tmpdir/ld1 "$flags tmpdir/ld-partial.o $BFDLIB $LIBIBERTY $extralibs"] {
fail $testname
continue
}
@@ -104,12 +112,12 @@ foreach flags {"" "strip" "--static" "--
}
}
- if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
+ if ![ld_link tmpdir/ld1 tmpdir/ld2 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
fail $testname
continue
}
- if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY"] {
+ if ![ld_link tmpdir/ld2 tmpdir/ld3 "$flags $OFILES $BFDLIB $LIBIBERTY $extralibs"] {
fail $testname
continue
}