llvm can't use headers from gcc 4.4 on centos Linux x86

Tried building a simple cout << "Hello!" << endl program using
<iostream> and failed while trying to compile the iostream headers and
their dependencies. The errors effected gcc 4.4 on x86_64 Centos
Linux.

Hi Richard,

Was this intended for the clang list (cfe-dev@cs.uiuc.edu)?

If so, could you provide some error output when re-sending to that list. I'm assuming you modified Clang to find
the correct c++ libraries. See note #5 of http://clang.llvm.org/get_started.html for trunk version if this applies.

Garrison

Hi Richard,

Tried building a simple cout<< "Hello!"<< endl program using
<iostream> and failed while trying to compile the iostream headers and
their dependencies. The errors effected gcc 4.4 on x86_64 Centos
Linux.

presumably this is about clang? If so, please write to the clang mailing
list instead (cfe-dev@cs.uiuc.edu).

Ciao,

Duncan.

Tried building a simple cout << "Hello!" << endl program using
<iostream> and failed while trying to compile the iostream headers and
their dependencies. The errors effected gcc 4.4 on x86_64 Centos
Linux.

I've attached the error output.

centos default is gcc 4.1.2, not 4.4.0, and I did modify the header
search for both C and C++ FIXMEs.

terminal-output (10.4 KB)

Richard, good afternoon.
I have some questions for you.

Which version of CentOS do you use? I assume CentOS 5.x.

Is your g++-4.4.0 the package "gcc44-c++" provided by centos.org?

Which version of clang/llvm do you build?

Do you build clang/llvm with gcc44?

What is your modification? Please show us by diff -u or svn diff

FYI, clang/llvm is available on centos5 with a few patches.
(you know, it requires gcc44)
simple std::cout works w/o any errors with clang++.

$ ./config.status --version
llvm config.status 2.9svn
configured by ../../llvm/configure, generated by GNU Autoconf 2.60,
  with options "'-C' '--enable-optimized=1' '--enable-targets=all'
'CC=gcc44' 'CXX=g++44'"

...Takumi

Hey, thanks for getting back to me. So, I hate when this happens, but
I checked out a fresh copy of the repo from svn, built it with gcc44
and g++44 right off the bat (as opposed to trying 41 first), and also
made my object directory separate from the source dir (which I didn't
do last time, and allows me to do make dist-clean). This time it
built, and was able to compile hello.cpp, my std::cout program that
includes <iostream>. I don't know which of these actions made it
'work', but I can confirm that with gcc/++44 it works. However it
doesn't pass make check without issuing some "unexpected errors"m.
I've attached the failed errors.

My question is: are these standard errors for CentOS 5.x with gcc44
and g++44? The patch with my changes follow (just 10-ish lines). You
mentioned a patch set, I googled around but wasn't able to find it.
Where can I get a copy of the CentOS patch set? Is it much different
then this patch of mine?

The paths I added were generated by "gcc44 -v -x c++ /dev/null
-fsyntax-only" as instructed by the web page docs.

Thanks.

crossroads$ svn diff
Index: lib/Frontend/InitHeaderSearch.cpp

stdout (9.95 KB)

Good midnight Richard,

OK, thanks. Also I forgot to include the AddPaths for the C search,
here is the updated patch. Also its for CentOS 5.5, not 5.3:

crossroads$ svn diff
Index: lib/Frontend/InitHeaderSearch.cpp

Good morning, Richard.

The patch for MC/MachO has been committed in r117637.

  Expected Passes : 7620
  Expected Failures : 59
  Unsupported Tests : 555

My comments are below inline;

OK, thanks. Also I forgot to include the AddPaths for the C search,
here is the updated patch. Also its for CentOS 5.5, not 5.3:

crossroads$ svn diff
Index: lib/Frontend/InitHeaderSearch.cpp

--- lib/Frontend/InitHeaderSearch.cpp (revision 117545)
+++ lib/Frontend/InitHeaderSearch.cpp (working copy)
@@ -418,7 +418,13 @@
void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
const HeaderSearchOptions
&HSOpts) {
+ AddPath("/usr/include/c++/4.4.0", System, true, false, false);
+ AddPath("/usr/include/c++/4.4.0/x86_64-redhat-linux6E", System,
true, false, false);
+ AddPath("/usr/include/c++/4.4.0/backward", System, true, false, false);

You don't have to include C++ dirs here :slight_smile:

+ AddPath("/usr/lib/gcc/x86_64-redhat-linux6E/4.4.0/include", System,
true, false, false);

It should be avoided. Clang has its alternatives.
It can be assumed as "gcc-44 specific headers".

@@ -645,6 +651,13 @@
//===------------------------------------------------------------------===//
// Redhat based distros.
//===------------------------------------------------------------------===//
+ // Centos 5.3
+ AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.0","", "", "", triple);
+ AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.0/x86_64-redhat-linux6E","",
"", "", triple);
+ AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.0/backward","",
"", "", triple);
+ AddGnuCPlusPlusIncludePaths("/usr/local/include","", "", "", triple);
+ AddGnuCPlusPlusIncludePaths("/usr/lib/gcc/x86_64-redhat-linux6E/4.4.0/include","",
"", "", triple);

It's bad and redundant. Please see the implementation of
InitHeaderSearch::AddGnuCPlusPlusIncludePaths().

FYI this is my local patch.
You might also add "g++44" to lib/Driver/Driver.cpp.

--- a/lib/Frontend/InitHeaderSearch.cpp
+++ b/lib/Frontend/InitHeaderSearch.cpp
@@ -664,6 +664,12 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple)
                                 "x86_64-redhat-linux", "32", "", triple);
     AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.1",
                                 "i586-redhat-linux","", "", triple);
+ // CentOS5(gcc44)
+#if __GNUC__ == 4 && __GNUC_MINOR__ == 4
+ AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.4.0",
+ "x86_64-redhat-linux6E", "32", "", triple);
+#endif