Compiling clang with libc++ and errors in compiler-rt

Hello,

I have been trying to compile clang doe some time now. If I use the GCC C++
library it works, but when I try to recompile so that the installed libc++
(using the `--enable-libcpp` configure argument) is used it stops when compiling
compiler-rt:

When a run `make` again, with verbose flags for the compilers I see that `clang`
is called without any include search paths.

The error output is this:

---8<---

make[5]: Entering directory
`/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt'
COMPILE: clang_linux/full-i386/i386:
/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/lib/absvdi2.c
/home/joachimp/tmp/clang/clang/build-clang-libcxx1/Release/bin/clang -v -m32
--sysroot=/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/SDKs/linux -c
-fPIC -o
/home/joachimp/tmp/clang/clang/build-clang-libcxx1/tools/clang/runtime/compiler-rt/clang_linux/full-i386/i386/SubDir.lib/absvdi2.o
/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/lib/absvdi2.c
clang version 3.3 (trunk 176337)
Target: i386-unknown-linux-gnu
Thread model: posix
"/home/joachimp/tmp/clang/clang/build-clang-libcxx1/Release/bin/clang" -cc1
-triple i386-unknown-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name absvdi2.c -mrelocation-model pic
-pic-level 2 -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases
-fuse-init-array -target-cpu pentium4 -target-linker-version 2.20.1
-momit-leaf-frame-pointer -v -coverage-file
/home/joachimp/tmp/clang/clang/build-clang-libcxx1/tools/clang/runtime/compiler-rt/clang_linux/full-i386/i386/SubDir.lib/absvdi2.o
-resource-dir
/home/joachimp/tmp/clang/clang/build-clang-libcxx1/Release/bin/../lib/clang/3.3
-isysroot /home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/SDKs/linux
-internal-isystem
/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/SDKs/linux/usr/local/include
-internal-isystem
/home/joachimp/tmp/clang/clang/build-clang-libcxx1/Release/bin/../lib/clang/3.3/include
-internal-externc-isystem -internal-externc-isystem -internal-externc-isystem
-fdebug-compilation-dir
/home/joachimp/tmp/clang/clang/build-clang-libcxx1/tools/clang/runtime/compiler-rt
-ferror-limit 19 -fmessage-length 118 -mstackrealign -fobjc-runtime=gcc
-fdiagnostics-show-option -fcolor-diagnostics -backend-option -vectorize-loops
-o
/home/joachimp/tmp/clang/clang/build-clang-libcxx1/tools/clang/runtime/compiler-rt/clang_linux/full-i386/i386/SubDir.lib/absvdi2.o
-x c /home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/lib/absvdi2.c
clang -cc1 version 3.3 based upon LLVM 3.3svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory
"/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/SDKs/linux/usr/local/include"
ignoring nonexistent directory ""
ignoring nonexistent directory ""
ignoring nonexistent directory ""
#include "..." search starts here:
#include <...> search starts here:

/home/joachimp/tmp/clang/clang/build-clang-libcxx1/Release/bin/../lib/clang/3.3/include
End of search list.
In file included from
/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/lib/absvdi2.c:15:
In file included from
/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/lib/int_lib.h:41:
In file included from
/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/lib/int_types.h:21:
/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt/lib/int_endianness.h:84:10:
fatal error: 'endian.h' file not
found
#include <endian.h>
^
1 error generated.
make[5]: ***
[/home/joachimp/tmp/clang/clang/build-clang-libcxx1/tools/clang/runtime/compiler-rt/clang_linux/full-i386/i386/SubDir.lib/absvdi2.o]
Error 1
make[5]: Leaving directory
`/home/joachimp/tmp/clang/clang/llvm/projects/compiler-rt'

---8<---

I have to manually set the CFLAGS to have `-I/usr/include` as an argument to
`make` for it to work. It does not help to set the `CXXFLAGS` or `CPPFLAGS`
before doing configure.

Is this perhaps a known bug? I can't seem to find anything about it.

The configuration command line I use is:

../llvm/configure \
    --enable-cxx11 \
    --enable-optimized \
    --disable-assertions \
    --disable-backtraces \
    --with-gcc-toolchain=/opt/gcc \

   --with-c-include-dirs="/usr/include:/usr/local/include/c++/v1:/usr/local/include"
\
    --enable-libcpp

I'm on a Debian 6 system, and have GCC 4.7.1 installed in /opt/gcc.

`uname -a` output:

Linux lnxjoachimp 2.6.32-5-amd64 #1 SMP Fri Feb 15 15:39:52 UTC 2013 x86_64
GNU/Linux