5 ms·
Both LLVM and gcc suffer from the problem that they're vast underdocumented code bases with Internal Platform Syndrome and mostly-but-not-quite-finished interna
by david-given 12y ago
Both LLVM and gcc suffer from the problem that they're vast underdocumented code bases with Internal Platform Syndrome and mostly-but-not-quite-finished internal tools which generate undebuggable code. The actual working set of knowledge which you need to do serious work on the compiler, such as porting it to a new backend, mostly exists as tribal knowledge only, and the only way to find this out is to either investigate the source yourself or to try and ask for help on the mailing lists. LLVM's is significantly more helpful than gcc's, because LLVM has more people participating and more momentum behind it, but you're still not guaranteed to get an answer. Actually producing a working backend is an enormous investment of time and effort.
By way of example: I'm interested in the Broadcom Videocore IV processor, also known as the main processor on the Raspberry Pi. I bounced off both gcc and LLVM, and for much the same reason --- after getting the port about 75% complete I ran into blocking issues that I couldn't fix on my own and couldn't get enough assistance on the mailing lists to fix. Which is a shame. (I should point out that prior to that I did do a VC4 backend for the ACK compiler. It generates terrible, terrible but working code.)
I have run into commercial compilers which were easy to port, and generated good code, to boot. Volker Barthelman's vbcc even has a VC4 backend, which produces amazing code, and his compiler is a tiny fraction of the size of either gcc or LLVM! But it's not open source. Maybe one day we'll get a similarly good open source small compiler...
- voltagex_ 12y agoOfftopic: what's a good way to learn about the Videocore processor? I now own a B+ and a Pi 2 so it might be worth my while.
- david-given 12y agoI have absolutely no idea about the processor in the Pi 2, but I got all the specs for the Pi 1 from here: https://github.com/hermanhermitage/videocoreiv https://github.com/hermanhermitage/videocoreiv (It's a beautiful processor. 32 registers, built in DSP, built in vector processing, some really elegant instruction design, dual core, and enough weirdness that writing good code is satisfying without being frustrating. No double precision float, alas, although it's got single precision, and for some bizarre reason there's no adc or sbc instruction which makes 64 bit arithmetic annoying.) If you're interested in playing with it, you might also like a look at my half-finished pure-VC4-code boot loader here: https://cowlark.com/piface https://cowlark.com/piface Stick it on an SD card, hook up a serial terminal, and it'll boot directly on the VC4 without even starting up the ARM.
- voltagex_ 12y agoWhoa, does that mean there's a chance of replacing the proprietary bootloader on the Pi? It's the most common complaint I see here.
- david-given 12y agoYou can replace the proprietary bootloader on the SD card. You can't replace the one in the ROM. And while running executables is easy --- just drop a VC4 binary called bootcode.bin onto the root directory of the card and the ROM loader will load and run it --- there's a lot of hardware setup which still needs to be figured out; such as initialising the SDRAM. I originally wanted to get Prex (a Minix-like microkernel OS with a Unix interface which doesn't need an MMU) running on the VC4, but I need an actual working compiler for that.
- acqq 12y agoMay I ask you: why programming VC4 (apart from taking over the control of the rest of Raspberry Pi?) It's only 250 MHz? And if you want the new control of the Raspberry Pi, why, as it's so proprietary?
- david-given 12y agoBecause the VC4 is really cool, basically.
- nitrogen 12y agoClock speed is only a very small part of the performance of a chip when comparing across completely different architectures (like VC4 vs. ARM).
- phire 12y agoPi 2 apparently has the exact same GPU/VPU as the Pi 1. The only thing they changed was the arm cores and the memory subsystem.