8 ms·
I don’t see why that’s an issue. Can you name a C compiler that distros use that isn’t written in C?
by __david__ 9y ago
I 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 ...
- readittwice 9y agoNo, they use C++ even for the C front-end. But you are right, you can still see its C past in the source code. What's important though is that the GCC devs actively try to avoid the newest C++-features, this allows it to compile current GCC-trunk even with very old GCC-Releases. IIRC even GCC 4.3 (released in March 2008) is able to compile current trunk (GCC 8.0). This is somewhat different for Rust, where I think the current policy is that master needs to compile with last released version (releases every 6 weeks and just to make it clear: Rust is written in Rust). Before that, the compiler was updated even more frequently. Bootstrapping Rust from 0 therefore is quite hard, since Rust is far from being as ubiquitous as C/C++-compilers. Even if you already have a rustc on your system, it's not unlikely that it is too old for compiling Rust-master. The first Rust-compiler was written in OCaml, so you need to compile that first, then compile Rust commit-for-commit until you reach current master. This could take quite some time. IMHO this is why mrustc is great, since you just compile current master (if it supports all features) with it and then use the generated compiler to compile Rust.
- deleted 9y ago[deleted]
- raimue 9y agoC compilers are ubiquituous. Name a platform which does not have at least one C compiler. Rust might come into such a position at some later time as well, but until then at least a transitional solution besides cross-compiling would make packaging easier and reproducible.
- andrewflnr 9y agoReally, the solution is just to make cross compiling as easy as any other kind. Compilation is basically a pure function, so by rights compilers with different targets should be drop-in replacements of each other.
- jjoonathan 9y ago> Compilation is basically a pure function Sure, a pure function taking the universe as an argument.
- alphaalpha101 9y agoNo, a pure function taking the original source code as the only argument.
- andrewflnr 9y agoExactly. There's no reason a compiler should take any input but the source (maybe some config) nor have any output but the translated code. There's no dependence on running on a particular piece of hardware in this equation. Just run the codegen for platform Y on platform X.
- coldtea 9y agoWouldn't it need to link to native libraries, and thus require you to have all those around too?
- 9y ago
- kazinator 9y agoCan you name a C compiler that distros use that isn't GCC or Clang?
- SAI_Peregrinus 9y agoMSVC. Yeah, Windows isn't a "distro" but it is a major OS and MSVC is a pretty major compiler. But it's binary only so there's no need to bootstrap it unless you're working at MS.
- fooker 9y agoActually, yes. GCC and Clang are both written in C++ now.
- coldtea 9y ago>I don’t see why that’s an issue. Can you name a C compiler that distros use that isn’t written in C? Can you name a distro or environment that doesn't already have a C compiler at arm's reach? That's not the case with Rust compilers, which is obviously what the issue is.
- __david__ 9y agoNo, it's not obvious what the issue is. If you want to compile a C compiler, you need a C compiler binary. If you want to compile a rust compiler, you need a rust compiler binary. It's the exact same issue, but people don't whine about the C compiler, probably because it's been that way for 50 years.
- xoroshiro 9y agoI don't get the issue as well, but maybe from ignorance. Can't I just get the rust compiler in LLVM's IR form and bootstrap from there?
- tmzt 9y agoLLVM IR is still very targeted to the architecture it will be run on, it's not intended to be a portable representation.