NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

toolchain/60048: Illegal instruction when cross-compiling



>Number:         60048
>Category:       toolchain
>Synopsis:       Illegal instruction when cross-compiling
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 01 14:30:00 +0000 2026
>Originator:     Benny Siegert
>Release:        NetBSD 11.99.5
>Organization:
The NetBSD Foundation
>Environment:
System: NetBSD xxx 11.0_BETA NetBSD 11.0_BETA (GENERIC) #0: Mon Oct 20 14:11:07 UTC 2025  mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
When cross-compiling on a NetBSD/amd64 machine for a riscv64 target, building a kernel fails. The failure is always in a floating-point multiplication in a const. There are several of these in the kernel, so with -j higher than 1, you sometimes hit one or the other. For example this (with -j 1):

#   compile  kern/rngtest.o
/usr/src/obj/tooldir.NetBSD-11.0_BETA-amd64/bin/riscv64--netbsd-gcc -mcmodel=medany -ffreestanding -fno-zero-initialized-in-bss  -fno-delete-null-pointer-checks   -O2 -fno-omit-frame-pointer  -fstack-usage -Wstack-usage=3584  -fno-strict-aliasing -fno-common     -std=gnu11   -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition -Wswitch -Wshadow -Wcast-qual -Wwrite-strings -Wno-unreachable-code -Wno-pointer-sign -Wno-attributes -Wno-type-limits -Wno-sign-compare    -Wno-address-of-packed-member  -Walloca      --sysroot=/usr/src/obj/destdir.riscv -I/usr/src/sys/lib/libkern/arch/riscv --sysroot=/usr/src/obj/destdir.riscv -Driscv -I../../. -I/usr/src/sys/external/bsd/libnv/dist -I/usr/src/sys/external/bsd/acpica/dist -I/usr/src/sys/../common/lib/libx86emu -I/usr/src/sys/../common/lib/libc/misc -I/usr/src/sys/../common/include -I/usr/src/sys/arch -I/usr/src/sys -nostdinc -DCOMPAT_UTILS -D__HAVE_PCI_CONF_HOOK -DFPE 
 -DCOMPAT_44 -DDIAGNOSTIC -DDEBUG -D_KERNEL -D_KERNEL_OPT -std=gnu11 -I/usr/src/sys/lib/libkern/../../../common/lib/libc/quad -I/usr/src/sys/lib/libkern/../../../common/lib/libc/string -I/usr/src/sys/lib/libkern/../../../common/lib/libc/arch/riscv/string -I/usr/src/sys/lib/libkern/../../../common/lib/libc/arch/riscv/atomic -I/usr/src/sys/lib/libkern/../../../common/lib/libc/hash/sha3 -I/usr/src/sys/external/bsd/libfdt/dist -I/usr/src/sys/external/bsd/libnv/dist  -I/usr/src/sys/lib/libkern/../../../common/lib/libc/quad -I/usr/src/sys/lib/libkern/../../../common/lib/libc/string -I/usr/src/sys/lib/libkern/../../../common/lib/libc/arch/riscv/string -I/usr/src/sys/lib/libkern/../../../common/lib/libc/arch/riscv/atomic -I/usr/src/sys/lib/libkern/../../../common/lib/libc/hash/sha3 -I/usr/src/sys/lib/libkern/../../../common/include -I/usr/src/sys/lib/libkern/../../../common/include/libc -I/usr/src/sys/lib/libkern/../../../common/libc/hash/sha3  -c    /usr/src/sys/lib/libkern/rngtest.c -o rng
 test.o
/usr/src/sys/lib/libkern/rngtest.c:169:1: internal compiler error: Illegal instruction
               169 | const long long minpoke = (MINPOKE * PRECISION);
                   | ^~~~~
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <http://www.NetBSD.org/support/send-pr.html> for instructions.

*** Failed target:  rngtest.o

When run with -j 4, another one of these bombs first:

/usr/src/sys/kern/kern_synch.c:1123:1: internal compiler error: Illegal instruction
 1123 | const fixpt_t ccpu = 0.95122942450071400909 * FSCALE;
      | ^~~~~
Please submit a full bug report, with preprocessed source (by using -freport-bug).
See <http://www.NetBSD.org/support/send-pr.html> for instructions.

*** Failed target: kern_synch.o
*** In directory: /usr/obj/sys/arch/riscv/compile/GENERIC64


I have seen the same issues when compiling for aarch64 (MACHINE=evbarm64) from amd64.
>How-To-Repeat:
On a fresh checkout of src:

$ ./build.sh -j 4 -N 1 -U -m riscv -a riscv64 tools kernel=GENERIC64
>Fix:
I would love to see a fix! This is supposed to work, no?



Home | Main Index | Thread Index | Old Index