News for hackers. Stuff that matters.
Re:Bootstrapping GCC in RISC-V: Milestone: MesCC builds Tiny... by unwind on Tuesday October 31, 2023 @04:13AM (#38081568)
This was really interesting, I (being a C buff, beard and all) love this kind of low-level hacking to get critical infrastructure to work on a platform. Many of the gotchas they experienced seemed familiar (such as char's lack of signed-ness) from helping beginners with the language, too.

It was surprising that the OP calls C's shift operators (<< and >>) rotate, especially surprising in the context of low-level/assembly programming where rotate is very often a separate instruction. A rotate will bring bits "around", while a shift just inserts 0s or sign bit copies.

Re:Bootstrapping GCC in RISC-V: Milestone: MesCC builds Tiny... by benj111 on Tuesday October 31, 2023 @04:54AM (#38081896)
A shift is basically a rotate and mask. If wonder if they came from a machine where there was no shift instruction?
Re:Bootstrapping GCC in RISC-V: Milestone: MesCC builds Tiny... by unwind on Tuesday October 31, 2023 @09:07AM (#38084240)
Not for the signed ("arithmetic") case when you need to duplicate the sign bit into the topmost bit. You can't replicate that with a rotate, it's a distinct operation.
Re:Bootstrapping GCC in RISC-V: Milestone: MesCC builds Tiny... by benj111 on Tuesday October 31, 2023 @11:32AM (#38086410)
No but if this hypothetical instruction set doesn't even include shifts, it wouldn't be surprising if it missed other instructions.
Re:Bootstrapping GCC in RISC-V: Milestone: MesCC builds Tiny... by fweimer on Tuesday October 31, 2023 @05:38AM (#38082242)
Note that this specific aspect discussed here isn't about getting things working as such. Cross-compilation of RISC-V has been absolutely trivial for many years. For example, support for riscv64-*-linux-gnu architectures was added to build-many-glibcs.py more than five years ago: https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=0fd5d... This gives you ABI-verified cross-compilers for GNU/Linux. Other similar scripts exist, and may even build more complete sysroots.

The difference to the approach referenced here is that build-many-glibcs.py and similar efforts start out from a native GNU toolchain (contemporary GCC with the C and C++ front ends, binutils, GNU make, and so on) plus some extensions (such as Python). Most people already have such an environment and trust it to some degree, so there is no need to bootstrap off some minimal seed.