open-simh / simh

The Open SIMH simulators package
https://opensimh.org/
Other
473 stars 89 forks source link

VAX emulators, compiled with gcc 10.4.0, fail the diagnostics EHKAA #177

Closed Rhialto closed 1 year ago

Rhialto commented 1 year ago

MicroVAX 3900 simulator Open SIMH V4.1-0 Current simh git commit id: 5e01c051 Build: Unsupported=include+lib sim> show version MicroVAX 3900 simulator Open SIMH V4.1-0 Current Simulator Framework Capabilities: 64b data 64b addresses Threaded Ethernet Packet transports:PCAP:TAP:NAT:UDP Idle/Throttling support is available Virtual Hard Disk (VHD) support Asynchronous I/O support (Lock free asynchronous event queue) Asynchronous Clock support FrontPanel API Version 12 Host Platform: Compiler: GCC 10.4.0 Simulator Compiled as C arch: x64 (Release Build) on Feb 7 2023 at 22:27:37 Build Tool: simh-makefile Memory Access: Little Endian Memory Pointer Size: 64 bits Large File (>2GB) support SDL Video support: SDL Version 2.26.1, PNG Version 1.6.39, zlib: 1.2.10 PCRE RegEx (Version 8.45 2021-06-15) support for EXPECT commands OS clock resolution: 1ms Time taken by msleep(1): 20ms Ethernet packet info: libpcap version 1.9.0-PRE-GIT OS: NetBSD murthe.falu.nl 9.3 NetBSD 9.3 (MAXLWP8192) #0: Sat Aug 6 22:25:06 CEST 2022 rhialto@murthe.falu.nl:/mnt/scratch/scratch/NetBSD/NetBSD-9.3/source/sets/x/usr/src/sys/arch/amd64/compile/MAXLWP8192 amd64 tar tool: bsdtar 3.4.0 - libarchive 3.4.0 zlib/1.2.10 liblzma/5.2.4 bz2lib/1.0.8 curl tool: curl 7.87.0 (x86_64--netbsd) libcurl/7.87.0 OpenSSL/1.1.1k zlib/1.2.10 libidn2/2.3.4 nghttp2/1.51.0 simh git commit id: 5e01c051 simh git commit time: 2023-02-03T22:03:45-08:00 Build: Unsupported=include+lib

- #### how you built the simulator or that you're using prebuilt binaries

