[cfe-dev] clang libc++ libcxxabi std::thread std::async

Ben Pope benpope81 at gmail.com
Tue May 29 09:14:49 PDT 2012


On Tuesday, May 29, 2012 09:36 PM, David Irvine wrote:
> I am curious if anyone has been able to get clang++ to run std::async in
> linux at all. If so the process would be great. I have tried TOT +
> libc++, with stdc++ and also the recently released binaries. In no
> configuration can I get this to work. As recently reported (not by me)
> in another mail (lost now), the following fails :
>
> #include <thread>
>     void f(){}
>     int main() {
>        std::thread t(f);
>        t.join();
>     }
>
> compiled with
>
> clang++ -std=c++11 thread.cc -o thread -pthread
>
> output
>
>   ./thread
> pure virtual method called
> terminate called without an active exception
> Aborted (core dumped)
>
> using
>
> clang++ --version
> clang version 3.1 (tags/RELEASE_31/final)
> Target: x86_64-unknown-linux-gnu
> Thread model: posix
>
> std::async seems to fail at runtime, I think this is due to abi issues
> but cannot be sure.

WorksForMe, but I had to modify your command line to link with libc++abi 
(as per your subject).  My versions of libc++ and libc++abi is ToT 
(157626) (is there a branch for libc++ and libc++abi for 3.1?)

$ clang++ -v
Debian clang version 3.1-3eudoxos1 (branches/release_31) (based on LLVM 3.1)
Target: x86_64-pc-linux-gnu
Thread model: posix
$ clang++ -std=c++11 -stdlib=libc++ thread_join.cpp -o thread -pthread 
-lc++abi
$ ./thread
$

Ben




More information about the cfe-dev mailing list