Wren6991 / Hazard3

3-stage RV32IMACZb* processor with debug
Apache License 2.0
696 stars 47 forks source link

Compilation failure under mingw64 #16

Open peardox opened 2 months ago

peardox commented 2 months ago

Does a load of the easie bits then gets to GCC and eventually...

build/gencheck.exe > tmp-check.h /bin/sh /home/simon/riscv-gnu-toolchain/gcc-14/gcc/../move-if-change tmp-check.h tree-check.h echo timestamp > s-check g++ -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -fno-exceptions -fno-rtti -fasynchronous-unwind-tables -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wmissing-format-attribute -Wconditionally-supported -Woverloaded-virtual -pedantic -Wno-long-long -Wno-variadic-macros -Wno-overlength-strings -DHAVE_CONFIG_H -DGENERATOR_FILE -static-libstdc++ -static-libgcc -Wl,--stack,12582912 -Wl,--undefined=HOST_EXTRA_OBJS_SYMBOL -o build/genrvv-type-indexer.exe \ build/genrvv-type-indexer.o ../build-i686-w64-mingw32/libiberty/libiberty.a build/genrvv-type-indexer.exe tmp-riscv-vector-type-indexer.gen.def /bin/sh /home/simon/riscv-gnu-toolchain/gcc-14/gcc/../move-if-change tmp-riscv-vector-type-indexer.gen.def riscv-vector-type-indexer.gen.def echo timestamp > s-riscv-vector-type-indexer.gen.defs build/gengtype.exe \ -S /home/simon/riscv-gnu-toolchain/gcc-14/gcc -I gtyp-input.list -w tmp-gtype.state /home/simon/riscv-gnu-toolchain/gcc-14/gcc/../libcpp/include/line-map.h: No such file or directory make[2]: [Makefile:2970: s-gtype] Error 1 make[2]: Waiting for unfinished jobs.... /bin/sh /home/simon/riscv-gnu-toolchain/gcc-14/gcc/../move-if-change tmp-mlib.h multilib.h echo timestamp > s-mlib

There is a gcc/libcpp/include/line-map.h in the gcc git however and it compiles under Linux OK - problematic MSYS toolchain???

peardox commented 2 months ago

Some exploration later I get...

mkdir -p /opt/riscv-64/gcc14-rp2350-no-zcmp git clone https://github.com/riscv/riscv-gnu-toolchain cd riscv-gnu-toolchain git clone https://github.com/gcc-mirror/gcc gcc -b releases/gcc-14

Then full configure and make runs out of memory (32G) - mem just keeps increasing until it's all used. It does actually build the tools and I can at least get sense out of -v / -h so they look functional. Problem appears to be that when it's building libraries mem use just keeps increasing. Restart and continue the build and eventually it gets stuck on the same section compiling stuff like generic-match-7.cc. find . | wc in the srouce dir shows 300k files while a linux buld shows 1.5M ...

Trying non-multilib now

Wren6991 commented 2 months ago

I don't run Windows so I can't reproduce this easily. Are you using mingw or are you using gcc under WSL? I'm a little confused.

I develop on Ubuntu, so you should find Ubuntu under WSL is the path of least resistance on Windows. The GCC build is notoriously kludgey.

Wren6991 commented 2 months ago

You could also try getting a prebuilt Windows RISC-V embedded toolchain like from here: https://www.embecosm.com/resources/tool-chain-downloads/#riscv-stable

You'll just have to update the Makefiles to use the toolchain you chose.

peardox commented 2 months ago

Yeah, aim is to get a good win10 native toolchain (which I imagine will be desirable)

Been using msys/mingw but it seems a dead-end under Windows - it's compiled a load of stuff but has been sat doing nothing for about five hours Last output was....

if test -z "$objects"; then \ echo 'int __libgcc_eh_dummy;' > eh_dummy.c; \ /home/simon/64bit/riscv-gnu-toolchain/build-gcc-newlib-stage2/./gcc/xgcc -B/home/simon/64bit/riscv-gnu-toolchain/build-gcc-newlib-stage2/./gcc/ -B/opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/bin/ -B/opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/lib/ -isystem /opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/include -isystem /opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/sys-include -Os -mcmodel=medlow -O2 -Os -mcmodel=medlow -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem ./include -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -I. -I. -I../.././gcc -I../../.././gcc/libgcc -I../../.././gcc/libgcc/. -I../../.././gcc/libgcc/../gcc -I../../.././gcc/libgcc/../include -DHAVE_CC_TLS -fvisibility=hidden -DHIDE_EXPORTS -c eh_dummy.c \ -o eh_dummy.o; \ objects=eh_dummy.o; \ fi; \ /opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/bin/ar rc libgcov.a $objects # early copy is necessary so that the gcc -B options find # the right startup files when linking shared libgcc. /bin/sh ../../.././gcc/libgcc/../mkinstalldirs ../.././gcc /opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/bin/ranlib libgcov.a parts="crtbegin.o crtend.o crtbegin.o crtend.o crti.o crtn.o"; \ for file in $parts; do \ rm -f ../.././gcc/$file; \ /usr/bin/install -c -m 644 $file ../.././gcc/; \ case $file in \ *.a) \ /opt/riscv/gcc14-rp2350-no-zcmp/riscv32-unknown-elf/bin/ranlib ../.././gcc/$file ;; \ esac; \ done

I've got several X86_64 Linux systems as well. Trying to work out how to do a cross-compile. Using Ubuntu I apt-got mingw64 which gave me a Linux version and sure enough ....

x86_64-w64-mingw32-gcc -v Gives me the expected output

I just dunno how to get ./configure to use the mingw64 stuff instead of the linux versions (tried --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 but that just made linux elf output)

If you can gimme a clue that'd be handy - if you're not overly conversant with cross compiling I do know people who can guide me in the right direction (although they're all highly PASCAL focused...)

gojimmypi commented 2 months ago

Been using msys/mingw but it seems a dead-end under Windows

@peardox I've had pretty good success using WSL. (Windows Subsystem For Linux). I've not recently built for this particular project, but I suspect it would work.

If you've not used it before, beware there are two flavors: WSL 1 and WSL 2, each with their own merits.

peardox commented 2 months ago

@gojimmypi Yeah, I use WSL2 extensively as well as Linux and Windows (even a little Mac stuff). I use WSL to build things like (very slightly) custom debug probe etc.

The thing is that Windows is the most popular OS so making Windows Pico friendly would be advantageous. I'm thinking specifically of things like learning Risc-V assembler ( and C/C++ I guess) on a device that costs a fiver.

The present solutions are all way too techie for a newbie so I'm looking at a simple IDE that purely does Pico - hence the desire for good toolchains

peardox commented 1 month ago

Just managed a gcc-13 Win64 build without multilib

Now gonna try gcc-14 with multilib

peardox commented 1 month ago

Some success (tada).... I now have a functioning gcc-14 no-multilib toolchain for Windows 64

IMHO 64Gb MAY be required for a multilib build

The output from a test shows the files to be....

$ file prime_hazard.uf2 prime_hazard.uf2: UF2 firmware image, family 0xe48bff57, address 0x10ffff00, 2 total blocks

$ file prime_hazard.elf prime_hazard.elf: ELF 32-bit LSB executable, UCB RISC-V, RVC, soft-float ABI, version 1 (SYSV), statically linked, with debug_info, not stripped

Using mingw64 to 'help' with the toolchain ATM (provision of ninja + cmake)

If anyone wants to try out the (very experimental) version it's at https://peardox.com/pico/gcc14-no-zcmp-no-multilib.zip