>Synopsis:      <synopsis of the problem (one line)>
>Category:      <PR category (one line)>
>Environment:
        System      : OpenBSD 7.7
        Details     : OpenBSD 7.7-current (GENERIC.MP) #35: Fri Aug  1 15:38:45 
MDT 2025
                         
[email protected]:/usr/src/sys/arch/sparc64/compile/GENERIC.MP

        Architecture: OpenBSD.sparc64
        Machine     : sparc64
>Description:
        I had discovered that our ld is a root cause why we can't use latest
        gcc on sparc64 platform.

        gcc can be bootstraped up to this commit:
        
https://gcc.gnu.org/cgit/gcc/commit/?id=9b884225bfc609606f9b169b021c4da93feba48e

        If I remove introduced condition

           if (!cmp_type || iv_precision > TYPE_PRECISION (cmp_type))

        I can build it for the next few commits, until it explode again as:

           Program terminated with signal SIGSEGV, Segmentation fault.
           #0  0x000000a31e861600 in 
_ZN4bidi7contextC1Ev+0xfffffffffb59ea0c@plt ()
           (gdb) disassemble
           Dump of assembler code for function 
_ZN4bidi7contextC1Ev+0xfffffffffb59ea0c@plt:
              0x000000a31e8615f0 <+0>:     mov  %o7, %g5
              0x000000a31e8615f4 <+4>:     call  0xa31e8615fc 
<_ZN4bidi7contextC1Ev+0xfffffffffb59ea0c@plt+12>
              0x000000a31e8615f8 <+8>:     nop 
              0x000000a31e8615fc <+12>:    ldx  [ %o7 + 0x65c ], %g1
           => 0x000000a31e861600 <+16>:    jmpl  %o7 + %g1, %g1
              0x000000a31e861604 <+20>:    mov  %g5, %o7
           End of assembler dump.
           (gdb) p/x $o7 + 0x65c
           $1 = 0xa31e861c50
           (gdb) x/x $o7 + 0x65c
           0xa31e861c50 <[email protected]>:    0xf9e379e0
           (gdb) p/x $o7 + $g1
           $2 = 0xf9e37a841e6ff100
           (gdb) x/x $o7 + $g1
           0xf9e37a841e6ff100:     Cannot access memory at address 
0xf9e37a841e6ff100
           (gdb) x/x $g1
           0xf9e379e0ffe9db0c:     Cannot access memory at address 
0xf9e379e0ffe9db0c
           (gdb) p/x $g1
           $3 = 0xf9e379e0ffe9db0c
           (gdb) 

        Different commits of gcc leads to a different place where it
        explodes, but it always a code like this.

        More of that, if I build the first compiler without PIE, by removing
        --enable-host-pie, it leads to a crash in ld:

           /usr/local/bootstrap-gcc/bin/g++ -std=c++14  -fno-PIE -c  
-DIN_GCC_FRONTEND -g -DIN_GCC    -fno-exceptions -fno-rtti 
-fasynchronous-unwind-tables -W -Wall -Wno-error=narrowing -Wwrite-strings 
-Wcast-qual -Wno-format -Wmissing-format-attribute -Wconditionally-supported 
-Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros 
-Wno-overlength-strings  -DHAVE_CONFIG_H -fno-PIE -I. -I. 
-I/usr/ports/pobj/gcc-15.2.0/gcc-15.2.0/gcc 
-I/usr/ports/pobj/gcc-15.2.0/gcc-15.2.0/gcc/. 
-I/usr/ports/pobj/gcc-15.2.0/gcc-15.2.0/gcc/../include  
-I/usr/ports/pobj/gcc-15.2.0/gcc-15.2.0/gcc/../libcpp/include 
-I/usr/ports/pobj/gcc-15.2.0/gcc-15.2.0/gcc/../libcody -I/usr/local/include  
-I/usr/ports/pobj/gcc-15.2.0/gcc-15.2.0/gcc/../libdecnumber 
-I/usr/ports/pobj/gcc-15.2.0/gcc-15.2.0/gcc/../libdecnumber/dpd 
-I../libdecnumber -I/usr/ports/pobj/gcc-15.2.0/gcc-15.2.0/gcc/../libbacktrace   
-o cc1-checksum.o -MT cc1-checksum.o -MMD -MP -MF ./.deps/cc1-checksum.TPo 
cc1-checksum.cc
           /usr/local/bootstrap-gcc/bin/g++ -std=c++14 -no-pie   -g -DIN_GCC    
-fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall 
-Wno-error=narrowing -Wwrite-strings -Wcast-qual -Wno-format 
-Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual 
-pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings  
-DHAVE_CONFIG_H -no-pie -static-libstdc++ -static-libgcc  -o cc1 c/c-lang.o 
c-family/stub-objc.o attribs.o c/c-errors.o c/c-decl.o c/c-typeck.o 
c/c-convert.o c/c-aux-info.o c/c-objc-common.o c/c-parser.o c/c-fold.o 
c/gimple-parser.o c-family/c-common.o c-family/c-cppbuiltin.o c-family/c-dump.o 
c-family/c-format.o c-family/c-gimplify.o c-family/c-indentation.o 
c-family/c-lex.o c-family/c-omp.o c-family/c-opts.o c-family/c-pch.o 
c-family/c-ppoutput.o c-family/c-pragma.o c-family/c-pretty-print.o 
c-family/c-semantics.o c-family/c-ada-spec.o c-family/c-ubsan.o 
c-family/known-headers.o c-family/c-attribs.o c-family/c-warn.o 
c-family/c-spellcheck.o c-fa
 mily/c-type-mismatch.o sparc-c.o default-c.o \
             cc1-checksum.o simple-diagnostic-path.o lazy-diagnostic-path.o 
