8 ms·
Rust front-end merged in GCC trunk
- rwmj 4y agoWhat are the practical implications of this? Could cargo call GCC? Or would it be like gcj and allow compiled rust libraries & binaries to be distributed? (at least in theory, gcj didn't work out well)
- Conan_Kudo 4y agoCargo could call gcc-rs instead of rustc.
- kangalioo 4y agoThe point of GCCRS over rustc_codegen_gcc is to make Rust easier integrateable into other projects and build systems. If you use Cargo anyways, you're much better off using rustc_codegen_gcc
- pabs3 4y agoWhat happened to gcj?
- e12e 4y agoIt grew stale(?) and was dropped in gcc 7.
- bonzini 4y agoSince there is now OpenJDK, there was no reason to keep working on it, and both GCJ and the associated class libraries didn't follow the evolution in the Java language. In the beginning GCJ became only an ahead-of-time bytecode compiler, with the Java->bytecode translation done using ecj; but ultimately there was no reason to keep it around at all and it was deleted in GCC 7.
- pjmlp 4y agoAhead of time native code compiler. It was kept around for a long time after everyone went to OpenJDK, because it was the only project with certain unit tests for GCC code paths, when that was eventually sorted out, it was when they dropped it.
- bonzini 4y agoI meant it compiled bytecode to native ahead of time. There was also a source to native part which was removed first.
- rapsey 4y agoMore architectures supported at least. Now Rust can really be used anywhere C is used
- scaredginger 4y agoOut of curiosity, what can GCC's backend generate that LLVM can't?
- elsjaako 4y agoAVR (for example, old Arduino boards) and xtensa (like esp32 developer boards) are the only ones I know of. Most of the desktop OS platforms are supported by both.
- viraptor 4y agoAVR should be working these days https://github.com/llvm/llvm-project/tree/main/llvm/lib/Target/AVR https://github.com/llvm/llvm-project/tree/main/llvm/lib/Targ... Unless you mean some specific chips?
- masklinn 4y agoAlso while ESP32 has not been mainlined (I think), Espressif has both an llvm and a rustc fork.
- pantalaimon 4y agoEspressif has forks of everything (OpenOCD, GDB, GCC) that they never mainline and that just become outdated as they release new chips. The latest xtensa-esp8266-elf-gcc is version 5.2
- jeroenhd 4y agoTheir first patches are in the process of being merged: https://discourse.llvm.org/t/rfc-request-for-upstream-tensilica-xtensa-esp32-backend/65355 https://discourse.llvm.org/t/rfc-request-for-upstream-tensil...
- pabs3 4y agoThere is also a project for rustc to use GCC instead of LLVM for codegen. https://github.com/rust-lang/rustc_codegen_gcc https://github.com/rust-lang/rustc_codegen_gcc
- sp1rit 4y agoDoes this mean I can now finally generate object files from .rs sources and link them myself? That is one of the things that rustc is severely lacking.
- viraptor 4y agoIs that not what "rustc --emit=obj" does now?
- stingraycharles 4y agoOut of curiosity, why would you need this?
- hgs3 4y agoYou're basically asking why you'd want object files. They're a container of (usually) relocatable machine code. You can inspect or modify them with nm [1] or objcopy [2]. You can link them with object files generated from other programming languages to mix languages. Maybe you have a custom linker or environment that requires you to convert an ELF or COFF object file to some custom variant. There are lots of reasons. [1] https://linux.die.net/man/1/nm https://linux.die.net/man/1/nm [2] https://linux.die.net/man/1/objcopy https://linux.die.net/man/1/objcopy
- deleted 4y ago[deleted]
- c0l0 4y agoProbably a dumb question, but I'd really like to know if this somehow affects/improves Rust's support for dynamic linking in any way (i.e., when comiling Rust code with the GCC-based toolchain, instead of with rustc)?
- mlindner 4y agoI would naively assume that it doesn't affect it at all. Compiling with GCC doesn't magically make dynamic linking better. The limitation in dynamic linking is an element of language design. I'd also note that any Rust you compile with GCC probably shouldn't be dynamically linked with Rust code compiled with rustc.
- hardware2win 4y agoI hope there aint gonna be ecosystem fragmentation When there are a fews compilers with significant market share then developers are those who lose, lose that handy dev. experience of solid and consistent ecosystem I hope it will be used only where necessary
- wofo 4y agoI think this is more of an attempt of making Rust compilable on platforms not supported by LLVM, not an attempt to replace the existing compiler. The GCC frontend, for instance, does not implement the borrow checker, so you should only use it to compile Rust code you know is correct according to the official Rust compiler.
- mkj 4y agoLacking a borrow checker is a temporary thing, no point reinventing the wheel. I think the intent is that eventually it'll use the same library as Rust (maybe Polonius, or perhaps plans will change)
- GrayShade 4y agoThat's rather rustc_codegen_gcc. gcc-rs is more for people who don't like LLVM and/or Rust. https://github.com/rust-lang/rustc_codegen_gcc https://github.com/rust-lang/rustc_codegen_gcc
- masklinn 4y agoA rust implementation for people who don’t like rust seems like a strange take.
- cstrahan 4y agoNot too strange. Imagine the reverse: a C compiler written in Rust. There is an awful lot of software in C that I want to use, but I really dislike C itself. If I found some deficiency in C compilers and felt the need to write my own, I certainly would prefer to write it in Rust. It would be a C implementation for people who don't like C.
- skitter 4y agoI have asked this question before, but why write an entirely new frontend, which is an enormous task if you want to reach a similar quality to rustc? rustc_codegen_gcc¹ adds gcc as a backend to rustc alongside llvm, miri and (wip) cranelift. As a result, it always works with the newest version of rust and is already nearly complete after less work. ¹https://github.com/rust-lang/rust/tree/master/compiler/rustc_codegen_gcc https://github.com/rust-lang/rust/tree/master/compiler/rustc...
- whyarewheher 4y agoWhy not do it? There are lots of reasons to have multiple implementations of a language, one of them being gcc is much easier to bootstrap than rustc
- skitter 4y agorustc got bootstrapped already, so download it. If you want to run the compiler itself on a new architecture, cross-compile. If you still decide to bootstrap it again, that's something that will only need to be done once. And even in that case, you can use the second implementation that already exists, mrustc.
- kangalioo 4y agoI've wondered about this for ages and now know: the people who work on GCCRS wouldn't work on rustc_codegen_gcc for one reason or another (familiarity, culture, personal ideals...?). So GCCRS is not "eating away" at available bandwidth and there's no reason not to let GCCRS developers do their thing, even if rustc_codegen_gcc is a more straightforward way of achieving most goals
- IshKebab 4y agoIt's probably not hugely useful from a "I want to compile this Rust code" point of view but I imagine it will at least help iron out ambiguities and bugs in the various specs people are working on. I think there's at least MiniRust and the Ferrocene Language Specification: https://www.youtube.com/watch?v=eFpHadbv34I https://www.youtube.com/watch?v=eFpHadbv34I https://spec.ferrocene.dev/ https://spec.ferrocene.dev/
- rurban 4y agoTheir base62 implementation really looks unreviewed. A static 64 byte array for 62 bytes...