murthe.10:.../pkgsrc-head/emulators/open-simh$ make test => Bootstrap dependency digest>=20211023: found digest-20220214 ===> _pkgformat-check-vulnerable [open-simh-4.1.0.20230207] ===> Checking for vulnerabilities in open-simh-4.1.0.20230207 ===> test-message [open-simh-4.1.0.20230207] ===> Testing for open-simh-4.1.0.20230207 cd /tmpfs/emulators/open-simh/work.x86_64/simh-5e01c0516b14d16fa4e780dff13077bed76aa38a && /usr/bin/env USETOOLS=no INCLUDES=/usr/pkg/include:\ /usr/pkg/include/SDL2:\ /usr/pkg/include:\ /usr/include/pcap:\ /usr/pkg/include/pcre:\ /usr/pkg/include:\ /usr/include LIBRARIES=/usr/pkg/lib:\ /usr/pkg/lib:\ /usr/pkg/lib:\ /usr/lib:\ /usr/pkg/lib:\ /usr/pkg/lib:\ /usr/lib GCC=gcc OS_LDFLAGS=\ \ \ -L/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0\ -Wl,-R/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0\ -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 FONTPATH=/usr/pkg/share/fonts/X11/TTF WARNINGS=ALLOWED PTHREAD_CFLAGS=\ -pthread\ PTHREAD_LDFLAGS=\ -pthread PTHREAD_LIBS= PTHREADBASE=/usr DL_CFLAGS=\ -pthread\ DL_LDFLAGS=\ -pthread DL_LIBS= CC=gcc CFLAGS=-O2\ -fPIC\ -D_FORTIFY_SOURCE=2\ -I/usr/pkg/include\ -I/usr/pkg/include/SDL2\ -I/usr/X11R7/include\ -I/usr/pkg/include/libdrm\ -I/usr/include\ -I/usr/pkg/include/freetype2\ -I/usr/pkg/include/readline CPPFLAGS=-I/usr/pkg/include\ -I/usr/pkg/include/SDL2\ -I/usr/X11R7/include\ -I/usr/pkg/include/libdrm\ -I/usr/include\ -I/usr/pkg/include/freetype2\ -I/usr/pkg/include/readline CXX=c++ CXXFLAGS=-O2\ -fPIC\ -D_FORTIFY_SOURCE=2\ -I/usr/pkg/include\ -I/usr/pkg/include/SDL2\ -I/usr/X11R7/include\ -I/usr/pkg/include/libdrm\ -I/usr/include\ -I/usr/pkg/include/freetype2\ -I/usr/pkg/include/readline COMPILER_RPATH_FLAG=-Wl,-R F77=gfortran FC=gfortran FFLAGS=-O LANG=C LC_ALL=C LC_COLLATE=C LC_CTYPE=C LC_MESSAGES=C LC_MONETARY=C LC_NUMERIC=C LC_TIME=C LDFLAGS=-L/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0\ -Wl,-R/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0\ -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 LINKER_RPATH_FLAG=-R PATH=/tmpfs/emulators/open-simh/work.x86_64/.cwrapper/bin:/tmpfs/emulators/open-simh/work.x86_64/.buildlink/bin:/tmpfs/emulators/open-simh/work.x86_64/.gcc/bin:/tmpfs/emulators/open-simh/work.x86_64/.tools/bin:/usr/pkg/bin:/home/rhialto/bin:/usr/pkg/bin:/usr/pkg/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/X11R7/bin:/usr/games:/usr/pkg/bin:/usr/X11R7/bin PREFIX=/usr/pkg MAKELEVEL=0 CONFIG_SITE= PKG_SYSCONFDIR=/usr/pkg/etc CXXCPP=cpp HOME=/tmpfs/emulators/open-simh/work.x86_64/.home CWRAPPERS_CONFIG_DIR=/tmpfs/emulators/open-simh/work.x86_64/.cwrapper/config CPP=cpp LOCALBASE=/usr/pkg X11BASE=/usr/X11R7 PKGMANDIR=man PKGINFODIR=info PKGGNUDIR=gnu/ MAKECONF=/dev/null OBJECT_FMT=ELF USETOOLS=no BSD_INSTALL_PROGRAM=/usr/bin/install\ -c\ -s\ -o\ rhialto\ -g\ users\ -m\ 755 BSD_INSTALL_SCRIPT=/usr/bin/install\ -c\ -o\ rhialto\ -g\ users\ -m\ 755 BSD_INSTALL_LIB=/usr/bin/install\ -c\ -o\ rhialto\ -g\ users\ -m\ 755 BSD_INSTALL_DATA=/usr/bin/install\ -c\ -o\ rhialto\ -g\ users\ -m\ 644 BSD_INSTALL_MAN=/usr/bin/install\ -c\ -o\ rhialto\ -g\ users\ -m\ 644 BSD_INSTALL=/usr/bin/install BSD_INSTALL_PROGRAM_DIR=/usr/bin/install\ -d\ -o\ rhialto\ -g\ users\ -m\ 755 BSD_INSTALL_SCRIPT_DIR=/usr/bin/install\ -d\ -o\ rhialto\ -g\ users\ -m\ 755 BSD_INSTALL_LIB_DIR=/usr/bin/install\ -d\ -o\ rhialto\ -g\ users\ -m\ 755 BSD_INSTALL_DATA_DIR=/usr/bin/install\ -d\ -o\ rhialto\ -g\ users\ -m\ 755 BSD_INSTALL_MAN_DIR=/usr/bin/install\ -d\ -o\ rhialto\ -g\ users\ -m\ 755 BSD_INSTALL_GAME=/usr/bin/install\ -c\ -s\ -o\ rhialto\ -g\ users\ -m\ 2555 BSD_INSTALL_GAME_DATA=/usr/bin/install\ -c\ -o\ rhialto\ -g\ users\ -m\ 664 BSD_INSTALL_GAME_DIR=/usr/bin/install\ -d\ -o\ rhialto\ -g\ users\ -m\ 775 INSTALL_INFO= MAKEINFO=/tmpfs/emulators/open-simh/work.x86_64/.tools/bin/makeinfo FLEX= BISON= ITSTOOL=/tmpfs/emulators/open-simh/work.x86_64/.tools/bin/itstool GDBUS_CODEGEN=/tmpfs/emulators/open-simh/work.x86_64/.tools/bin/gdbus-codegen PKG_CONFIG=/tmpfs/emulators/open-simh/work.x86_64/.tools/bin/pkg-config PKG_CONFIG_LIBDIR=/tmpfs/emulators/open-simh/work.x86_64/.buildlink/lib/pkgconfig:/tmpfs/emulators/open-simh/work.x86_64/.buildlink/share/pkgconfig PKG_CONFIG_LOG=/tmpfs/emulators/open-simh/work.x86_64/.pkg-config.log PKG_CONFIG_PATH= CWRAPPERS_CONFIG_DIR=/tmpfs/emulators/open-simh/work.x86_64/.cwrapper/config /usr/pkg/bin/gmake -f makefile all Warning Warning Unsupported build with INCLUDES defined as: /usr/pkg/include: /usr/pkg/include/SDL2: /usr/pkg/include: /usr/include/pcap: /usr/pkg/include/pcre: /usr/pkg/include: /usr/include Warning Unsupported build with LIBRARIES defined as: /usr/pkg/lib: /usr/pkg/lib: /usr/pkg/lib: /usr/lib: /usr/pkg/lib: /usr/pkg/lib: /usr/lib Warning lib paths are: /usr/pkg/lib /usr/pkg/lib /usr/pkg/lib /usr/lib /usr/pkg/lib /usr/pkg/lib /usr/lib include paths are: /usr/pkg/include /usr/pkg/include/SDL2 /usr/pkg/include /usr/include/pcap /usr/pkg/include/pcre /usr/pkg/include /usr/include using libm: /usr/lib/libm.so using librt: /usr/lib/librt.so using libpthread: /usr/lib/libpthread.so /usr/include/pthread.h using libpcre: /usr/pkg/lib/libpcre.so /usr/pkg/include/pcre.h using semaphore: /usr/include/semaphore.h using libdl: /usr/include/dlfcn.h using libedit: /usr/pkg/include/editline/readline.h using libpng: /usr/pkg/include/png.h using zlib: /usr/lib/libz.so /usr/include/zlib.h using mman: /usr/include/sys/mman.h using libSDL2: /usr/pkg/include/SDL2/SDL.h font paths are: /usr/pkg/share/fonts/X11/TTF/ font names are: DejaVuSans.ttf LucidaSansRegular.ttf FreeSans.ttf AppleGothic.ttf tahoma.ttf using libSDL2_ttf: /usr/pkg/lib/libSDL2_ttf.so /usr/pkg/include/SDL2/SDL_ttf.h


