5 ms·
Just one question, as suggested by the title: the rust compiler itself could be made portable using this? I guess not, because of its use of multi-threading.
by childintime 4y ago
Just one question, as suggested by the title: the rust compiler itself could be made portable using this? I guess not, because of its use of multi-threading.
- rkangel 4y agoYou probably could, but that would be less useful than you think. There are two machines that you care about with a compiler: the machine the compiler is running on ("Host"), and the machine the compiler is producing code for ("Target"). Generally we use a compiler with the same Host and Target - if you use Rust on x64-Windows you get a binary that runs on x64-Windows. If you use it on ARM-Linux you get a binary that runs on ARM-Linux. What you are talking about is making a compiler that would run on all Hosts, but it would take different work to make it be able to produce code for all Targets. So you'd produce a compiler that targeted x86-Windows and it would run on x86-Linux but still produce code for x86-Windows. It would also NOT be able to run on ARM-Linux. [For completeness there's actually three machines we talk about with compilers - in addition to Host and Target there is also "Build". This allows you to cross-compile your compiler. For example you want to build your compiler on x86, you want the resulting compiler to run on ARM, and when it runs it produces code for RISC-V. Here Build is x86, Host is ARM and Target is RISC-V.]
- TazeTSchnitzel 4y agoBut the “actually portable executable” is a single target and runs on many platforms, surely a rustc compiled as an APE for APE would be useful?
- rkangel 4y agoOh I see! You mean "built as an APE and targeting APE". That would indeed be an interesting idea.
- mastax 4y ago> What you are talking about is making a compiler that would run on all Hosts, but it would take different work to make it be able to produce code for all Targets. This is already how rustc works, it is not like GCC. Any rustc can (cross-)compile for any target, as long as you have the rlibs for that target, your libllvm has those targets enabled, and you have the appropriate linker. Rustup usually manages all that for you.