libbackend.a main.o libcommon-target.a libcommon.a ../libcpp/libcpp.a 
../libdecnumber/libdecnumber.a libcommon.a ../libcpp/libcpp.a   
../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a 
../libdecnumber/libdecnumber.a   -L/usr/local/lib -lmpc -lmpfr -lgmp -rdynamic  
-lz 
           collect2: fatal error: ld terminated with signal 11 [Segmentation 
fault], core dumped

        with absolutle useless stacktrace inside core:

           Core was generated by `ld.bfd'.
           Program terminated with signal SIGSEGV, Segmentation fault.
           #0  0x00000099a352bb48 in bfd_putb64 ()
           (gdb) bt
           #0  0x00000099a352bb48 in bfd_putb64 ()
           #1  0x00000099a3544fb8 in bfd_elf64_swap_reloca_out ()
           #2  0x00000099a353e644 in ?? ()
           Backtrace stopped: previous frame identical to this frame (corrupt 
stack?)
           (gdb)

        I had tried to use clang-19, both from /usr/bin/clang and ports with
        the same result. I've tried to use gas with the same result.
>How-To-Repeat:
        Try to build lang/gcc/15 from ports.
>Fix:
        No idea

dmesg:
OpenBSD 7.7-current (GENERIC.MP) #35: Fri Aug  1 15:38:45 MDT 2025
    [email protected]:/usr/src/sys/arch/sparc64/compile/GENERIC.MP
real mem = 8053063680 (7680MB)
avail mem = 7882203136 (7517MB)
random: good seed from bootblocks
mpath0 at root
scsibus0 at mpath0: 256 targets
mainbus0 at root: SPARC T4-1
cpu0 at mainbus0: SPARC-T4 (rev 0.0) @ 2847.862 MHz
cpu1 at mainbus0: SPARC-T4 (rev 0.0) @ 2847.862 MHz
cpu2 at mainbus0: SPARC-T4 (rev 0.0) @ 2847.862 MHz
cpu3 at mainbus0: SPARC-T4 (rev 0.0) @ 2847.862 MHz
cpu4 at mainbus0: SPARC-T4 (rev 0.0) @ 2847.862 MHz
cpu5 at mainbus0: SPARC-T4 (rev 0.0) @ 2847.862 MHz
cpu6 at mainbus0: SPARC-T4 (rev 0.0) @ 2847.862 MHz
cpu7 at mainbus0: SPARC-T4 (rev 0.0) @ 2847.862 MHz
"reboot-memory" at mainbus0 not configured
vbus0 at mainbus0
"flashprom" at vbus0 not configured
vrng0 at vbus0
cbus0 at vbus0
vdsk0 at cbus0 chan 0x2: ivec 0x4, 0x5
scsibus1 at vdsk0: 1 targets
sd0 at scsibus1 targ 0 lun 0: <SUN, Virtual Disk, 1.1>
sd0: 3MB, 512 bytes/sector, 6400 sectors
vnet0 at cbus0 chan 0x3: ivec 0x6, 0x7, address 00:14:4f:f8:f2:08
vcons0 at vbus0: ivec 0x8011: console
vrtc0 at vbus0
vpci0 at mainbus0: bus 0 to 255, dvma map 80000000-ffffffff
pci0 at vpci0
ppb0 at pci0 dev 2 function 0 "Sun SDIO PCIE" rev 0x01
pci1 at ppb0 bus 7
ppb1 at pci1 dev 0 function 0 "Sun SDIO PCIE" rev 0x01
pci2 at ppb1 bus 8
ppb2 at pci2 dev 4 function 0 "Sun SDIO PCIE" rev 0x01
pci3 at ppb2 bus 11
mpii0 at pci3 dev 0 function 0 "Symbios Logic SAS2008" rev 0x03: msi
mpii0: RF On-Board, firmware 9.0.0.0 IR, MPI 2.0
scsibus2 at mpii0: 834 targets
ppb3 at pci2 dev 7 function 0 "Sun SDIO PCIE" rev 0x01
pci4 at ppb3 bus 13
em0 at pci4 dev 0 function 0 "Intel 82576" rev 0x01: msi, address 
00:10:e0:10:2e:5a
em1 at pci4 dev 0 function 1 "Intel 82576" rev 0x01: msi, address 
00:10:e0:10:2e:5b
sd1 at scsibus2 targ 2 lun 0: <HITACHI, H109030SESUN300G, A31A> 
naa.5000cca0220f386c
sd1: 286102MB, 512 bytes/sector, 585937500 sectors
vscsi0 at root
scsibus3 at vscsi0: 256 targets
softraid0 at root
scsibus4 at softraid0: 256 targets
bootpath: /pci@400,0/pci@2,0/pci@0,0/pci@4,0/scsi@0,0/disk@5000cca0220f386d,0
root on sd1a (d5d2548c40f337c0.a) swap on sd1b dump on sd1b
cd0 at scsibus2 targ 8 lun 0: <TEAC, DV-W28SS-V, 1.0B> removable
sd2 at scsibus2 targ 3 lun 0: <HITACHI, H109030SESUN300G, A31A> 
naa.5000cca0221ac484
sd2: 286102MB, 512 bytes/sector, 585937500 sectors

usbdevs:
usbdevs: no USB controllers found

-- 
wbr, Kirill

Reply via email to