30% Faster Rust Build Times using Cranelift instead of the LLVM
github.com
github.com
- this
- https://docs.rs/gimli/0.23.0/gimli/
- https://github.com/rust-lang/compiler-builtins
- https://github.com/redox-os/relibc
It finally possible to make Linux binaries in a high level language not involving anything written in C at build-time or run-time!!!
(And I think with CraneLift + -Z build-std, but without any libc, one should be able to skip linking separately-compiled object files too, and thus skip LLD and C++.)
That's going to be hard.
You're going to need an operating system, redox might work, not sure if it can run rustc yet.
Once you have the operating system you need the hardware, specifically the hardware not to be using C. I'm not sure how I would even go about testing that but even if I had a magic wand I don't think it would be easy to cobble together a computer... and I can't even use particularly exotic hardware because of the limited OS selection.
If we want pure Rust at, Redox or some tiny embedded thing is already no-C at runtime. The big novelty here is that build time is getting improved.
But I think the progress is still very important. It shows that Rust can do basically anything. Also, for the c dependencies Cargo uses, rust rewrites exist. reqwest, rustls, and various (currently highly immature) pure-rust git libraries like gitoxide/https://github.com/chrisdickinson/git-rs.
relibc is a genuine libc implementation. However, I do believe Rust on Redox might indeed not factor through relibc's C interface for everything, taking advantage of Rust being on both sides. That is like Go.
?
You can build the Go toolchain (and many other Go apps, so as long as they do not hard depend on C) with CGo disabled. I do not believe this is true.
Source, although it is self-evident for Go developers who dabble in cross-compilation. https://golang.org/doc/faq#What_compiler_technology_is_used_...
(I do think there are optional C dependencies, but that shouldn’t be important; you can go end-to-end without C with exceedingly few compromises.)
Wow, OK. Go's GC is in Go. I'm very jealous; I've wanted this for Haskell for a long time.
https://people.inf.ethz.ch/wirth/ProjectOberon/Sources/Kerne...
Or the JikeRVM implementation in Java.
https://github.com/JikesRVM/JikesRVM/tree/52582fa1c519d48fe0...
-- what's this part mean? Does cranelift have an option to directly make locally-resolved executables without external references somehow?
I don't know for sure, but because of Cranelift's origins as a JIT for wasm, I suspect that it does.
"wasm backend" sounds like you were thinking the latter?
Go has multiple implementations, only the reference one is pure Go, gogcc and the llvm variants are naturally a mix of Go and C++.
Regarding the bootstrapping point, rustc was bootstrapped via a "rustboot" compiler written in ocaml. Doesn't make the rust compiler any less rust now, as it compiles itself nowadays (to be precise, version N compiles version N+1, and also supports compiling version N, at least for bootstrap purposes).
Virgil has been doing this for years.
The C code in the repo is used for a few benchmarking and testing harnesses. It is not used in the runtime or compiler or libraries.
[1] https://blog.rust-lang.org/inside-rust/2020/11/15/Using-rust...
I use them both and appreciate their different strengths. There’s no question that the existence of llvm spurred gcc to improve a lot, and vice versa.
The most dangerous aspect of this is the cargo cult of not thinking out of the box regarding alternatives.
Clang, in turn, only supports C, C++, Obj-C, and Obj-C++, so that's 4 frontend languages.
Edit: But yes, as 'Gaelan notes, I think they meant compiler backends.
It's a fast but not-much-optimizing code gen which is complementing LLVM for the use-case where you want to fastly spit out code but don't care much about optimizing it, beyond "simple"/"basic" optimizations.
Besides that why do you think there should be LLVM IR to cranelift coversions? I just can't find any use-case for which is makes sense as it's always simpler and more efficient to generate cranelift IR from MIR instead of generating LLVM IR and then trying to convert it to cranelift.
Wasm is in the end close to a form of high level assembly. Which means it is (should be) already preoptimized as much as needed/wanted/possible.
Cranelift still needs to do some optimizations, especially wrt. platform specific aspects like register allocations and similar.
In the end you don't want long load times when using wasm (at least in the web browser maybe in other places too).
Through maybe in the future you might have some options to opt-in to some more time intensive optimizations for e.g. in browser gaming. But then rust could just not opt-in.
Exciting times :)
But seriously: I wonder if it would help to generate the code needed to compile code that depends on a specific collection of crates, and then compile and run that. Something drastic needs to be done. Apologetics are not carrying the day.
At one point I recall people complaining that you couldn't build 32 bit Rust on the target machine because the compiler couldn't squeeze itself into a couple gigs of memory. I'm curious if we are still in cross-compiler territory there or if the last few generations of improvements have done much for that limitation.
To be fair, gcc requires contributors to assign copyright to the FSF or dedicate their work into the public domain. Neither of which is required by the GPL's copyleft so if Apple used gcc, they could still make changes that can't be upstreamed due to gcc's policy.
Device code, most likely. Using cranelift for TCG would be interesting, but right now the major concern is attack surface of emulated devices.
It is possible to have both.
While you are developing you get a JIT based enviroment with the productivity workflow one knows from languages like Java and .NET (MELT VM).
Then when it comes to a proper release, you use the AOT compiler which uses C or C++ based compiler as part of the build workflow (Eiffel AOT compiler generates C or C++ code as its intermediate format).
So you get the quick edit-compile-debug workflow, and when feeling like doing a full release build just let the C or C++ compiler do its job.
There are other examples, I just choose Eiffel as one of thm.
Could someone more enlightened share an overview of Cranelift's capability in handling deep learning relevant compiling tasks: gemm optimization, data flow, scheduling, GPU backend, etc?
Also, it seems Cranelift only has one IR format as the interface to the language frontend. Does it have things like MLIR to bridge diverse optimization needs of multiple different languages?
So I would expect it to have very little overlap with deep learning. No high-level optimizations to do with matrices or dataflow or scheduling; currently no GPU backends; no integration with MLIR (though that one seems completely doable if someone put in the effort).
If you have other stats, I'd love to see them. I imagine that c++ numbers don't translate over into rust 1:1.