1. 33

  2. 4

    Great work! All these fixes to libgccjit would be needed if anyone ever wanted to pursue this as a Zig backend too, so from this side of the fence, thank you!!

    1. 3

      I am looking forward to when this will be more widely available and works, because it will allow Rust to be used in more places where C is currently the mainstream language of choice due to the need to still compile and build on various esoteric platforms.

      This will also help alleviate the concerns from the packagers attempting to package the Python cryptography package which now uses Rust in various places!

      1. 1

        even more when we can get rust+c code in one thing from gcc, like mozilla does use for rust+c(++) on LLVM

        1. 1

          various esoteric platforms

          I am really curious. Which platform do you have in mind?

          1. 4

            All of the platforms that Linux runs on, for one thing. There is a project to enable the use of Rust in the Linux kernel, but for now it can only be used for platform specific device drivers. Rust doesn’t support most of the platforms that Linux runs on, so Rust can’t be used for platform-independent code in Linux, until it supports the same platforms that gcc supports.

            For more information about the Python cryptography controversy, which concerns platforms unsupported by Rust, see https://github.com/pyca/cryptography/issues/5771

            1. 3

              I myself work on a platform that implements AIX syscall emulation - and I maintain a C codebase targeting it. I’d love to use a safer language.

              1. 1

                Apparently IBM wants to support LLVM on AIX, see Adding LLVM Support for AIX.

              2. 3

                Can’t speak for the GP, but I imagine pretty much all microcontrollers ever would fall into this category :) IIRC Rust has been ported to a few, but being able to transpile into C would vastly increase its reach.

                1. 2

                  being able to transpile into C would vastly increase its reach

                  Do you get that from this work? As I understand it, libgccjit exposes C types[1] but it then generates GIMPLE, not C. It should be possible to use it to target any architecture that GCC can target[2], but it’s not clear that you can use it to generate C code. It exposes things such as unwind table structures that can’t be expressed in C and so any transformation to C would be lossy.

                  [1] One of my pet peeves with LLVM is that it doesn’t. Most platform ABIs are defined in C types and so there’s an implicit (undocumented) contract between clang and each back end about what IR idioms map to which C constructs and each front-end needs to reimplement this logic.

                  [2] With the limitation that, unlike LLVM, GCC is not intrinsically a cross-compiler and so you’d need a separate libgccjit binary for each target architecture. If you can dynamically load these into rustc then that’s probably fine, you can ship a load of them and just load the one you need based on the target.