This is the mail archive of the
cygwin-developers@cygwin.com
mailing list for the Cygwin project.
Bug "ld: final link failed: File truncated" on libm.a isolated to single commit
- From: "Max Bowsher" <maxb at ukf dot net>
- To: <cygwin-developers at cygwin dot com>
- Date: Mon, 18 Aug 2003 19:37:13 +0100
- Subject: Bug "ld: final link failed: File truncated" on libm.a isolated to single commit
By lots of "cvs up -D", I've isolated the bug to the commit shown below, and
confirmed that the bug disappeares from HEAD when the commit is reverted.
Max.
Index: ChangeLog
===================================================================
RCS file: /home/max/cvsmirror/src-cvs/src/winsup/cygwin/ChangeLog,v
retrieving revision 1.1985
retrieving revision 1.1986
diff -u -p -r1.1985 -r1.1986
--- ChangeLog 5 Aug 2003 04:49:43 -0000 1.1985
+++ ChangeLog 6 Aug 2003 01:40:11 -0000 1.1986
@@ -1,3 +1,9 @@
+2003-08-05 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in: Rework to accommodate new speclib arguments.
+ * speclib: Rework to extract everything from libcygwin.a rather than
+ building things from existing object files.
+
2003-08-05 Pavel Tsekov <ptsekov@gmx.net>
* path.cc (cygdrive_getmntent): Do not skip over drives of type
Index: Makefile.in
===================================================================
RCS file: /home/max/cvsmirror/src-cvs/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -p -r1.130 -r1.131
--- Makefile.in 26 Jul 2003 00:08:25 -0000 1.130
+++ Makefile.in 6 Aug 2003 01:40:12 -0000 1.131
@@ -116,7 +116,6 @@ RUNTESTFLAGS =
DLL_NAME:=cygwin1.dll
TEST_DLL_NAME:=cygwin0.dll
-LIB_NAME:=libcygwin.a
TEST_LIB_NAME:=libcygwin0.a
DEF_FILE:=cygwin.def
DLL_ENTRY:=@DLL_ENTRY@
@@ -233,10 +232,11 @@ NEW_FUNCTIONS:=regcomp posix_regcomp \
API_VER:=$(srcdir)/include/cygwin/version.h
PWD:=${shell pwd}
-SUBLIBS:=libpthread.a $(PWD)/libm.a libc.a
+LIB_NAME:=$(PWD)/libcygwin.a
+SUBLIBS:=$(PWD)/libpthread.a $(PWD)/libm.a $(PWD)/libc.a
EXTRALIBS:=libautomode.a libbinmode.a libtextmode.a
INSTOBJS:=automode.o binmode.o textmode.o
-TARGET_LIBS:=$(LIB_NAME) $(SUBLIBS) $(CYGWIN_START) $(GMON_START)
$(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
+TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A)
$(SUBLIBS) $(INSTOBJS) $(EXTRALIBS)
.PHONY: all force dll_ofiles install all_target install_target all_host
install_host \
install install-libs install-headers -lgcc
@@ -376,14 +376,14 @@ dcrt0.o sigproc.o: child_info_magic.h
shared.o: shared_info_magic.h
-libpthread.a: speclib cygwin.def pthread.o thread.o
- /bin/sh ${word 1, $^} $@ "${NM}" "${DLLTOOL}" "${AS}" ${wordlist 2, 99,
$^}
+$(PWD)/libpthread.a: speclib $(LIB_NAME) pthread.o thread.o
+ /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
-$(PWD)/libm.a: speclib cygwin.def $(LIBM)
- /bin/sh ${word 1, $^} $@ "${NM}" "${DLLTOOL}" "${AS}" ${wordlist 2, 99,
$^}
+$(PWD)/libm.a: speclib $(LIB_NAME) $(LIBM)
+ /bin/sh ${word 1, $^} $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
-$(PWD)/libc.a: speclib cygwin.def $(PWD)/libm.a libpthread.a
- /bin/sh ${word 1, $^} -v $@ "${NM}" "${DLLTOOL}" "${AS}" ${wordlist 2, 99,
$^}
+$(PWD)/libc.a: speclib $(LIB_NAME) $(PWD)/libm.a libpthread.a
+ /bin/sh ${word 1, $^} -v $@ "${NM}" "$(AR)" ${wordlist 2, 99, $^}
lib%.a: %.o
$(AR) cru $@ $?
Index: crt0.c
===================================================================
RCS file: /home/max/cvsmirror/src-cvs/src/winsup/cygwin/crt0.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -p -r1.1 -r1.2
--- crt0.c 12 May 2003 11:06:25 -0000 1.1
+++ crt0.c 6 Aug 2003 01:40:12 -0000 1.2
@@ -30,6 +30,8 @@ int __cygwin_crt0_bp = 0;
extern int main (int argc, char **argv);
+void cygwin_crt0 (int (*main) (int, char **));
+
void
mainCRTStartup ()
{
Index: speclib
===================================================================
RCS file: /home/max/cvsmirror/src-cvs/src/winsup/cygwin/speclib,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -p -r1.7 -r1.8
--- speclib 24 Jan 2002 21:39:09 -0000 1.7
+++ speclib 6 Aug 2003 01:40:12 -0000 1.8
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh -x
# speclib - Make a special version of the cygwin import library.
#
# Copyright 2001, 2002 Red Hat, Inc.
@@ -10,14 +10,30 @@
# details.
case "$1" in
- -v) v="-v"; shift
+ -v) shift; v() { :; } ;;
+ *) v() { /bin/false; } ;;
esac
lib=$1; shift
nm=$1; shift
-dlltool=$1; shift
-as=$1; shift
-def=$1; shift
-trap "rm -f /tmp/$$.def" 0 1 2 15
-(echo "LIBRARY cygwin1.dll
-EXPORTS"; $nm --extern-only --defined-only $* | sed -e '/^[ ]*$/d' -e
'/:$/d' -e 's/^.* _\(.*\)/\1/' | grep $v -f - -w $def |egrep -vi
'^library|exports|^$' | sort) > /tmp/$$.def
-$dlltool --as=$as -d /tmp/$$.def -l "$lib"
+ar=$1; shift
+libdll=$1; shift
+cp /dev/null /tmp/$$.objs
+trap "/bin/rm -rf /tmp/$$.dir /tmp/$$.syms /tmp/$$.objs /tmp/$$.raw" 0 1 2
15
+$nm --extern-only --defined-only $* | sed -e '/^[ ]*$/d' -e '/:$/d' -e
's%^.* _\(.*\)%/ __imp__\1$/p%' | grep -v ' __imp___imp__' > /tmp/$$.syms
+v || $nm -Ap --extern-only --defined-only $libdll | egrep ' I __head| I
_.*_iname' | awk -F: '{print $2}' > /tmp/$$.objs
+$nm -Ap --extern-only --defined-only $libdll | sed -n -f /tmp/$$.syms |
awk -F: '{print $2}' >> /tmp/$$.objs
+sort -o /tmp/$$.objs -u /tmp/$$.objs
+
+[ -s /tmp/$$.objs ] || { echo "speclib: couldn't find symbols for $lib"
1>&2; exit 1; }
+
+/bin/rm -f /tmp/$$>dir
+mkdir /tmp/$$.dir
+cd /tmp/$$.dir
+if v; then
+ $ar x $libdll
+ /bin/rm -f `cat /tmp/$$.objs`
+else
+ $ar x $libdll `cat /tmp/$$.objs`
+fi
+/bin/rm -f $lib
+$ar crus $lib *.o