https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65255

            Bug ID: 65255
           Summary: std::thread does not work for cross compiling on ARM
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: yyc1992 at gmail dot com

Created attachment 34903
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34903&action=edit
PKGBUILD used to compile the cross compiling version of gcc

Duplicate of the problem reported in the comment of #42734. However, IMHO, that
bug was tracking a different issue and it should be better to open a new bug
for this one although the error message produced at runtime are very similar.

See attached file for the script used to compile the cross-compiler
(CHOST=x86_64-unknown-linux-gnu).

Minimum source that produces the problem
```
#include <thread>

int
main()
{
    std::thread([] {}).join();
    return 0;
}
```

When compiling with `arm-linux-gnueabihf-g++` on x86_64 and run on arm, it
throws an runtime error

```
pure virtual method called
terminate called without an active exception
Aborted (core dumped)
```

However, the error disappeared if run with gdb....

The same source works on the host machine (x86_64), with clang cross compiling
on ARM and with both clang and gcc natively compiled on ARM. Adding `-latomic`
as suggested in #42734 does not help either and is also not needed using the
native compiler on arm.

Command line option used to compile:
gcc cross compile:
    arm-linux-gnueabihf-g++ -pthread -std=c++14 -Os -Wall -Wextra thread.cpp -o
thread-arm
clang cross compile:
    clang++ --target=arm-linux-gnueabihf -pthread -std=c++14 -Os -Wall -Wextra
thread.cpp -o thread-arm_clang -I
/usr/arm-linux-gnueabihf/include/c++/4.9.2/arm-linux-gnueabihf
gcc native compile (on ARM):
    g++ -pthread -std=c++14 -Os -Wall -Wextra thread.cpp -o thread-arm_native
clang native compile (on ARM):
    clang++ -pthread -std=c++14 -Os -Wall -Wextra thread.cpp -o
thread-arm_native_clang

I'll try to upload the binaries (if they are allowed) or the output of `objdump
-S` (if I cannot upload binaries).

Reply via email to