← Back to context

Comment by mastax

3 years ago

Unusual platforms like DSPs usually have specific (usually proprietary) toolchains. Why can't those platforms implement extensions to support 32-bit bytes? Why must everyone else support them? In practice ~no C code is portable to machines with 32-bit bytes. That's okay! You don't choose a DSP to run general purpose code. You choose it to run DSP code, usually written for a specific purpose, often in assembly.

"Weird" platforms often do have their own tool-chains but they do have the ability to leverage LLVM, MISRA, and an array of common tools and analyses that exists for C. One of the reason we got new platforms like RISC-V is that today its possible to use existing OSS software to build a platform with a working OS and Development environment, that common basic libraries can be built for is that all this software is written in C and can be targeted towards a new platform.

  • doesn't LLVM only cover a smidge of the weird platforms, if that?

    Like, it doesn't even cover ESP32 chips, despite attempts to get support into LLVM since 2019.

    point being, they can't leverage LLVM

  • What is the relevance of RiscV here? Not weird at all. I feel like you skipped part of the argument.

    • Ok here’s a concrete one, ARM is experimenting with a brand new CHERI implementation that throws out a lot of “obvious” things that are supposed to be true for pointers and integers. The only way this has been able to work is that the standard is flexible enough to let C(++) work here. Rust is getting breaking changes to support the platform.

      1 reply →

    • The point is that new exploration of the design space only works when there’s a familiar environment to build on. The old days of each architecture being its own hermetic environment are gone.

Because C already does this, and has from the beginning. C was designed to be portable in an era where there were significant differences in fundamental CPU design decisions between platforms. C is widely used to write software for all kinds of weird platforms. Changing that would be far more work than just making a new language.

They also tend to be non-standard for a variety of reasons anyway! C bends backwards to support odd architectures but is often also insufficient (or at least the vendors cannot justify the effort to achieve full compliance and their customers don't care significantly anyway).