For the August 11 snapshot
ry$ sysctl kern.version
kern.version=OpenBSD 6.7-current (GENERIC.MP) #22: Tue Aug 11 21:29:51
MDT 2020
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
ry$ egcc --version
egcc (GCC) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
ry$ cat mytls.c
__thread int a; int b; int main() { return a = b; }
ry$ egcc -o mytls -static mytls.c
ry$ ./mytls
Segmentation fault (core dumped)
ry$ grep mytls /var/log/messages
...[snip]...
Aug 13 15:44:40 ry /bsd: [mytls]36048/435394 pc=5951167a inside
27732e000-27733c000: bogus syscall
For the Jun 15 snapshot, all is well:
snap1$ sysctl kern.version
kern.version=OpenBSD 6.7-current (GENERIC.MP) #272: Mon Jun 15 01:54:58
MDT 2020
dera...@amd64.openbsd.org:/usr/src/sys/arch/amd64/compile/GENERIC.MP
snap1$ egcc --version
egcc (GCC) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is
NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
snap1$ cat mytls.c
__thread int a; int b; int main() { return a = b; }
snap1$ egcc -o mytls mytls.c -O2 -static
snap1$ mytls
snap1$
And the static image is different:
snap1$ ldd mytls
mytls:
Start End Type Open Ref GrpRef Name
00000fda3f626000 00000fda3f648000 dlib 1 0 0
/home/j/tls/mytls
on the older snapshot, and
ry$ ldd mytls
mytls:
Start End Type Open Ref GrpRef Name
000004822c606000 000004822c62a000 exe 1 0 0 mytls
0000048524b42000 0000048524b42000 ld.so 0 1 0
/usr/libexec/ld.so
on the newer snapshot.
These are two different machines, snap1 is Dell workstation,
E7400 Core 2 Duo, and ry is Ryzen 3700 8-core.
The example code is scooped from the gcc configure scripts. A gcc build
provokes this behaviour (using this code fragment) when building gcc for
these libraries:
libstdc++-v3
libobjc
libitm
libgomp (which is me adding OMP to gcc)
It seems to be only for TLS (thread-local-storage) tests, iiuc.
clang does not show this behaviour.
John