Page 1 of 1
How to cross compile a rust kernel with a default toolchain.
Posted: Wed Apr 08, 2015 1:49 am
by Layl
I'm looking to compile a rust kernel (preferably built with cargo) without any recompiling of GCC needed. Preferably this needs to work on MinGW or Cygwin out of the box. The goal with this is that I can give a really simple setup guide. I know that I can do the assembly part with nasm and the rust part with rustc/cargo without recompiling, but the linking part is a problem I don't know how to solve.
Re: How to cross compile a rust kernel with a default toolch
Posted: Wed Apr 08, 2015 6:53 am
by Octocontrabass
Building a
GCC Cross-Compiler works with MinGW out of the box (as long as you also installed MSYS).
I know that's not what you want to hear, but abusing OS-specific GCC for OS development is generally discouraged around here.
Re: How to cross compile a rust kernel with a default toolch
Posted: Wed Apr 08, 2015 7:07 am
by Layl
I am not looking at using OS-specific toolchains in such a way, rather I am looking at tools that can output binaries for a variety of platforms without recompiling the tool. Recompiling GCC unfortunately did not work for me out of the box with MinGW, so I do that on a VM with [insert linux distro here] instead when I need GCC for a specific platform.
Re: How to cross compile a rust kernel with a default toolch
Posted: Wed Apr 08, 2015 7:49 am
by zhiayang
clang, at least on OS X, supports the "-target" argument, which you can use to target x86_64-elf, or some ARM platform of your choice.
Re: How to cross compile a rust kernel with a default toolch
Posted: Thu Apr 09, 2015 1:17 am
by Icee
The canonical (I guess) way to compile with Rust in this case is by passing a .json file as a --target argument. Start your journey
here. For final linking, you'll still want a cross-compiled ld from binutils; although you
may end up well with just objcopy'ing to your desired output format with the stock binutils depending on your setup.
EDIT: in any case, as long as you don't have any C sources in your project, you don't need GCC at all.