18

When using gcc version 4.3.2, I see how to generate specs using:

$ /usr/local/gcc-4.3.2/bin/gcc -v
Using built-in specs

Now changing to the same directory as libgcc:

cd /usr/local/gcc-4.3.2/lib/gcc/x86_64-unknown-linux-gnu/4.3.2
/usr/local/gcc-4.3.2/bin/gcc -dumpspecs > specs

I have a populated specs file that I can modify. However, once that is done I still see that:

$ /usr/local/gcc-4.3.2/bin/gcc -v
Using built-in specs

How do I tell gcc to use that specs file by default rather than forcing me to pass a -specs parameter every compile? I would like it to match another system I have where I get the following:

$ /usr/local/gcc-4.3.2/bin/gcc -v
Reading specs from /usr/local/gcc-4.3.2/lib/gcc/i686-pc-linux-gnu/4.3.2/specs</code>

As you can see, the major difference between the two systems is that the existing setup is 32-bit and I am now trying to match that on a 64-bit system. The version of Linux is otherwise the same and I am compiling the same version of gcc. (With both systems gcc 4.3.2 is the second gcc installation, with 4.1.2 being used to compile 4.3.2)

Ciro Santilli OurBigBook.com
  • 347,512
  • 102
  • 1,199
  • 985
Gary
  • 181
  • 1
  • 1
  • 4
  • 1
    Try `strace gcc 2>&1 | grep -i spec` to see where it looks for the file. – Johannes Schaub - litb Apr 25 '11 at 12:57
  • @Johannes Schaub - litb It gives no results, whereas the working system gives the path to the specs file. It also gives no results running that command for the 4.1.2 version of gcc located in /usr/bin. (The working system gives paths for both the 4.3.2 and 4.1.2 versions of the compiler, though the 4.1.2 version has "(No such file or directory)" since it is using built-in specs.) – Gary Apr 25 '11 at 14:20
  • 1
    @Johannes Schaub - litb Scratch that. Strace wasn't installed. It appears it is attempting to access `/usr/local/include/x86_64-unknown-linux-gnu/4.3.2/specs`, `/usr/local/include/specs`, `/usr/lib/gcc/x86_64-unknown-linux-gnu/4.3.2/specs`, `/usr/local/include/../../x86_64-unknown-linux-gnu/lib/specs`, `/usr/local/include/../../x86_64-unknown-linux-gnu/lib/x86_64-unknown-linux-gnu/4.3.2/specs`, or `/usr/local/gcc-4.3.2/lib/gcc/x86_64-unknown-linux-gnu/specs`, all of which fail. – Gary Apr 25 '11 at 14:41

3 Answers3

5

As hinted at by the strace suggestion by Johannes Schaub - litb, it was a problem with where the compiler was looking for the file. As it turns out, the non-working installation had an environment variable set in the .bashrc that was causing the confusion.

The correct location for the specs file is indeed the same directory that libgcc is in. Just be sure you're looking there.

Gary
  • 51
  • 1
1

I used this command line:

/usr/bin/set-gcc-default-3.sh i686-pc-mingw32

but you'll probably want:

/usr/bin/set-gcc-default-4.sh i686-pc-linux-gnu

(Note the -4 instead of -3)

This is built using the "alternatives" stuff, please see

/usr/sbin/alternatives.exe --help

And also see pages such as http://linux.about.com/library/cmd/blcmdl8_alternatives.htm

johnstosh
  • 335
  • 1
  • 5
  • This looks interesting. Does GCC supply the `set-gcc-default-*` scripts? I don't seem to have it on a Linaro device. – jww May 19 '16 at 09:55
0

You rebuild gcc with your specs file as part of the build!

A simpler solution is to create an alias:

alias gcc_Gary gcc -specs /<folder With Specs File>/newSpecsFile
Martin York
  • 257,169
  • 86
  • 333
  • 562