[3.5 Release] <cxxabi.h> not found by clang-3.5 rc1 with libc++

I managed to post this to the llvm.devel list, so posting here also. Apologies.

This seems to be exclusive to the rc1, trunk works, clang-3.4 works, etc

ben:~/development/test$ cat abi.cpp
#include <cxxabi.h>

int main() {}

ben:~/development/test$ clang++-3.4 -stdlib=libc++ abi.cpp
ben:~/development/test$ clang++-3.5 -stdlib=libc++ abi.cpp
abi.cpp:1:10: fatal error: 'cxxabi.h' file not found
#include <cxxabi.h>
          ^
1 error generated.

As far as I know, they all use the same libc++ install (also trunk) and built against libc++abi.

/usr/include/c++/v1/cxxabi.h exists and is installed when I install libc++.

Ben

Ben Pope <benpope81@...> writes:

I managed to post this to the llvm.devel

list, so posting here also.

Apologies.

This seems to be exclusive to the rc1, trunk

works, clang-3.4 works, etc

ben:~/development/test$ cat abi.cpp
#include <cxxabi.h>

int main() {}

ben:~/development/test$ clang++-3.4 -

stdlib=libc++ abi.cpp

ben:~/development/test$ clang++-3.5 -

stdlib=libc++ abi.cpp

abi.cpp:1:10: fatal error: 'cxxabi.h' file

not found

#include <cxxabi.h>
          ^
1 error generated.

As far as I know, they all use the same

libc++ install (also trunk) and

built against libc++abi.

/usr/include/c++/v1/cxxabi.h exists and is

installed when I install libc++.

Ben

Ping

Does the following work?

$ clang++ -nostdinc++ -I/usr/include/c++/v1/ -stdlib=c++ abi.cpp

ben:~/development/test$ clang++-3.5 -std=c++11 -stdlib=libc++ abi.cpp -nostdinc -I/usr/include/c++/v1
In file included from abi.cpp:1:
/usr/include/c++/v1/cxxabi.h:18:10: fatal error: 'stddef.h' file not found
#include <stddef.h>

So, yes, it finds the file at least.

Ben

This has been broken on Linux [Debian Linux in my case], as in it has never worked on Linux that I’ve tested, but it magically works [for obvious reasons] on OS X.

Debian has LLVM/Clang 3.4.2 with /usr/include/c++/v1/

Building from trunk having /usr/local/include/c++/v1

Both are broken.

I don’t even bother building trunk with the following turned on:

//Use libc++ if available.
LLVM_ENABLE_LIBCXX:BOOL=ON

I default to the following:

//Use libc++ if available.
LLVM_ENABLE_LIBCXX:BOOL=OFF

Otherwise, the damn stack won’t compile. By off it just defaults to GCC’s libstc++ stack and compiles as expected. Everything else with compiling a fresh libc++ builds when turned on in cmake, but this part.

  • Marc

I'm wondering if the RC is built with an in-tree libc++ or something. I don't have a lot of time to investigate right now.

Most of my boost tests are failing, so for whatever reason it seems like a big regression.

Ben

I've been building and running the clang test releases and tests, as well as trunk on Ubuntu for a while with libc++ and libc++abi, it's been fine until the 3.5 RC1.

That is to say that the boost regression test suite that I also run and publish, seem to have a very similar pass rate as gcc.

I don't usually build libc++ and libc++abi in-tree with clang and llvm, but the clang release script was fine with 3.3, 3.4, 3.4.1, 3.4.2 and perhaps earlier.

Ben

ben:~/development/test$ clang+±3.5 -std=c++11 -stdlib=libc++ abi.cpp
-nostdinc -I/usr/include/c++/v1
In file included from abi.cpp:1:
/usr/include/c++/v1/cxxabi.h:18:10: fatal error: ‘stddef.h’ file not found

-nostdinc**++**. We still want it to find the standard headers, just not libstdc++.

LLVM_ENABLE_LIBCXX controls whether or not LLVM itself is built with libc++. AFAIK, it shouldn’t affect clang’s behavior from the user side of things.

Sounds like it’s an issue with clang’s default include search path. Maybe one of the clang people can chime in?

    ben:~/development/test$ clang++-3.5 -std=c++11 -stdlib=libc++ abi.cpp
    -nostdinc -I/usr/include/c++/v1
    In file included from abi.cpp:1:
    /usr/include/c++/v1/cxxabi.h:__18:10: fatal error: 'stddef.h' file
    not found

-nostdinc*++*. We still want it to find the standard headers, just not
libstdc++.

Mea culpa, it compiles successfully.

LLVM_ENABLE_LIBCXX controls whether or not LLVM itself is built with
libc++. AFAIK, it shouldn't affect clang's behavior from the user side
of things.

Sounds like it's an issue with clang's default include search path.
Maybe one of the clang people can chime in?

Is there some way to check what the include paths are?

Ben

Using -v flag shows these paths (as well as a bunch of other stuff).
Here's what I get:

