Peter M
Peter M

Reputation: 1998

How do you put together a cross-compiler for yourself?

I'm sort of surprised that I can't find much info on how to put together a cross-architecture or cross-os compiler using llvm, from scratch. llvm itself works out of the box. Then you just need to gather the sysroot from the target system, and then somehow generate and integrate cross-platform binutils?

While I have a huge number of random use cases, my immediate annoyance is with CodeSourcery being ... basically gone for targeting arm/linux, building on Windows.

Upvotes: 3

Views: 961

Answers (1)

Richard Pennington
Richard Pennington

Reputation: 19985

I'm working on a cross compilation tool chain based on clang/LLVM. It currently runs on various Linux platforms (ARM, Mips, PowerPC, x86) and Windows x86. I try to stay up to date with the current LLVM source tree and bring in the latest versions of binutils, GDB, etc. as they get released.(see http://ellcc.org/blog/?page_id=467). I had a few major design goals for the project, but two were top priority. I wanted the entire tool chain to be able to build itself, which it does for all the Linux targets, and in the spirit of clang, I wanted as few support binaries as possible. To that end, I build binutils with options for most of the executables to support all of the targets. Each processor gets its own as (which LLVM is eliminating the need for as more internal assembler support becomes available), but I build just one ld, objdump, gdb, etc, that can handle all the different targets.

From a clean source install, I first build clang/LLVM and binutils/GDB with gcc, then I build all the libraries (C/C++, compiler-rt, etc.) for all the targets. A second, optional build uses the newly built tools to compile themselves. After that, subsequent builds are self hosting.

I build all the tools for the various hosts on my x86 Linux box, but each tool chain should in theory be able to recreate themselves on the other Linux hosts or on Windows.

If you're interested in pre-built binaries, they are available at http://ellcc.org/blog/?page_id=20295

Upvotes: 4

Related Questions