I'm sticking with using my PC for now due to the speed. The riscv-gnu-toolchain keeps stopping. I have to type 'make' multiple times. First time yields binutils. Second, a stage1 gcc which I only just noticed. Seems if I keep typing 'make' it proceeds through later stages. ie "Hello C World" failed (no <stdio.h>). Make. Now no 'ctrbegin.o. Make. Repeat until it appears. It's now stopped on 'gdb' which I don't care about(*) atm. At least I can do "Hello C World" and "Hello C++ World". No idea if the compiler works of course but at least it builds and generates am executable.I followed the instructions in one of the PDF files but can't remember which and can't find it so included what I did below. That successfully built the RISC-V compiler on my Pi 4B 1GB, Bookworm 32-bit.
Found it : "Raspberry Pi Pico-series C/C++ SDK", page 30, section 2.10
It was a 10 hour build and ate 16 GB of disk space. A Pi 5 should be quicker.
And because it's a Pi 4B 1GB I had to enable a 2GB swap file to prevent it crashing out with Out of Memory after 20 or so minutes. Could probably be less but, hey ho. That's also why I am running a simple 'make' rather than a 'make -j$(nproc)' as that's proven less problematic with big builds.Then updated my '~/.bashrc' -Code:
cd ~/appsmkdir riscvsudo apt-get install autoconf automake autotools-dev curl python3 \ python3-pip libmpc-dev libmpfr-dev libgmp-dev \ gawk build-essential bison flex texinfo gperf \ libtool patchutils bc zlib1g-dev libexpat-dev \ ninja-build git cmake libglib2.0-dev libslirp-devsudo mkdir -p /opt/riscv/gcc14-rp2350-no-zcmpsudo chown -R $(whoami) /opt/riscv/gcc14-rp2350-no-zcmpgit clone https://github.com/riscv/riscv-gnu-toolchaincd riscv-gnu-toolchaingit clone https://github.com/gcc-mirror/gcc gcc-14 -b releases/gcc-14 ./configure \ -prefix=/opt/riscv/gcc14-rp2350-no-zcmp \ --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb \ --with-abi=ilp32 \ --with-multilib-generator="rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--" \ --with-gcc-src=`pwd`/gcc-14time make
You may have to logout or reboot for that to take effect but I believe you should be able to execute that 'export' line at the command line and it will instantly happen. YMMV.Code:
cd ~nano .bashrc export PATH="$PATH:/opt/riscv/gcc14-rp2350-no-zcmp/bin"
No joy yet with dragging and dropping that '/opt/riscv/gcc14-rp2350-no-zcmp/bin' to my Pi 3B Buster 32-bit. It seems to have a GCC dependency on '/lib/arm-linux-gnueabihf/libc.so.6' I haven't resolved. Which is a shame because I don't have the disk space to build it on that.
The --with-gcc-src option broke things fairly rapidly. So.. I (ahem) deleted "gcc" (rm -rf riscv-gnu-toolchain/gcc/*), and copied a gcc-14.2.0/ into there. Surprisingly, that worked. Note the gcc-14.2.0 already had the correct gmp/mpfr etc in it. I tend to do that for my builds because I don't like it when things have to reach out to the internet for a build. I had noticed some issues with "missing gmp" etc flying by with the initial default gcc13. Incidentally, gcc13 doesn't like rpi specific multilib options so gcc14 is a requirement not a choice.
(*) missing gmp etc again. I removed the dev libs for gmp/mpfr/mpc/isl from my PC because it broke my full fat arm cross. Ditto my build rpi for consistency. You need in-tree versions for a reliable gcc else you get random runtime faults.
I have a script to build arm-none-eabi. I did start with a modified version of that for the above. I hoping to return to that as it's a bit more sane. The lengthy part is going to be fishing out what riscv-gnu-toolchain is doing (and possible patches) that my script isn't.
So we can compare..
Code:
foo@sdu:~/usr/src/riscv$ /tmp/RV/bin/riscv32-unknown-elf-gcc --print-multi-lib.;rv32imac_zicsr_zifencei_zba_zbb_zbkb_zbs/ilp32;@march=rv32imac_zicsr_zifencei_zba_zbb_zbkb_zbs@mabi=ilp32
Code:
foo@sdu:~/usr/src/riscv$ /tmp/RV/bin/riscv32-unknown-elf-gcc -vUsing built-in specs.COLLECT_GCC=/tmp/RV/bin/riscv32-unknown-elf-gccCOLLECT_LTO_WRAPPER=/tmp/RV/libexec/gcc/riscv32-unknown-elf/14.2.0/lto-wrapperTarget: riscv32-unknown-elfConfigured with: /home/foo/usr/src/riscv/obj/../riscv-gnu-toolchain/gcc/configure --target=riscv32-unknown-elf --prefix=/tmp/RV --disable-shared --disable-threads --enable-languages=c,c++ --with-pkgversion=gc891d8dc23e-dirty --with-system-zlib --enable-tls --with-newlib --with-sysroot=/tmp/RV/riscv32-unknown-elf --with-native-system-header-dir=/include --disable-libmudflap --disable-libssp --disable-libquadmath --disable-libgomp --disable-nls --disable-tm-clone-registry --src=../../riscv-gnu-toolchain/gcc --enable-multilib --with-multilib-generator='rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb-ilp32--;rv32imac_zicsr_zifencei_zba_zbb_zbs_zbkb-ilp32--' --with-abi=ilp32 --with-arch=rv32ima_zicsr_zifencei_zba_zbb_zbs_zbkb_zca_zcb --with-tune=rocket --with-isa-spec=20191213 'CFLAGS_FOR_TARGET=-Os -mcmodel=medlow' 'CXXFLAGS_FOR_TARGET=-Os -mcmodel=medlow'Thread model: singleSupported LTO compression algorithms: zlibgcc version 14.2.0 (gc891d8dc23e-dirty)
Code:
foo@sdu:~/usr/src/riscv$ ldd /tmp/RV/bin/riscv32-unknown-elf-gcclinux-vdso.so.1 (0x00007ffd790ba000)libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd4ed9f8000)/lib64/ld-linux-x86-64.so.2 (0x00007fd4edc40000)
Statistics: Posted by swampdog — Mon Aug 19, 2024 5:22 pm