make headers
/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/clang++
-c -O0 -gdwarf-2 -std=c++1y -isystem /usr/local/include/c++/4.9.0
-isystem /usr/local/include/c++/v1 -v -x c++ /dev/null -fsyntax-only
clang version 3.5.0 (tags/RELEASE_35/rc1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free -main-file-name null -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24 -v -gdwarf-2 -dwarf-column-info -resource-dir /home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/../lib/clang/3.5.0 -isystem /usr/local/include/c++/4.9.0 -isystem /usr/local/include/c++/v1 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/x86_64-linux-gnu -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8 -internal-isystem /usr/local/include -internal-isystem /home/evansl/dwnlds/llvm/3.5rc!
1/build-va
riants/release/install/bin/../lib/clang/3.5.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O0 -std=c++1y -fdeprecated-macro -fdebug-compilation-dir /home/evansl/prog_dev/clang -ferror-limit 19 -fmessage-length 124 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -x c++ /dev/null
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/x86_64-linux-gnu"
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include/c++/4.9.0
/usr/local/include/c++/v1
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8
/usr/local/include
/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/../lib/clang/3.5.0/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.

Compilation finished at Thu Aug 7 10:49:31

You'll have to parse the output to get the include paths shown between:

#include <...> search starts here:

and:

End of search list.

You may be curious about the /usr/local/include entries. If you look at
the command, you'll see 2 -isystem flags. I've had to add those to get
the compiles to work on a simple hello_work.cpp program.

HTH.

-regards,
Larry

Right, so I get this:

clang++-3.5 -std=c++11 -stdlib=libc++ abi.cpp -v
clang version 3.5.0 (tags/RELEASE_350/rc2)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Selected multilib: .;@m64
"/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/clang" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name abi.cpp -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -target-linker-version 2.24.51.20140617 -v -dwarf-column-info -resource-dir /home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../lib/clang/3.5.0 -internal-isystem /home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../include/c++/v1 -internal-isystem /usr/local/include -internal-isystem /home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../lib/clang/3.5.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -std=c++11 -fdeprecated-macro -fdebug-compilation-dir /home/ben/development/test -ferror-limit 19 -fmessage-length 253 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/abi-97f8d1.o -x c++ abi.cpp
clang -cc1 version 3.5.0 based upon LLVM 3.5.0 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../include/c++/v1
  /usr/local/include
/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../lib/clang/3.5.0/include
  /usr/include/x86_64-linux-gnu
  /usr/include
End of search list.
abi.cpp:1:10: fatal error: 'cxxabi.h' file not found
#include <cxxabi.h>
          ^
1 error generated.

So perhaps there is something not quite right about the libc++ built with clang-3.5.

Does anybody know if ./llvm.src/utils/release/test-release.sh is supposed to build a working libc++? I thought I read recently that libc++abi is the default, but perhaps that's for clang-3.6.

Ben

     ben:~/development/test$ clang++-3.5 -std=c++11 -stdlib=libc++
abi.cpp
     -nostdinc -I/usr/include/c++/v1
     In file included from abi.cpp:1:
     /usr/include/c++/v1/cxxabi.h:__18:10: fatal error: 'stddef.h' file
     not found

-nostdinc*++*. We still want it to find the standard headers, just not
libstdc++.

Mea culpa, it compiles successfully.

LLVM_ENABLE_LIBCXX controls whether or not LLVM itself is built with
libc++. AFAIK, it shouldn't affect clang's behavior from the user side
of things.

Sounds like it's an issue with clang's default include search path.
Maybe one of the clang people can chime in?

Is there some way to check what the include paths are?

Ben

Using -v flag shows these paths (as well as a bunch of other stuff).
Here's what I get:

make headers
/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/clang++

-c -O0 -gdwarf-2 -std=c++1y -isystem /usr/local/include/c++/4.9.0
-isystem /usr/local/include/c++/v1 -v -x c++ /dev/null -fsyntax-only
clang version 3.5.0 (tags/RELEASE_35/rc1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.2
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.0
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Candidate multilib: .;@m64
Selected multilib: .;@m64

"/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/clang"
-cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -disable-free
-main-file-name null -mrelocation-model static -mdisable-fp-elim
-fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables
-fuse-init-array -target-cpu x86-64 -target-linker-version 2.24 -v
-gdwarf-2 -dwarf-column-info -resource-dir
/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/../lib/clang/3.5.0
-isystem /usr/local/include/c++/4.9.0 -isystem
/usr/local/include/c++/v1 -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/x86_64-linux-gnu
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8

/ba

  ckward -internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8
-internal-isystem /usr/local/include -internal-isystem
/home/evansl/dwnlds/llvm/3.5rc!
  1/build-va
riants/release/install/bin/../lib/clang/3.5.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -O0 -std=c++1y -fdeprecated-macro -fdebug-compilation-dir
/home/evansl/prog_dev/clang -ferror-limit 19 -fmessage-length 124
-mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -x c++ /dev/null
clang -cc1 version 3.5.0 based upon LLVM 3.5.0svn default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/x86_64-linux-gnu"

ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
  /usr/local/include/c++/4.9.0
  /usr/local/include/c++/v1
  /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8
  /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward

/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8

  /usr/local/include

/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/../lib/clang/3.5.0/include

  /usr/include/x86_64-linux-gnu
  /usr/include
End of search list.

Compilation finished at Thu Aug 7 10:49:31

You'll have to parse the output to get the include paths shown between:

#include <...> search starts here:

and:

End of search list.

You may be curious about the /usr/local/include entries. If you look at
the command, you'll see 2 -isystem flags. I've had to add those to get
the compiles to work on a simple hello_work.cpp program.

Right, so I get this:

clang++-3.5 -std=c++11 -stdlib=libc++ abi.cpp -v
clang version 3.5.0 (tags/RELEASE_350/rc2)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.1
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
Candidate multilib: .;@m64
Selected multilib: .;@m64

"/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/clang"
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all
-disable-free -disable-llvm-verifier -main-file-name abi.cpp
-mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu
x86-64 -target-linker-version 2.24.51.20140617 -v -dwarf-column-info
-resource-dir
/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../lib/clang/3.5.0
-internal-isystem
/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../include/c++/v1
-internal-isystem /usr/local/include -internal-isystem
/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../lib/clang/3.5.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem
/usr/include -std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/home/ben/development/test -ferror-limit 19 -fmessage-length 253
-mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -o /tmp/abi-97f8d1.o -x
c++ abi.cpp
clang -cc1 version 3.5.0 based upon LLVM 3.5.0 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:

/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../include/c++/v1

/usr/local/include

/home/ben/development/llvm/3.5/rc2/Phase3/Release/llvmCore-3.5.0-rc2.install/bin/../lib/clang/3.5.0/include

/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
abi.cpp:1:10: fatal error: 'cxxabi.h' file not found
#include <cxxabi.h>
         ^
1 error generated.

So perhaps there is something not quite right about the libc++ built
with clang-3.5.

Does anybody know if ./llvm.src/utils/release/test-release.sh is
supposed to build a working libc++? I thought I read recently that
libc++abi is the default, but perhaps that's for clang-3.6.

Ben

The attached headers.mk makefile hightlights how the
include search paths differ depending on the presence or absence
of the -nostdinc++ flag.

The output of the make is:

-*- mode: compilation; default-directory: "~/prog_dev/clang/" -*-
Compilation started at Tue Aug 12 14:09:21

make -f headers.mk headers
***headers***
header=cxx
how=clangxx3_5_rc1
/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/clang++
-stdlib=libc++ -std=c++11 -nostdinc++ -v -x c++ abi.cpp 2>
not.cxx.compile-clangxx3_5_rc1.out
make: [headers] Error 1 (ignored)
csplit not.cxx.compile-clangxx3_5_rc1.out '%^#include <%'+1 '/^End of
search/' >/dev/null
mv xx00 not.out
/home/evansl/dwnlds/llvm/3.5rc1/build-variants/release/install/bin/clang++
-stdlib=libc++ -std=c++11 -v -x c++ abi.cpp 2>
yes.cxx.compile-clangxx3_5_rc1.out
csplit yes.cxx.compile-clangxx3_5_rc1.out '%^#include <%'+1 '/^End of
search/' >/dev/null
mv xx00 yes.out
diff not.out yes.out
0a1

/usr/include/c++/v1

make: *** [headers] Error 1

Compilation exited abnormally with code 2 at Tue Aug 12 14:09:23

showing that the only difference is the libc++ include:

/usr/include/c++/v1

In contrast to you original post, the compile without this flag
succeeds, as shown by the
yes.cxx.compile-clangxx3_5_rc1.out contents,
which is also attached. OTOH, *with* the -nostdinc++ flag, the
not.cxx.compile-clangxx3_5_rc1.out contents, also attached, show
the same error as your original post:

abi.cpp:1:10: fatal error: 'cxxabi.h' file not found
#include <cxxabi.h>
         ^
1 error generated.

So the mystery here is why Ben's clang3.5rc1 compile of abi.cpp failed
but mine succeeded.

Dan Albert's 2nd post, on 8/4, indicated it was because Ben's clang was
looking for the libstdc++, but my clang3.5rc1 apparently doesn't have
that problem.

-regards,
Larry

BTW, you can't use header.mk directly because it has some included
makefiles which are not attached; however, I think you can figure
out from the macro names the proper substitutions to make.

headers.mk (1.23 KB)

yes.cxx.compile-clangxx3_5_rc1.out (2.66 KB)

not.cxx.compile-clangxx3_5_rc1.out (1.95 KB)

I think it's looking for paths relative to the binary, and although libc++ headers exist, there is no abi layer and no built libc++.so.

I don't know if the test-release script is supposed to build and package libc++ (and perhaps libc++abi) or not on linux.

Ben