[cfe-users] Can't find correct libstdc++ headers with --with-gcc-toolchain nor --with-cxx-include-root

Steven Vormwald sdvormwa at mtu.edu
Tue Apr 22 15:38:08 PDT 2014


Hello,

I'm trying to build clang 3.4 to use libstdc++ from an installation of GCC
4.8.1, but I haven't been able to get clang to correctly locate the
headers.  I've tried configuring both using the '--with-gcc-toolchain'
option and the '--with-cxx-include-root' option, but in both cases the
resulting clang toolchain doesn't find the C++ headers.  I suspect this is
because GCC was configured with a non-standard layout
(--with-gxx-include-dir=$PREFIX/include/g++ rather than
$PREFIX/include/c++).  I've included the output of compiling an empty C++
program with -fsyntax only for gcc (slightly modified by replacing
identifying information in the actual output with the string 'VENDOR') [1]
and both variants of clang [2,3] at the end of the email.

Are there other configure options I should try?  Am I going to need to
patch the driver (lib/Driver/ToolChains.cpp) to get this working?  Any
suggestions would be greatly appreciated.

Steven Vormwald


[1] GCC 4.8.1:

$ g++ -fsyntax-only -v t.c
Using built-in specs.
COLLECT_GCC=/opt/gcc/4.8.1/bin/../snos/bin/g++
COLLECT_LTO_WRAPPER=/opt/gcc/4.8.1/snos/libexec/gcc/x86_64-suse-linux/4.8.1/lto-wrapper
Target: x86_64-suse-linux
Configured with: ../VENDOR-gcc-4.8.1/configure --prefix=/opt/gcc/4.8.1/snos
--disable-nls --libdir=/opt/gcc/4.8.1/snos/lib
--enable-languages=c,c++,fortran
--with-gxx-include-dir=/opt/gcc/4.8.1/snos/include/g++
--with-slibdir=/opt/gcc/4.8.1/snos/lib --with-system-zlib --enable-shared
--enable-__cxa_atexit --build=x86_64-suse-linux
--with-mpc=/opt/gcc/mpc/0.8.1 --with-mpfr=/opt/gcc/mpfr/2.4.2
--with-gmp=/opt/gcc/gmp/4.3.2
Thread model: posix
gcc version 4.8.1 20130531 (VENDOR) (GCC)
COLLECT_GCC_OPTIONS='-fsyntax-only' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
 /opt/gcc/4.8.1/snos/libexec/gcc/x86_64-suse-linux/4.8.1/cc1plus -quiet -v
-D_GNU_SOURCE t.c -quiet -dumpbase t.c -mtune=generic -march=x86-64
-auxbase t -version -fsyntax-only -o /dev/null
GNU C++ (GCC) version 4.8.1 20130531 (VENDOR) (x86_64-suse-linux)
        compiled by GNU C version 4.8.1 20130531 (VENDOR), GMP version
4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory
"/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/../../../../x86_64-suse-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /opt/gcc/4.8.1/snos/include/g++
 /opt/gcc/4.8.1/snos/include/g++/x86_64-suse-linux
 /opt/gcc/4.8.1/snos/include/g++/backward
 /opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/include
 /usr/local/include
 /opt/gcc/4.8.1/snos/include
 /opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/include-fixed
 /usr/include
End of search list.
GNU C++ (GCC) version 4.8.1 20130531 (VENDOR) (x86_64-suse-linux)
        compiled by GNU C version 4.8.1 20130531 (VENDOR), GMP version
4.3.2, MPFR version 2.4.2, MPC version 0.8.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 179a0f2be046b98875cb1f704d81fcba
COMPILER_PATH=/opt/gcc/4.8.1/snos/libexec/gcc/x86_64-suse-linux/4.8.1/:/opt/gcc/4.8.1/snos/libexec/gcc/x86_64-suse-linux/4.8.1/:/opt/gcc/4.8.1/snos/libexec/gcc/x86_64-suse-linux/:/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/:/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/
LIBRARY_PATH=/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/:/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/../../../../lib64/:/lib/../lib64/:/usr/lib/../lib64/:/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-fsyntax-only' '-v' '-shared-libgcc' '-mtune=generic'
'-march=x86-64'
...

[2] Clang/LLVM 3.4 configured with
'--prefix=/ptmp/sdvormwa/clang/3.4-gcc-toolchain --enable-optimized
--enable-targets=all --with-gcc-toolchain=/opt/gcc/4.8.1/snos
--enable-cxx11':
$ /ptmp/sdvormwa/clang/3.4-gcc-toolchain/bin/clang++ -fsyntax-only -v t.c

clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1
Selected GCC installation:
/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1
"/ptmp/sdvormwa/clang/3.4-gcc-toolchain/bin/clang" -cc1 -triple
x86_64-unknown-linux-gnu -fsyntax-only -disable-free -main-file-name t.c
-mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-target-linker-version 11 -v -resource-dir
/ptmp/sdvormwa/clang/3.4-gcc-toolchain/bin/../lib/clang/3.4
-internal-isystem /usr/local/include -internal-isystem
/ptmp/sdvormwa/clang/3.4-gcc-toolchain/bin/../lib/clang/3.4/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include
-fdeprecated-macro -fdebug-compilation-dir /home/sdvormwa -ferror-limit 19
-fmessage-length 157 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions
-fexceptions -fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp
-x c++ t.c
clang -cc1 version 3.4 based upon LLVM 3.4 default target
x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/ptmp/sdvormwa/clang/3.4-gcc-toolchain/bin/../lib/clang/3.4/include
/usr/include
End of search list.
...

[3] Clang/LLVM 3.4 configured with
'--prefix=/ptmp/sdvormwa/clang/3.4-cxx-include --enable-optimized
--enable-targets=all --enable-cxx11
--with-c-include-dirs=/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/include:/usr/include
--with-cxx-include-32bit-dir=32
--with-cxx-include-root=/opt/gcc/4.8.1/snos/include/g++
--with-cxx-include-arch=x86_64-suse-linux':

$ /ptmp/sdvormwa/clang/3.4-cxx-include/bin/clang++ -fsyntax-only -v t.c
clang version 3.4 (tags/RELEASE_34/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation:
/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1
Selected GCC installation:
/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior
is deprecated
"/ptmp/sdvormwa/clang/3.4-cxx-include/bin/clang" -cc1 -triple
x86_64-unknown-linux-gnu -fsyntax-only -disable-free -main-file-name t.c
-mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose
-mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64
-target-linker-version 11 -v -resource-dir
/ptmp/sdvormwa/clang/3.4-cxx-include/bin/../lib/clang/3.4 -internal-isystem
/usr/local/include -internal-isystem
/ptmp/sdvormwa/clang/3.4-cxx-include/bin/../lib/clang/3.4/include
-internal-externc-isystem
/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/include
-internal-externc-isystem /usr/include -fdeprecated-macro
-fdebug-compilation-dir /home/sdvormwa -ferror-limit 19 -fmessage-length
157 -mstackrealign -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-slp -x c++ t.c
clang -cc1 version 3.4 based upon LLVM 3.4 default target
x86_64-unknown-linux-gnu
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/ptmp/sdvormwa/clang/3.4-cxx-include/bin/../lib/clang/3.4/include
/opt/gcc/4.8.1/snos/lib/gcc/x86_64-suse-linux/4.8.1/include
/usr/include
End of search list.
...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-users/attachments/20140422/9022f389/attachment.html>


More information about the cfe-users mailing list