Article View: gnu.gcc.bug
Article #2876-nostdlib seems to inhibit gnulib linking
From: jimb
Date: Wed, 21 Feb 1990 08:15
Date: Wed, 21 Feb 1990 08:15
93 lines
3988 bytes
3988 bytes
I believe there is a bug regarding the -nostdlib option in gcc version
1.36. The documentation for this option:
`-nostdlib'
Don't use the standard system libraries and startup files when
linking. Only the files you specify (plus `gnulib') will be
passed to the linker.
I read this to mean that gcc links with gnulib whether -nostdlib is
specified or not. However, gcc does not seem to include gnulib when
the -nostdlib option is given. An annotated transcript, on a Sun 3/60
running SunOS Release 4.0:
betty% ls -l tm.h md
lrwxrwxrwx 1 gnusoft 16 Feb 20 23:09 md -> ./config/m68k.md
lrwxrwxrwx 1 gnusoft 18 Feb 20 23:09 tm.h -> ./config/tm-sun3.h
betty%
These are the linkages for md and tm.h.
betty% cat foo.c
main(int x)
{
return (x-1)/x;
}
betty%
This is a sample program that exacerbates the bug. Note that these
ints are 32 bits, so this will require 32-bit division.
betty% ./gcc -v -m68000 -nostdlib -e _main foo.c -o foo
gcc version 1.36
/usr/users/software/gnusoft/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68010 foo.c /usr/tmp/cca12192.cpp
GNU CPP version 1.36
/usr/users/software/gnusoft/lib/gcc-cc1 /usr/tmp/cca12192.cpp -quiet -dumpbase foo.c -m68000 -version -o /usr/tmp/cca12192.s
GNU C version 1.36 (68k, MIT syntax) compiled by GNU C version 1.36.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
as -mc68010 -o foo.o /usr/tmp/cca12192.s
ld -o foo -dc -dp -e _main foo.o
Undefined:
___divsi3
betty%
I am using GCC to compile for a 68010. When compiled with the -m68000
flag, gcc generates a call to the gnulib division function, but
doesn't seem to link with gnulib.
betty% ./gcc -v -m68000 -e _main foo.c -o foo
gcc version 1.36
/usr/users/software/gnusoft/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68010 foo.c /usr/tmp/cca12197.cpp
GNU CPP version 1.36
/usr/users/software/gnusoft/lib/gcc-cc1 /usr/tmp/cca12197.cpp -quiet -dumpbase foo.c -m68000 -version -o /usr/tmp/cca12197.s
GNU C version 1.36 (68k, MIT syntax) compiled by GNU C version 1.36.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
as -mc68010 -o foo.o /usr/tmp/cca12197.s
ld -o foo -dc -dp -e _main /lib/crt0.o /lib/Mcrt1.o foo.o /usr/users/software/gnusoft/lib/gcc-gnulib -lc
betty%
Without the -nostdlib option, things compile fine, so it *is* finding
gnulib normally.
betty% gcc -v -m68000 -nostdlib -e _main foo.c ~gnusoft/lib/gcc-gnulib -o foo
gcc version 1.36
/usr/users/software/gnusoft/lib/gcc-cpp -v -undef -D__GNUC__ -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68010 foo.c /usr/tmp/cca12202.cpp
GNU CPP version 1.36
/usr/users/software/gnusoft/lib/gcc-cc1 /usr/tmp/cca12202.cpp -quiet -dumpbase foo.c -m68000 -version -o /usr/tmp/cca12202.s
GNU C version 1.36 (68k, MIT syntax) compiled by GNU C version 1.36.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
as -mc68010 -o foo.o /usr/tmp/cca12202.s
ld -o foo -dc -dp -e _main foo.o /usr/users/software/gnusoft/lib/gcc-gnulib
betty% ls ~gnusoft/lib
bison.hairy dump.h gcc-cpp* gcc-include/
bison.simple gcc-cc1* gcc-gnulib* window.h
betty%
When one explicitly specifies gnulib with -nostdlib, things work fine.
It seems to me that this is a case of gcc not performing as
documented.
Otherwise, GCC is a pleasure to use.
Jim Blandy - jimb@occs.cs.oberlin.edu
Technical Details
Message-ID:
<9002210815.AA16258@occs.cs.oberlin.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!occs.cs.oberlin.edu!jimbShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!occs.cs.oberlin.edu!jimb From: jimb@occs.cs.oberlin.edu Newsgroups: gnu.gcc.bug Subject: -nostdlib seems to inhibit gnulib linking Message-ID: <9002210815.AA16258@occs.cs.oberlin.edu> Date: 21 Feb 90 08:15:35 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 93