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

--- Comment #7 from Andrea Bocci <fwyzard at gmail dot com> ---
The same test program will fail in the same way, if compiled with -flto, even
if -pthread is used:

$ g++-9 -Wall -Wextra -std=c++17 callonce.cpp -pthread
$ ./a.out

but

$ g++-9 -Wall -Wextra -std=c++17 callonce.cpp -pthread -flto
$ ./a.out 
terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error -1
Aborted (core dumped)

Possibly because the LTO pass discards the dependency on libpthread.so:

$ ldd a.out 
        linux-vdso.so.1 (0x00007ffc09b46000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f420535e000)
        libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
(0x00007f4204f7e000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f4205952000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4204be0000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1
(0x00007f42049c8000)

Reply via email to