6 ms·
Maybe this compiler could help with bootstrapping the official rust compiler. At the moment, it seems to be quite a mess for packagers. Rust is written in Rust,
by raimue 9y ago
Maybe this compiler could help with bootstrapping the official rust compiler. At the moment, it seems to be quite a mess for packagers. Rust is written in Rust, but also needs cargo to build, which is also written in Rust. To break this circular dependency chain, you need to have pre-compiled binaries first in order to bootstrap the build process.
- steveklabnik 9y agoThat's one of the goals, yeah. The author is working on Cargo now.
- mitchty 9y agoThis is true of a lot of languages, go, haskell (even more once shake becomes the build system for it) etc... It makes porting things... interesting.
- steveklabnik 9y agoUsually you port by cross compiling an initial compiler, and bootstrapping from there.
- binarycrusader 9y agoSpeaking from personal experience, that can be quite painful. Being able to build rust and cargo, even if only for bootstrapping when porting, would truly be a wondrous thing.
- fmap 9y agoWhy, we could always use emscripten to compile rustc to JavaScript and use that for bootstrapping! On a more serious note, ghc at least solved this problem by allowing you to compile Haskell to C (-fvia-C). Writing a naive C code generator from whatever your backend is using is probably not that hard.
- pjmlp 9y agoOr by making use of an interpreter as first stage.
- Kubuxu 9y agoGo bootstrap uses Go1.4 which compiler is written in C. So: compile Go1.4 and use that to compile the Go 1.X compiler (I don't know but multiple steps might be necessary).
- __david__ 9y agoI don’t see why that’s an issue. Can you name a C compiler that distros use that isn’t written in C?
- steveklabnik 9y agogcc and clang are both C++ in my understanding. Regardless, those compilers are usually grandfathered in; distro policies are different for other languages. It just depends.
- kazinator 9y agoEven the C++ front end in GCC is written in C. https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/cp https://gcc.gnu.org/git/?p=gcc.git;a=tree;f=gcc/cp
- microcolonel 9y agoTechnically not only C anymore, not sure about the C++ frontend specifically, but there is C++ in GCC since... 5? 4?
- xioxox 9y agoSome of those files are C++!
- deleted 9y ago[deleted]
- pjmlp 9y agoIt looks like C, but actually it is common subset from C++. GCC has migrated to C++ in 2008. https://lwn.net/Articles/542457/ https://lwn.net/Articles/542457/
- kazinator 9y agoAny carefully written C program that doesn't use certain C99 an C11 things can be said to be C++. My language implementation compiles as C and C++. Every so often I build it as C++ (like before releases) to check for regressions and flush out any issues caught by the C++ compiler. I don't think of it as "written in C++", though it is not technically a false statement. All Scheme programs are really written in Common Lisp; they just need a suitable library of macros and functions ...
- hsivonen 9y agoOf the distros, Fedora has the strictest compiler bootstrapping policy, and Fedora seems to be doing great with Rust packaging (for a number of CPU architectures).
- jokr004 9y agoI've been beating my head against the wall for weeks trying to compile rustc/cargo on Openindiana. I want it so that I can compile a recent version firefox and/or thunderbird for Openindiana, both of which require rustc and cargo.
- dbaupp 9y agoThe typical route is to cross compile a compiler and cargo on another platform and then run the resulting binary. Is that approach infeasible for Openindiana?