using libpcap: /usr/include/pcap/pcap.h


all Simulators being built with: - compiler optimizations and no debugging support. GCC Version: 10.4.0. - dynamic networking support using NetBSD provided libpcap components. - Local LAN packet transports: PCAP TAP NAT(SLiRP) - video capabilities provided by libSDL2 (Simple Directmedia Layer). - Per simulator tests will be run.


gcc -std=gnu99 -U__STRICT_ANSI__ -O2 -DSIM_BUILD=Unsupported=include+lib -DSIM_COMPILER="GCC Version: 10.4.0" -DSIM_BUILD_TOOL=simh-makefile -I . -D_GNU_SOURCE -DUSE_READER_THREAD -DSIM_ASYNCH_IO -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_cis.c ./VAX/vax_octa.c ./VAX/vax_cmode.c ./VAX/vax_mmu.c ./VAX/vax_sys.c ./VAX/vax_syscm.c ./VAX/vax_watch.c ./VAX/vax_nar.c ./VAX/vax4xx_stddev.c ./VAX/vax420_sysdev.c ./VAX/vax420_syslist.c ./VAX/vax4xx_dz.c ./VAX/vax4xx_rd.c ./VAX/vax4xx_rz80.c ./VAX/vax_xs.c ./VAX/vax4xx_va.c ./VAX/vax4xx_vc.c ./VAX/vax4xx_ve.c ./VAX/vax_lk.c ./VAX/vax_vs.c ./VAX/vax_gpx.c ./sim_scsi.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 -DVAX_420 -DUSE_INT64 -DUSE_ADDR64 -DUSE_SIM_VIDEO -I ./VAX -I ./PDP11 -DHAVE_PCAP_NETWORK -I/usr/include/pcap/ -DBPF_CONST_STRING -DUSE_SHARED -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 -DVAX_41A -o BIN/microvax3100 -L/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0 -Wl,-R/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0 -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 In file included from ./sim_ether.c:1023: /usr/include/pcap/pcap.h:962: warning: "INVALID_SOCKET" redefined 962 #define INVALID_SOCKET -1
In file included from ./sim_ether.h:70, from ./sim_ether.c:373: ./sim_sock.h:93: note: this is the location of the previous definition 93 #define INVALID_SOCKET ((SOCKET)-1)

