Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: OpenBSD/spac64 by LLVM toolchain
To:
tech@openbsd.org
Date:
Wed, 8 Jul 2026 10:25:30 +0200

Download raw body.

Thread
On Sun, Jul 05, 2026 at 11:56:06AM +0200, Kirill A. Korinsky wrote:
> tech@,
> 
> Here a diff which allows me to build OpenBSD/spac64 by llvm toolchain.
> 
> My test cycle from clean snapshot was:
> 
> 1. Rebuild clang / lld
> 
> cd /usr/src/gnu/usr.bin/clang
> doas make clean
> doas -u build make CC=clang CXX=clang++ -j8
> doas make install
> 
> 2. Rebuild clang / lld as system compiler
> 
> cd /usr/src/share/mk
> doas make install
> cd /usr/src/gnu/usr.bin/clang
> doas make clean
> doas -u build make CC=clang CXX=clang++ LD=ld.lld -j8
> doas make install
> 
> 3. Rebuild the system itself
> 
> cd /usr/src
> doas make build -j8

This make build step (which does include an install step) does not
complete on my M3k since static binaries segfault in _start(). Once ksh
is installed and linked to sh, the system is pretty much broken.

-static -no-pie binaries work.

Here's a simple debug session if it helps. I can leave the machine in
this state for a bit in case someone has a suggestion, but I would like
to do some other testing on it later today.

$ cc --version; ld --version
OpenBSD clang version 22.1.6
Target: sparc64-unknown-openbsd7.9
Thread model: posix
InstalledDir: /usr/bin
LLD 22.1.6 (compatible with GNU linkers)
$ cat test.c
int main(void) { return 27; }
$ cc -g -o test-dynamic test.c
$ ./test-dynamic; echo $?
27
$ cc -g -static -o test-static test.c
$ ktrace ./test-static
Segmentation fault (core dumped)
$ kdump
   825 ktrace   RET   ktrace 0
   825 ktrace   CALL  execve(0xfffffed2694a97df,0xfffffed2694a9670,0xfffffed2694a9680)
   825 ktrace   NAMI  "./test-static"
   825 ktrace   ARGS
	[0] = "./test-static"
   825 test-static RET   execve JUSTRETURN
   825 test-static PSIG  SIGSEGV SIG_DFL code=SEGV_ACCERR addr=0x18ad1077d0 trapno=1
   825 test-static NAMI  "test-static.core"
$ egdb -q test-static
Reading symbols from test-static...
(gdb) start
Temporary breakpoint 1 at 0x107d84: file test.c, line 1.
Starting program: /tmp/test-static

Program received signal SIGSEGV, Segmentation fault.
0x000000d5124077d4 in _start ()
(gdb) disas
Dump of assembler code for function _start:
   0x000000d5124077b4 <+0>:	mov  %g0, %fp
   0x000000d5124077b8 <+4>:	sub  %sp, 0xb0, %sp
   0x000000d5124077bc <+8>:	add  %sp, 0x8af, %l3
   0x000000d5124077c0 <+12>:	add  %l3, 0x80, %o0
   0x000000d5124077c4 <+16>:	mov  %o0, %l0
   0x000000d5124077c8 <+20>:	call  0xd5124077d4 <_start+32>
   0x000000d5124077cc <+24>:	nop
   0x000000d5124077d0 <+28>:	call  0xd5125247e0
=> 0x000000d5124077d4 <+32>:	ld  [ %o7 + 8 ], %o2
   0x000000d5124077d8 <+36>:	sll  %o2, 2, %o2
   0x000000d5124077dc <+40>:	sra  %o2, 0, %o2
   0x000000d5124077e0 <+44>:	add  %o2, %o7, %o2
   0x000000d5124077e4 <+48>:	call  0xd512407800 <_dl_boot_bind>
   0x000000d5124077e8 <+52>:	mov  %l3, %o1
   0x000000d5124077ec <+56>:	add  %sp, 0xb0, %sp
   0x000000d5124077f0 <+60>:	add  %sp, 0x87f, %o0
   0x000000d5124077f4 <+64>:	b  %icc, 0xd512407a4c
   0x000000d5124077f8 <+68>:	mov  %g0, %o1
End of assembler dump.
(gdb) info registers
g0             0x0                 0
g1             0x0                 0
g2             0x0                 0
g3             0x0                 0
g4             0x0                 0
g5             0x0                 0
g6             0x0                 0
g7             0x0                 0
o0             0xfffffe562b3fc6c0  -1828930468160
o1             0x0                 0
o2             0x0                 0
o3             0x0                 0
o4             0x0                 0
o5             0x0                 0
sp             0xfffffe562b3fbd91  0xfffffe562b3fbd91
o7             0xd5124077c8        915134248904
l0             0xfffffe562b3fc6c0  -1828930468160
l1             0x0                 0
l2             0x0                 0
l3             0xfffffe562b3fc640  -1828930468288
l4             0x0                 0
l5             0x0                 0
l6             0x0                 0
l7             0x0                 0
i0             0x0                 0
i1             0x0                 0
i2             0x0                 0
i3             0x0                 0
i4             0x0                 0
i5             0x0                 0
fp             0x0                 0x0
i7             0x6a19207ccd54d741  7645177562831050561
pc             0xd5124077d4        0xd5124077d4 <_start+32>
npc            0xd5124077d8        0xd5124077d8 <_start+36>
state          0x82000201          2181038593
fsr            0x0                 [ ]
fprs           <unavailable>
y              0x0                 0
cwp            0x1                 1
pstate         0x2                 [ IE ]
asi            0x82                130
ccr            0x0                 [ ]
(gdb)