Patch: Find gcc-4.4.4 on Gentoo

Hi all,

Attached a trivial patch against trunk to make InitHeaderSearch find
gcc-4.4.4 headers on Gentoo systems. Tested here and now I finally have a
working clang!

Cheers,

Bertjan

p.s. For the interested: I opened a bug with an ebuild fix for the 2.8
release on Gentoo as well: 345683 – sys-devel/clang-2.8-r2: Add support for gcc-4.4.4 to clang 2.8

gentoo-gcc-4.4.4.patch (687 Bytes)

I think hard code the include/lib path is BAD idea.
Even a mirror version bummed, we must add another case !

I think we maybe have 2 approach:

1. Use a config file
This file can be generated by compile time, and updated at any time.

2. Found path at run time
For example, gcc can generate such verbose output:

# gcc -O2 -v Hello.c
Using built-in specs.
Target: i486-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian
4.4.5-6' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.4 --enable-shared --enable-multiarch
--enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --libdir=/usr/lib
--enable-nls --enable-clocale=gnu --enable-libstdcxx-debug
--enable-objc-gc --enable-targets=all --with-arch-32=i586
--with-tune=generic --enable-checking=release --build=i486-linux-gnu
--host=i486-linux-gnu --target=i486-linux-gnu
Thread model: posix
gcc version 4.4.5 (Debian 4.4.5-6)
COLLECT_GCC_OPTIONS='-O2' '-v' '-mtune=generic' '-march=i586'
/usr/lib/gcc/i486-linux-gnu/4.4.5/cc1 -quiet -v Hello.c -quiet
-dumpbase Hello.c -mtune=generic -march=i586 -auxbase Hello -O2
-version -o /tmp/ccd2fqzF.s
ignoring nonexistent directory "/usr/local/include/i486-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../i486-linux-gnu/include"
ignoring nonexistent directory "/usr/include/i486-linux-gnu"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/lib/gcc/i486-linux-gnu/4.4.5/include
/usr/lib/gcc/i486-linux-gnu/4.4.5/include-fixed
/usr/include
End of search list.
GNU C (Debian 4.4.5-6) version 4.4.5 (i486-linux-gnu)
        compiled by GNU C version 4.4.5, GMP version 4.3.2, MPFR
version 3.0.0-p3.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: ac416eae4ede756d7afac2a14e735189
COLLECT_GCC_OPTIONS='-O2' '-v' '-mtune=generic' '-march=i586'
as -V -Qy -o /tmp/ccjkT41T.o /tmp/ccd2fqzF.s
GNU assembler version 2.20.1 (i486-linux-gnu) using BFD version (GNU
Binutils for Debian) 2.20.1-system.20100303
COMPILER_PATH=/usr/lib/gcc/i486-linux-gnu/4.4.5/:/usr/lib/gcc/i486-linux-gnu/4.4.5/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.4.5/:/usr/lib/gcc/i486-linux-gnu/:/usr/lib/gcc/i486-linux-gnu/4.4.5/:/usr/lib/gcc/i486-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/i486-linux-gnu/4.4.5/:/usr/lib/gcc/i486-linux-gnu/4.4.5/:/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/:/lib/../lib/:/usr/lib/../lib/:/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-O2' '-v' '-mtune=generic' '-march=i586'
/usr/lib/gcc/i486-linux-gnu/4.4.5/collect2 --build-id --eh-frame-hdr
-m elf_i386 --hash-style=both -dynamic-linker /lib/ld-linux.so.2
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crti.o
/usr/lib/gcc/i486-linux-gnu/4.4.5/crtbegin.o
-L/usr/lib/gcc/i486-linux-gnu/4.4.5
-L/usr/lib/gcc/i486-linux-gnu/4.4.5
-L/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib -L/lib/../lib
-L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.4.5/../../..
/tmp/ccjkT41T.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc
--as-needed -lgcc_s --no-as-needed
/usr/lib/gcc/i486-linux-gnu/4.4.5/crtend.o
/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crtn.o
root@vc:/tmp#

We can got lib path (LIBRARY_PATH) and include path ( #include search
starts here / End of search list) very easy.

I think we maybe have 2 approach:

1. Use a config file
This file can be generated by compile time, and updated at any time.

2. Found path at run time
For example, gcc can generate such verbose output:

We already have support for configure options for setting this. Adding
support for figuring out the correct values from the host compiler
would be a very nice improvement.

For now I think this patch is OK (assuming this is a common gentoo
configuration...).

Cheers,
Rafael

Are you said '-I' and '-L' operation ?

I mean such host compiler setting should not hard code,
can use compiled time setting, configuration file or obtained at run
time search instead.

Could you give a link ?

Rafael Espíndola wrote:

I think we maybe have 2 approach:

1. Use a config file
This file can be generated by compile time, and updated at any time.

2. Found path at run time
For example, gcc can generate such verbose output:

We already have support for configure options for setting this. Adding
support for figuring out the correct values from the host compiler
would be a very nice improvement.

Yes, I noticed that Gentoo has a use flag for this, which if enabled (not
the default) indeed uses the correct path as well. But as said, it wasn't
the default and IMO the default configuration should work as well.

For now I think this patch is OK (assuming this is a common gentoo
configuration...).

It is a common configuration yes. And indeed, getting the correct values
from the host compiler might be nice, but in the end it doesn't differ
that much from the current situation. I.e. you'll need (slightly)
different calls to compiler executables and output parsing for each
different compiler (though, probably a lot less as you don't need a new
method for each compiler version, most likely).

Anyhow, I don't have commit rights, so if somebody who has can commit...
I'd appreciate.

Rafael Espíndola wrote:

I think we maybe have 2 approach:

1. Use a config file
This file can be generated by compile time, and updated at any time.

2. Found path at run time
For example, gcc can generate such verbose output:

We already have support for configure options for setting this. Adding
support for figuring out the correct values from the host compiler
would be a very nice improvement.

Yes, I noticed that Gentoo has a use flag for this, which if enabled (not
the default) indeed uses the correct path as well. But as said, it wasn't
the default and IMO the default configuration should work as well.

For now I think this patch is OK (assuming this is a common gentoo
configuration...).

It is a common configuration yes. And indeed, getting the correct values
from the host compiler might be nice, but in the end it doesn't differ
that much from the current situation. I.e. you'll need (slightly)
different calls to compiler executables and output parsing for each
different compiler (though, probably a lot less as you don't need a new
method for each compiler version, most likely).

Anyhow, I don't have commit rights, so if somebody who has can commit...
I'd appreciate.

Landed in r119348. Thanks for the patch!