BIN/microvax3100 RegisterSanityCheck /tmpfs/emulators/open-simh/work.x86_64/simh-5e01c0516b14d16fa4e780dff13077bed76aa38a/VAX/tests/vax-diag_test.ini </dev/null Running internal register sanity checks on MicroVAX 3100 M10/M20 (KA41-A) simulator. *** Good Registers in MicroVAX 3100 M10/M20 (KA41-A) simulator.

MicroVAX 3100 M10/M20 (KA41-A) simulator Open SIMH V4.1-0 Current simh git commit id: 5e01c051 Build: Unsupported=include+lib Running Hardware Core Test (EHKAA)

*** FAILED - MicroVAX 3100 M10/M20 (KA41-A) Hardware Core Instruction test EHKAA

gmake: [makefile:2364: BIN/microvax3100] Error 1 Error code 2

Stop. make[1]: stopped in /mnt/vol1/rhialto/cvs/pkgsrc-head/emulators/open-simh *** Error code 1

Stop. make: stopped in /mnt/vol1/rhialto/cvs/pkgsrc-head/emulators/open-simh murthe.10:.../pkgsrc-head/emulators/open-simh$


- #### the simulator configuration file (or commands) which were used when the problem occurred.
Using the included diagnostics testing command:
`BIN/microvax3100 RegisterSanityCheck VAX/tests/vax-diag_test.ini </dev/null`

- #### the expected behavior and the actual behavior
as above:

Running Hardware Core Test (EHKAA)

*** FAILED - MicroVAX 3100 M10/M20 (KA41-A) Hardware Core Instruction test EHKAA

This test fails for all VAX models I tried so far.

If I compile the same git commit using gcc 7.5.0, the tests pass. This is also outside the pkgsrc context, so libraries which get linked may differ. But I expect that not to matter for a CPU instruction diagnostic.

The commands below are run in the open-simh repository, not in the pkgsrc repository as above.

murthe.6:.../cvs/other/open-simh$ gmake vax lib paths are: /usr/lib /usr/pkg/lib /lib/ /usr/lib/ include paths are: /usr/include/gcc-7 /usr/include /usr/pkg/include using libm: /usr/lib/libm.so using librt: /usr/lib/librt.so using libpthread: /usr/lib/libpthread.so /usr/include/pthread.h using libpcre: /usr/pkg/lib/libpcre.so /usr/pkg/include/pcre.h using semaphore: /usr/include/semaphore.h using libdl: /usr/include/dlfcn.h using libedit: /usr/pkg/include/editline/readline.h using mman: /usr/include/sys/mman.h using libSDL2: /usr/pkg/include/SDL2/SDL.h *** No SDL ttf support available. BESM-6 video panel disabled.


Info Install the development components of libSDL2-ttf packaged by your Info operating system distribution and rebuild your simulator to Info enable this extra functionality. using libpcap: /usr/include/pcap.h


vax Simulator being built with: - compiler optimizations and no debugging support. GCC Version: 7.5.0. - dynamic networking support using NetBSD provided libpcap components. - Local LAN packet transports: PCAP TAP NAT(SLiRP) - video capabilities provided by libSDL2 (Simple Directmedia Layer). - Per simulator tests will be run.


git commit id is 5e01c0516b14d16fa4e780dff13077bed76aa38a. git commit time is 2023-02-03T22:03:45-0800.


gcc -std=gnu99 -U__STRICT_ANSI__ -O2 -finline-functions -fgcse-after-reload -fpredictive-commoning -fipa-cp-clone -fno-unsafe-loop-optimizations -fno-strict-overflow -DSIM_GIT_COMMIT_ID=5e01c0516b14d16fa4e780dff13077bed76aa38a -DSIM_GIT_COMMIT_TIME=2023-02-03T22:03:45-0800 -DSIM_COMPILER="GCC Version: 7.5.0" -DSIM_BUILD_TOOL=simh-makefile -I . -Werror -D_GNU_SOURCE -I/usr/pkg/include -DUSE_READER_THREAD -DSIM_ASYNCH_IO -DHAVE_PCRE_H -DHAVE_SEMAPHORE -DHAVE_SYS_IOCTL -DSIM_HAVE_DLOPEN=so -DHAVE_EDITLINE -DHAVE_UTIME -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/ -DBPF_CONST_STRING -DUSE_SHARED -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 -o BIN/vax -L/usr/pkg/lib -R/usr/pkg/lib -lm -lrt -lpthread -lpcre -L/usr/pkg/lib/ -ledit -ltermcap cp BIN/vax BIN/microvax3900 BIN/vax RegisterSanityCheck /mnt/vol1/rhialto/cvs/other/open-simh/VAX/tests/vax-diag_test.ini </dev/null Running internal register sanity checks on MicroVAX 3900 simulator. *** Good Registers in MicroVAX 3900 simulator.

