Announcement

Collapse
No announcement yet.

GCC Rust Compiler "gccrs" Sees ~900 New Patches Upstreamed For GCC 14

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    Originally posted by Developer12 View Post

    A lot. This whole effort is kinda pointless considering that rustc using the GCC codegen backend can already compile all the rust kernel code, and this GCC frontend is never going to be able to keep up with the much faster rustc release cadence and nightly builds. GCC organizationally just isn't capable of it.
    Not really, I assume gccrs is mostly for kernel support. So it would be incredibly helpful for building linux with gcc.

    Comment


    • #22
      Originally posted by anarki2 View Post
      I don't understand why I would ever use this instead of the official compiler. I really don't.
      More hardware support. GCC supports much more targets than LLVM currently can.

      Comment


      • #23
        Originally posted by ehansin View Post
        I get so confused about all of the various components here, but think I may have figured it all out. What I think is going on is...


        * rustc: The official Rust compiler.

        * rustc_codegen_gcc: Allows GCC to be used with rustc, and LLVM by extension (I think!) Not sure what direction things pass through, but sounds like ultimately you get the greater architectural coverage of GCC, generating bytecode (or something like that) than can then be consumed by rustc/LLVM. So you ultimate get to use the offical Rust compiler.

        * gccrs: What this article is about. A Rust compiler implantation purely in/using GCC. This means of course you are no using the official Rust compiler, and any delta between the two needs to be accepted.


        That is where I am at now. But at least I took a few minutes to sort it out for future mental reference. Happy for any input if there is any.
        You're close. Regarding rustc_codegen_gcc: GCC has a component called `libgccjit` which can be embedded into programs to generate machine code at runtime (like for an interpreter, for example). That's its main purpose, but it can also generate machine code ahead-of-time as well with the same API, which is where rustc_codegen_gcc comes in. It uses the rustc frontend that Rust programmers are all familiar with, but instead of generating LLVM intermediate representation code, it generates code for the libgccjit API. libgccjit will then generate machine code ahead-of-time for any of the targets GCC supports.

        Comment


        • #24
          Originally posted by darcagn View Post

          You're close. Regarding rustc_codegen_gcc: GCC has a component called `libgccjit` which can be embedded into programs to generate machine code at runtime (like for an interpreter, for example). That's its main purpose, but it can also generate machine code ahead-of-time as well with the same API, which is where rustc_codegen_gcc comes in. It uses the rustc frontend that Rust programmers are all familiar with, but instead of generating LLVM intermediate representation code, it generates code for the libgccjit API. libgccjit will then generate machine code ahead-of-time for any of the targets GCC supports.
          Then why is there a separate implementation in GCC? Licensing aside, what's the argument here?

          Comment


          • #25
            Originally posted by vextium View Post

            More hardware support. GCC supports much more targets than LLVM currently can.
            I'm going to venture a guess and say a second implementation can uncover quirks in rustc, just like adding Rust support uncovered quirks in LLVM.

            Comment


            • #26
              Originally posted by AHSauge View Post
              Then why is there a separate implementation in GCC? Licensing aside, what's the argument here?
              To help create a formal Rust spec, which is necessary for certain markets. To involve the GCC community in Rust development and not put all eggs in one basket. Code generated with libgccjit cannot be LTO'd with standard GCC or LLVM objects. Open Source Security inc, one of the main funders, is funding development because of some negative security implications of mixing code compiled with LLVM and code compiled with GCC in relation to the Linux kernel. These might not be the most exciting reasons but are little loose ends that will benefit from having an alternative implementation. Maybe it'll always be behind the flagship rustc compiler but that might be a perfectly fine tradeoff in exchange for a stable formal spec in certain markets.

              Comment


              • #27
                The fun really commences once Rust is bootstrappable in upstream GCC, and GCC can begin being ported to Rust. :+ )

                Comment


                • #28
                  Originally posted by darcagn View Post
                  Code generated with libgccjit cannot be LTO'd with standard GCC or LLVM objects.
                  I don't see why one couldn't LTO C code complied with gcc and rust code complied with rustc+libgccjit. Could you elaborate? Can't libgccjit output gimpl?

                  Comment


                  • #29
                    Originally posted by oleid View Post

                    I don't see why one couldn't LTO C code complied with gcc and rust code complied with rustc+libgccjit. Could you elaborate? Can't libgccjit output gimpl?
                    because there is no linking in libgccjit. its a jit library... they are literally mutually exclusive.

                    Comment


                    • #30
                      Originally posted by anarki2 View Post
                      I don't understand why I would ever use this instead of the official compiler. I really don't.
                      Because of official (to be honest, the only way) to install rust:

                      curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
                      is pathetic and miserable.

                      Comment

                      Working...
                      X