[OE-core] Yocto development with C++11 threads and gcc

Khem Raj raj.khem at gmail.com
Wed Aug 13 21:18:38 UTC 2014


On Mon, Aug 11, 2014 at 12:02 PM, Peter A. Bigot <pab at pabigot.com> wrote:
> The program below built on the target with the MACHINE=beaglebone gcc-4.9.1
> compiler from Yocto/OpenEmbedded poky master produces this error:
>
> beaglebone[52]$ g++ -std=c++1y -pthread test.cc && ./a.out
> starting
> joining
> pure virtual method called
> terminate called without an active exception
> Aborted (core dumped)
>
> When the program is recompiled with the defines for
> __GCC_HAVE_SYNC_COMPARE_AND_SWAP_X enabled as suggested at
> https://groups.google.com/d/msg/automatak-dnp3/Jisp_zGhd5I/ck_Cj6nO8joJ it
> works:
>
> beaglebone[53]$ g++ -std=c++1y -pthread test.cc && ./a.out
> starting
> joining
> doit
> done
>
> Preliminary analysis confirms that the built-ins for those defines are not
> being added by the compiler because it thinks the target doesn't support
> those operations.  Nonetheless, it doesn't use the substitutes that are
> obviously available.
>
> Can anybody recall anything about the way GCC is built under OE that would
> explain this?

Can you add -mcpu=cortex-a8 to your cmdline and see if it solves the problem ?

>
> Peter
>
> /* g++ -std=c++1y -pthread test.cc && ./a.out */
> #if 0
> #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1
> #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2
> #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4
> #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
> #endif
>
> #include <iostream>
> #include <thread>
>
> void
> doit ()
> {
>   std::cerr << "doit\n";
> }
>
> int main (int argc,
>           char * argv [])
> {
>   std::cerr << "starting\n";
>   std::thread thr{doit};
>   std::cerr << "joining\n";
>   thr.join();
>   std::cerr << "done\n";
>   return 0;
> }
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core at lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core



More information about the Openembedded-core mailing list