MicroVAX 3900 simulator Open SIMH V4.1-0 Current git commit id: 5e01c051 Running Hardware Core Test (EHKAA)

*** PASSED - MicroVAX 3900 Hardware Core Instruction test EHKAA

murthe.6:.../cvs/other/open-simh$


It seems that last time I packaged open-simh I failed to run the tests, commit ce791138b5b5365105415a9a1cf4091d6e50a43d, because the build I have from that also fails the test.
I'm pretty sure that they worked at some point in the past with some version of gcc 10.x though.

Maybe the optimization levels need to be decreased, but I have not experimented yet with that.
pkoning2 commented 1 year ago

What happens if you use a current GCC? I think 12.x is current.

Rhialto commented 1 year ago

I will try that soon, I would need to build it first.

Meanwhile I also tried the combination of the "bare" open-simh repo + gcc 10 and that appears to work. So that leaves me with a bit of a mystery...

murthe.6:.../cvs/other/open-simh$ sh -x ./Make vax
+ export TMPDIR=/tmpfs
+ gmake -j6 GCC=/usr/pkg/gcc10/bin/gcc FONTPATH=/usr/pkg/share/fonts/X11/TTF vax
lib paths are: /usr/lib /usr/pkg/lib /lib/ /usr/lib/
include paths are:  /usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0/include /usr/pkg/gcc10/include /usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0/include-fixed /usr/include /usr/pkg/include
using libm: /usr/lib/libm.so
using librt: /usr/lib/librt.so
using libpthread: /usr/lib/libpthread.so /usr/include/pthread.h
using libpcre: /usr/pkg/lib/libpcre.so /usr/pkg/include/pcre.h
using semaphore: /usr/include/semaphore.h
using libdl: /usr/include/dlfcn.h
using libedit: /usr/pkg/include/editline/readline.h
using mman: /usr/include/sys/mman.h
using libSDL2: /usr/pkg/include/SDL2/SDL.h
*** No SDL ttf support available.  BESM-6 video panel disabled.
***
*** Info *** Install the development components of libSDL2-ttf packaged by your
*** Info *** operating system distribution and rebuild your simulator to
*** Info *** enable this extra functionality.
using libpcap: /usr/include/pcap.h
***
*** vax Simulator being built with:
*** - compiler optimizations and no debugging support. GCC Version: 10.4.0.
*** - dynamic networking support using NetBSD provided libpcap components.
*** - Local LAN packet transports: PCAP TAP NAT(SLiRP)
*** - video capabilities provided by libSDL2 (Simple Directmedia Layer).
*** - Per simulator tests will be run.
***
*** git commit id is 5e01c0516b14d16fa4e780dff13077bed76aa38a.
*** git commit time is 2023-02-03T22:03:45-0800.
***
/usr/pkg/gcc10/bin/gcc -std=gnu99 -U__STRICT_ANSI__  -O2 -finline-functions -fgcse-after-reload -fpredictive-commoning -fipa-cp-clone -fno-unsafe-loop-optimizations -fno-strict-overflow -DSIM_GIT_COMMIT_ID=5e01c0516b14d16fa4e780dff13077bed76aa38a -DSIM_GIT_COMMIT_TIME=2023-02-03T22:03:45-0800  -DSIM_COMPILER="GCC Version: 10.4.0" -DSIM_BUILD_TOOL=simh-makefile -I . -Werror -D_GNU_SOURCE -I/usr/pkg/include -DUSE_READER_THREAD -DSIM_ASYNCH_IO  -DHAVE_PCRE_H -DHAVE_SEMAPHORE -DHAVE_SYS_IOCTL -DSIM_HAVE_DLOPEN=so -DHAVE_EDITLINE -DHAVE_UTIME -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/ -DBPF_CONST_STRING -DUSE_SHARED -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` -o BIN/vax -L/usr/pkg/lib -R/usr/pkg/lib -lm -lrt -lpthread -lpcre -L/usr/pkg/lib/ -ledit -ltermcap
cp BIN/vax BIN/microvax3900
BIN/vax RegisterSanityCheck /mnt/vol1/rhialto/cvs/other/open-simh/VAX/tests/vax-diag_test.ini </dev/null
 Running internal register sanity checks on MicroVAX 3900 simulator.
*** Good Registers in MicroVAX 3900 simulator.

MicroVAX 3900 simulator Open SIMH V4.1-0 Current        git commit id: 5e01c051
Running Hardware Core Test (EHKAA)

*** PASSED - MicroVAX 3900 Hardware Core Instruction test EHKAA

murthe.6:.../cvs/other/open-simh$
Rhialto commented 1 year ago

Using the earlier packaged build, that also seems to fail diagnostics, does boot NetBSD:

murthe.0:.../scratch/simh-vax/vaxbsd92$ ./netbsd-boot

MicroVAX 3900 simulator V4.0-0 Current        simh git commit id: ce791138        Build: Unsupported=include+lib
/mnt/scratch/scratch/simh-vax/vaxbsd92/netbsd-boot-5> attach nvr nvram.bin
%SIM-INFO: NVR: buffering file in memory
/mnt/scratch/scratch/simh-vax/vaxbsd92/netbsd-boot-15> attach xq0 tap:tap0
%SIM-ERROR: Eth: open error - Device not configured
/mnt/scratch/scratch/simh-vax/vaxbsd92/netbsd-boot-30> boot cpu
%SIM-INFO: Loading boot code from internal ka655x.bin

KA655-B V5.3, VMB 2.7
Performing normal system tests.
40..39..38..37..36..35..34..33..32..31..30..29..28..27..26..25..
24..23..22..21..20..19..18..17..16..15..14..13..12..11..10..09..
08..07..06..05..04..03..
Tests completed.
>>>boot
(BOOT/R5:0 DUA0

  2..
-DUA0
  1..0..

>> NetBSD/vax boot [1.12 (Tue Dec  7 12:43:14 UTC 2021)] <<
>> Press any key to abort autoboot 0
nfs_open: must mount first.
open netbsd.vax: Device not configured
> boot netbsd
3304416+205420 [239120+227675]=0x3cb190
[   1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
[   1.0000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
[   1.0000000]     2018, 2019, 2020 The NetBSD Foundation, Inc.  All rights reserved.
[   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
[   1.0000000]     The Regents of the University of California.  All rights reserved.

[   1.0000000] NetBSD 9.2_STABLE (GENERIC) #0: Tue Dec  7 12:43:14 UTC 2021
[   1.0000000]  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/vax/compile/GENERIC
[   1.0000000] MicroVAX 3800/3900
[   1.0000000] total memory = 65468 KB
[   1.0000000] avail memory = 58968 KB
[   1.0000000] mainbus0 (root)
[   1.0000000] cpu0 at mainbus0: KA655, CVAX microcode rev 6 Firmware rev 83
[   1.0000000] lance at mainbus0 not configured
[   1.0000000] uba0 at mainbus0: Q22
[   1.0000000] dz1 at uba0 csr 160100 vec 304 ipl 17
[   1.0000000] mtc0 at uba0 csr 174500 vec 774 ipl 17
[   1.0000000] mscpbus0 at mtc0: version 5 model 3
[   1.0000000] mscpbus0: DMA burst size set to 4
[   1.0000000] uda0 at uba0 csr 172150 vec 770 ipl 17
[   1.0000000] mscpbus1 at uda0: version 3 model 3
[   1.0000000] mscpbus1: DMA burst size set to 4
[   1.0000000] qt0 at uba0 csr 174440 vec 764 ipl 17
[   1.0000000] qt0: delqa-plus in Turbo mode, hardware address 08:00:2b:68:52:7d
[   1.0000000] rlc0 at uba0 csr 174400 vec 160 ipl 17
...

Weird. I'll have to look into this tomorrow but now it's late...

markpizz commented 1 year ago

My NetBSD test system is running the latest NetBSD release 9.3 and it has GCC 7.5 and, as you say, things work just fine.

FreeBSD has clang as the default and that runs just fine, with the packaged gcc (12.2.0) also works just fine.

Similarly OpenBSD 7.2 uses clang and no problem there. I installed the gcc 11.2.0 package, but don't know how to actually run the pieces of that package.

markpizz commented 1 year ago

As I vaguely recall, from days gone by, the initial cuts of newer gcc releases might not be great honoring all of the specific build time options simh wants. simh's gcc restriction comes specifically from the VAX simulators which share the same CPU code that was originally written presuming overflow behaviors which were implementation dependent. The build time options try to achieve that compiler behavior.

pkoning2 commented 1 year ago

That's strange; I work on gcc at times, and the notion that new releases would be sloppy about honoring compile switches is entirely unfamiliar. However, using obscure switches to force the optimizer to do unnatural things about stuff like overflow is tricky and prone to breakage. The C standard has rules about arithmetic -- which are quite a lot looser than many people think. The standard behavior is very solid, but the various switches to modify the arithmetic rules to accommodate various notions about "how it should be done instead" are far less so. The best answer is to fix the simulator so it executes correctly with standard C, not to make the compiler do odd things.

pkoning2 commented 1 year ago

Ok, so now I'm confused. I don't see any special GCC switches for the VAX builds in the makefile.

markpizz commented 1 year ago

Ok, so now I'm confused. I don't see any special GCC switches for the VAX builds in the makefile.

They are not VAX specific. The VAX switches have worked just fine for all simulators. The VAX has historically been the only one which ever had any glitches.

pkoning2 commented 1 year ago

Ok, I see -fno-strict-overflow. Right, that's a thing to avoid since the C standard clearly says that's not how signed arithmetic works. The solution is to use unsigned int whenever wrapping is desired. Chances are that getting this fixed will be some effort, but it would be worth doing over time.

Rhialto commented 1 year ago

I may be one step closer to finding what's the difference. Pkgsrc meddles a bit with compiler options behind the scenes. On the one hand, this can be set in the pkgsrc Makefile to do substitutions that are difficult to sqeeze into the package's own build system. On the other, it is to add security options like the stack protector, or position independent code.

Fortunately it keeps a log of the requested and the adjusted command lines, so I dug that up. I removed the options that refer to the temporary building directory of pkgsrc, and replaced them to point to the normal system locations. With that I could build a failing microvax3100 from the plain open-simh repository.

I also removed the -q from run -q in the simh ini file, to see more of how the diagnostic fails.

Here is the result. One of these extra options must be the cause. I haven't tried removing some of them yet.

murthe.6:.../cvs/other/open-simh$ ./TestFail
++ /usr/pkg/gcc10/bin/gcc -fcommon -Wl,-zrelro -std=gnu99 -U__STRICT_ANSI__ -O2 -DSIM_BUILD=Unsupported=include+lib '-DSIM_COMPILER=GCC Version: 10.4.0' -DSIM_BUILD_TOOL=simh-makefile -I. -D_GNU_SOURCE -DUSE_READER_THREAD -DSIM_ASYNCH_IO -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_cis.c ./VAX/vax_octa.c ./VAX/vax_cmode.c ./VAX/vax_mmu.c ./VAX/vax_sys.c ./VAX/vax_syscm.c ./VAX/vax_watch.c ./VAX/vax_nar.c ./VAX/vax4xx_stddev.c ./VAX/vax420_sysdev.c ./VAX/vax420_syslist.c ./VAX/vax4xx_dz.c ./VAX/vax4xx_rd.c ./VAX/vax4xx_rz80.c ./VAX/vax_xs.c ./VAX/vax4xx_va.c ./VAX/vax4xx_vc.c ./VAX/vax4xx_ve.c ./VAX/vax_lk.c ./VAX/vax_vs.c ./VAX/vax_gpx.c ./sim_scsi.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 -DVAX_420 -DUSE_INT64 -DUSE_ADDR64 -DUSE_SIM_VIDEO -I./VAX -I./PDP11 -DHAVE_PCAP_NETWORK -I/usr/include/pcap/ -DBPF_CONST_STRING -DUSE_SHARED -DHAVE_TAP_NETWORK -DHAVE_BSDTUNTAP -Islirp -Islirp_glue -Islirp_glue/qemu -DHAVE_SLIRP_NETWORK -DUSE_SIMH_SLIRP_DEBUG slirp/arp_table.c slirp/bootp.c slirp/cksum.c slirp/dnssearch.c slirp/if.c slirp/ip_icmp.c slirp/ip_input.c slirp/ip_output.c slirp/mbuf.c slirp/misc.c slirp/sbuf.c slirp/slirp.c slirp/socket.c slirp/tcp_input.c slirp/tcp_output.c slirp/tcp_subr.c slirp/tcp_timer.c slirp/tftp.c slirp/udp.c slirp_glue/glib_qemu_stubs.c slirp_glue/sim_slirp.c -DHAVE_LIBSDL -DUSE_SIM_VIDEO -I/usr/pkg/include/SDL2 -I/usr/X11R7/include -D_REENTRANT -D_THREAD_SAFE -lSDL2 -DVAX_41A -o BIN/microvax3100 -L/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0 -Wl,-rpath,/usr/pkg/gcc10/lib/gcc/x86_64--netbsd/10.4.0 -Wl,-zrelro -Wl,-rpath,/usr/pkg/lib -L/usr/X11R7/lib -Wl,-rpath,/usr/X11R7/lib -lm -lrt -lpthread -lpcre -L/usr/pkg/lib/ -ledit -ltermcap -lpng16 -lz -fPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -I/usr/pkg/include -pie
In file included from ./sim_ether.c:1023:
/usr/include/pcap/pcap.h:962:warning: "INVALID_SOCKET" redefined
  962 |   #define INVALID_SOCKET -1
      | 
In file included from ./sim_ether.h:70,
                 from ./sim_ether.c:373:
./sim_sock.h:93:note: this is the location of the previous definition
   93 | #define INVALID_SOCKET  ((SOCKET)-1)
      | 
++ BIN/microvax3100 RegisterSanityCheck VAX/tests/vax-diag_test.ini
 Running internal register sanity checks on MicroVAX 3100 M10/M20 (KA41-A) simulator.
*** Good Registers in MicroVAX 3100 M10/M20 (KA41-A) simulator.

MicroVAX 3100 M10/M20 (KA41-A) simulator Open SIMH V4.1-0 Current        Build: Unsupported=include+lib
Running Hardware Core Test (EHKAA)
/mnt/vol1/rhialto/cvs/other/open-simh/VAX/tests/vax-diag_test.ini-61> go 200
%SIM-INFO: Running with Buffered Console

HALT instruction, PC: 800040A8 (CMPL R7,R4)

*** FAILED - MicroVAX 3100 M10/M20 (KA41-A) Hardware Core Instruction test EHKAA

murthe.6:.../cvs/other/open-simh$
Rhialto commented 1 year ago

Ahhh... somewhere the options -finline-functions -fgcse-after-reload -fpredictive-commoning -fipa-cp-clone -fno-unsafe-loop-optimizations -fno-strict-overflow get lost. It looks like simh's Makefile already doesn't add them; there must be some mis-detection about whether they are needed?

If I add those options to my previous TestFail script, then the microvax passes.

Rhialto commented 1 year ago

So the pkgsrc transformation changes the call cc -v --help into tmpfs/emulators/open-simh/work.x86_64/.gcc/bin/gcc -fcommon -Wl,-zrelro -v --help -fPIC -D_FORTIFY_SOURCE=2 -fstack-protector-strong -I/tmpfs/emulators/open-simh/work.x86_64/.buildlink/include -pie

It seems to be -Wl,-zrelro that causes gcc to output less help text than usual... in particular the part about the optimization options is missing...

Now the question is what to do about this...

pkoning2 commented 1 year ago

I would argue pkgsrc has a real defect. Messing with the compile options chosen by the projects it's packaging is bad practice. Especially when dealing with options that affect code generation and language semantics, which is the case here.

If that bug can't be fixed it needs at least to be worked around for SIMH.

Rhialto commented 1 year ago

@pkoning2 yes and no :) I would say it is good to add options to increase security, such as -D_FORTIFY_SOURCE=2 -fstack-protector-strong. I can understand that pkgsrc more or less assumes that calls to the compiler are there to actually compile something. A typical way to find out if a compiler option exists is to try using it; looking in help output is quite unusual.

But I would put part of the blame at gcc's feet. It is really weird that it changes the amount of --help output if some particular other option is present. If it doesn't like any other options with --help, fine, but then it should output no help at all and an error return code. Instead it does output a lot of text, just not as much as usual:

$ /usr/pkg/gcc10/bin/gcc -v --help -Wl,-zrelro 2>&1 | wc -l
     359
$ /usr/pkg/gcc10/bin/gcc -v --help  2>&1 | wc -l
    3589
Rhialto commented 1 year ago

For pkgsrc, I'm working around this by simply setting CFLAGS_O to all of the to-be-detected options. If they fail to be detected, it doesn't matter, nor if they are used twice.

I'm assuming for now that the cmake build process has a different way to detect the possible flags, which would work better for this use case.

With that, I'll close this issue.