pkgsrc-Bugs archive

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

Re: pkg/60875 (open-simh: miscompiled by GCC on NetBSD/amd64)



Thank you very much for kind explanation!

On 2026/10/15 4:50, Rhialto wrote:
I tried to reproduce this in my own environment (NetBSD 11.0 amd64 with
gcc 12.5.0 from base) but did not succeed. (I attached a different disk
image which I had at hand, but that should make no difference, since it
is never read)

This does not prove much, because the upstream code relies on UB
(undefined behavior) especially in the VAX code. The most obvious one is
that it assumes that overflow of signed integers works the same as with
unsigned integers. They are relucant to change the code: a long time ago
it has been validated with proprietary DEC instruction set validation
tests, and those are no longer available.

Due to the UB, there is a large number of compiler options to try to
make it work anyway. It could be that in your compilation some of these
are missing (due to a different environment). If this is the case,
fixing that may fix the issue.

I also tried
https://cdn.netbsd.org/pub/pkgsrc/packages/NetBSD/x86_64/11.0_2026Q3/All/open-simh-4.1.0.20260413nb2.tgz
and it did not reproduce the issue either.

I tried that package, and I also couldn't reproduce the problem.
So, this may be my local settings, but I haven't figured out what
causes the problem...

I have compile commands like this:

gcc -std=gnu99 -U__STRICT_ANSI__  -fno-strict-overflow
     -finline-functions -fpredictive-commoning -fipa-cp-clone
     -fgcse-after-reload -fno-unsafe-loop-optimizations -O2 -DNDEBUG=1
     -finline-functions -fgcse-after-reload -fpredictive-commoning
     -fipa-cp-clone -fno-unsafe-loop-optimizations -fno-strict-overflow
     -DSIM_BUILD=Unsupported=include+lib  -DSIM_COMPILER="GCC Version:
     12.5.0" -DSIM_BUILD_TOOL=simh-makefile -I .  -D_GNU_SOURCE -DHAVE_PCRE_H
     -DHAVE_SEMAPHORE -DHAVE_SYS_IOCTL -DSIM_HAVE_DLOPEN=so -DHAVE_EDITLINE
     -DHAVE_UTIME -DHAVE_LIBPNG -DHAVE_ZLIB -DHAVE_GLOB -DHAVE_SHM_OPEN
     ./VAX/vax_cpu.c ./VAX/vax_cpu1.c ./VAX/vax_fpa.c ./VAX/vax_io.c
     ./VAX/vax_cis.c ./VAX/vax_octa.c  ./VAX/vax_cmode.c./VAX/vax_mmu.c
     ./VAX/vax_stddev.c ./VAX/vax_sysdev.c ./VAX/vax_sys.c  ./VAX/vax_syscm.c
     ./VAX/vax_syslist.c ./VAX/vax_vc.c ./VAX/vax_lk.c ./VAX/vax_vs.c
     ./VAX/vax_2681.c ./PDP11/pdp11_rl.c ./PDP11/pdp11_rq.c
     ./PDP11/pdp11_ts.c ./PDP11/pdp11_dz.c ./PDP11/pdp11_lp.c
     ./PDP11/pdp11_tq.c ./PDP11/pdp11_xq.c ./PDP11/pdp11_vh.c
     ./PDP11/pdp11_cr.c ./PDP11/pdp11_td.c ./PDP11/pdp11_io_lib.c
     ./PDP11/pdp11_dup.c ./scp.c ./sim_console.c ./sim_fio.c ./sim_timer.c
     ./sim_sock.c ./sim_tmxr.c ./sim_ether.c ./sim_tape.c ./sim_disk.c
     ./sim_serial.c ./sim_video.c ./sim_imd.c ./sim_card.c -DVM_VAX
     -DUSE_INT64 -DUSE_ADDR64 -DUSE_SIM_VIDEO -I ./VAX -I ./PDP11
     -DHAVE_PCAP_NETWORK -I/usr/include/pcap/ -DBPF_CONST_STRING
     -DUSE_NETWORK -DHAVE_VDE_NETWORK -DHAVE_TAP_NETWORK -DHAVE_BSDTUNTAP
     -Islirp -Islirp_glue -Islirp_glue/qemu -DHAVE_SLIRP_NETWORK
     -DUSE_SIMH_SLIRP_DEBUG slirp/*.c slirp_glue/*.c -DHAVE_LIBSDL
     -DUSE_SIM_VIDEO `sdl2-config --cflags` `sdl2-config --libs`
     -DUSE_READER_THREAD -DSIM_ASYNCH_IO -o BIN/vax  -Wl,-zrelro
     -L/usr/pkg/lib -Wl,-R/usr/pkg/lib -L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib
     -L/usr/lib -Wl,-R/usr/lib -lm -lrt -lpthread -lpcre -L/usr/pkg/lib/
     -ledit -ltermcap -lpng16 -lz -lpcap -lvdeplug -Wl,-R,/usr/pkg/lib/
     -L/usr/pkg/lib/

(You can ignore references to VDE or vdeplug; this refers to wip/vde2)

Compile command completely coincides except for VDE arguments.

Aside: the config line "load -r ka655x.bin" should not be needed, since
the same file is built-in. Simh will say "%SIM-INFO: Loading boot code
from internal ka655x.bin"

I tried both internal and external ka655x.bin, but result does
not changed.

It may be that adding -Wstrict-overflow=5 shows some useful diagnostic.

Ah, yes, disabling -fno-strict-overflow and adding -Wstrict-overflow=5
result in a lot of compiler warnings...

If this does not show any missing options, I have no objection if you
commit the changes you propose.

As I couldn't reproduce the problem with public build of 2026Q3 for
netbsd-11, I hesitate to commit my suggested changes...

I will change this PR to analyzed until when anyone who can reproduce
my problem.

-Olaf.

Thanks,
rin



Home | Main Index | Thread Index | Old Index