You are not logged in.
main.cpp
#include <iostream>
int main()
{
return 0;
}This program doesn't compile with the latest clang compiler.
clang++ output:
$ clang++ -c main.cpp
In file included from main.cpp:1:
In file included from /usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/iostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ostream:39:
In file included from /usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ios:42:
In file included from /usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/bits/ios_base.h:40:
/usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h:48:45: error: use of undeclared identifier '__ATOMIC_ACQ_REL'
{ return __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
^
/usr/bin/../lib/gcc/x86_64-unknown-linux-gnu/4.7.0/../../../../include/c++/4.7.0/ext/atomicity.h:52:38: error: use of undeclared identifier '__ATOMIC_ACQ_REL'
{ __atomic_fetch_add(__mem, __val, __ATOMIC_ACQ_REL); }
^
2 errors generated.It seems like clang pulls in include files from gcc but can't recognize some of the built-ins used in there (probably newly introduced in 4.7?).
I would guess that downgrading gcc would solve the problem but that seems like a rather hacky workaround.
Does clang have to use the gcc files? Does it not have its own files? I know nowhere near enough about this to solve it on my own.
Thank you for your time.
Additional information:
$ clang++ -v
clang version 3.0 (tags/RELEASE_30/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix$ g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/src/gcc-4.7-20120505/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --disable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release
Thread model: posix
gcc version 4.7.0 20120505 (prerelease) (GCC) Last edited by eguez (2012-05-14 12:58:53)
Offline
You don't have to use gcc files. You can also use libc++ (Available from the AUR here). Make sure to use the "-stdlib=libc++" option when compiling with clang++. The only problem is that you won't be able to link against any libraries that were compiled with gcc's libstdc++, so unless you're making simple console applications, you will have to recompile most of your system
.
But clang 3.1 will support atomic operations, so gcc's libstdc++ should work properly after that. ![]()
You can also try getting clang from svn (https://aur.archlinux.org/packages.php?ID=20222).
Offline
Installing clang-svn from the AUR solved the problem (though it took hours to compile and almost overheated my laptop). I'm gonna keep using it until clang 3.1 comes out.
Thank you @Terra-byte!
Last edited by eguez (2012-05-14 12:58:19)
Offline