This test case is about the spec `startfile_prefix_spec', tho' I suspect the
problem might actually be a generic specs problem, but am not sure.

Scenario:
Say you want to link executables with startfiles different from those in the
default location on your system. Sure, I can use -B, but there are times when
you want this hardwired into the compiler's specs, so this bug is about specs
handling.

To reproduce the problem, follow these steps:

1. Copy some startfiles to /tmp
     cp /usr/lib/{crt1.o,crti.o,crtn.o} /tmp

2. GCC-4 no longer installs a specs file so we'll create a temporary one:
     gcc -dumpspecs > /tmp/specs

3. Now edit /tmp/specs so that startfile_prefix_spec points at /tmp/

4. Compile a dummy binary with -v and note that it DOES NOT pick up our start
files in /tmp:

$ echo 'main(){}' | cc -x c -specs=/tmp/specs -v -
Using built-in specs.
Reading specs from /tmp/specs
Configured with: ../gcc-20050106T052249/configure --libexecdir=/usr/lib
--enable-shared --enable-languages=c,c++ --enable-clocale=gnu
--enable-threads=posix --enable-__cxa_atexit --disable-checking
Thread model: posix
gcc version 4.0.0 20050106 (experimental)
 /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/cc1 -quiet -v - -quiet -dumpbase -
-mtune=pentiumpro -auxbase - -version -o /tmp/ccsb8sUR.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/include
 /usr/include
End of search list.
GNU C version 4.0.0 20050106 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.0.0 20050106 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 as -V -Qy -o /tmp/ccQlh4py.o /tmp/ccsb8sUR.s
GNU assembler version 2.15.94.0.2 (i686-pc-linux-gnu) using BFD version
2.15.94.0.2 20041220
 /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../crt1.o
/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../crti.o
/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/crtbegin.o
-L/usr/lib/gcc/i686-pc-linux-gnu/4.0.0 -L/usr/lib/gcc/i686-pc-linux-gnu/4.0.0
-L/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/../../.. /tmp/ccQlh4py.o -lgcc
--as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/crtend.o
/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../crtn.o


5. This time we'll try again, with the difference being that we'll place a specs
file in GCC's default location:

gcc -dumpspecs > `gcc -print-search-dirs | head -n 1 | awk '{ print $2 }'`specs

6. Now edit this one as above ie: place /tmp/ into the startfile_prefix_spec

7. Again, compile a dummy binary with -v and note that this time it DOES pick up
our start files in /tmp:

$ echo 'main(){}' | cc -x c -v -
Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/specs
Configured with: ../gcc-20050106T052249/configure --libexecdir=/usr/lib
--enable-shared --enable-languages=c,c++ --enable-clocale=gnu
--enable-threads=posix --enable-__cxa_atexit --disable-checking
Thread model: posix
gcc version 4.0.0 20050106 (experimental)
 /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/cc1 -quiet -v - -quiet -dumpbase -
-mtune=pentiumpro -auxbase - -version -o /tmp/cchIqhHa.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/include
 /usr/include
End of search list.
GNU C version 4.0.0 20050106 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.0.0 20050106 (experimental).
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
 as -V -Qy -o /tmp/ccevdSNe.o /tmp/cchIqhHa.s
GNU assembler version 2.15.94.0.2 (i686-pc-linux-gnu) using BFD version
2.15.94.0.2 20041220
 /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/collect2 --eh-frame-hdr -m elf_i386
-dynamic-linker /lib/ld-linux.so.2 /tmp/crt1.o /tmp/crti.o
/usr/lib/gcc/i686-pc-linux-gnu/4.0.0/crtbegin.o
-L/usr/lib/gcc/i686-pc-linux-gnu/4.0.0 -L/usr/lib/gcc/i686-pc-linux-gnu/4.0.0
-L/tmp /tmp/ccevdSNe.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
--as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i686-pc-linux-gnu/4.0.0/crtend.o
/tmp/crtn.o


The bug is that startfile_prefix_spec is not being used when I specify another
specs file using -specs=/tmp/specs. I can modify other specs (eg:
dynamic_linker) using the above technique and it works fine.

I tried 3.4.3 and 4.0 and this bug is present in both.

Thankyou

-- 
           Summary: Faulty handling of startfile_prefix_spec
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: driver
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gschafer at zip dot com dot au
                CC: gcc-bugs at gcc dot gnu dot org
  GCC host triplet: i686-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19353

Reply via email to