specs file make gcc 4.1.2 segfault

Benoit Sigoure tsuna@lrde.epita.fr
Tue Feb 20 15:10:00 GMT 2007


Quoting Benoit Sigoure <tsuna@lrde.epita.fr>:
> Hello,
> (please use reply all as I am not subscribed to the list)
>
> The big picture: I'm installing gcc 4.1.2 (with only C and C++ 
> frontends) on an
> NFS mount and trying to setup a default specs file so that a -rpath 
> gets added
> at link time so that C++ applications can be run without changing the
> LD_LIBRARY_PATH so that they find libstdc++.so.
>

This topic (which definitely looks like a FAQ) was also addressed on the
autoconf ML (not be me though) a link to
http://gcc.gnu.org/ml/gcc/2006-06/msg00806.html was posted.

Adding the -rpath in the specs file is not just about writing *link: -rpath
... in the specs file, and the FAQ does not make this clear at all, and I
think that's why the question keeps coming back on the various MLs. I think
the FAQ should be updated and should make it clear as to how to tackle this
problem. Ideally, there should be an option at configure time that tells GCC
it will be installed in a non standard location and that because of that, the
user *wants* the -rpath option added to the builtin specs file (if the target
allows it, I suppose not all targets have something equivalent)


So, back to my problem, I now get an idea as to why whenever I add a specs
file, running "g++ -v" makes it print g++: unrecognized option '-v' The
builtin specs specify "%{v:-version}" in the "*cc1_options:" spec string. This
made me think that whenever a specs file is used, to completely overrides the
builtin spec strings, thus one should not start with an empty specs file if
they just want to add/modify GCC options. I don't know whether this a bug or a
feature but the documentation
(http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Spec-Files.html) does not make it
clear that GCC has this behavior.

So I started with a new specs file this way:
$ gcc -dumpspecs > _inst/lib/gcc/i386-unknown-netbsdelf3.0./4.1.2/specs

Now GCC loads and uses the spec strings specified in this file (at least, I
can tell it's reading the file with kdump/ktrace) but I can't get it to do
anything useful.

For instance I tried to add an option -foo that would behave like --version: I
added %{foo:-version} at the end of the spec string "*cc1_options:" and then
running gcc -foo would not do anything else than printing "gcc: no input
files" (I tried many other combinations because -foo could be mixed up with
optimization options, so I tried with -K too, which does not seem to be used
by GCC)

Even changing the %{v:-version} to %{K:-version} which was originally in the
spec string "*cc1_options:" does not change anything: gcc still accepts -v and
silently ignores -K. However, without the %{K:-version}, using gcc -K prints
"gcc: unrecognized option '-K'".

I'd greatly appreciate if someone could shed some light on this.

-- 
SIGOURE Benoit aka Tsuna
   _____
  /EPITA\ Promo 2008, LRDE



More information about the Gcc-help mailing list