Clang cross-compilation

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Clang cross-compilation

Andrew McGregor-3
I understand that clang is not yet ready to be a cross-compiler.  However, I'd like to fix that, so I'd like to know what the known issues are in order to start working on it, so I don't have to find them all out for myself.  Undoubtedly there will be unknown issues as well.

My intended targets are OpenWRT for various MIPS targets, and an embedded Linux for ethernet switches that runs on PowerPC and MIPS platforms.  Ideally, the aim would be to compile the whole distribution, but even portions of userspace would be valuable.

Thanks,

Andrew
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Clang cross-compilation

Douglas Gregor

On Sep 22, 2010, at 3:12 PM, Andrew McGregor wrote:

> I understand that clang is not yet ready to be a cross-compiler.  However, I'd like to fix that, so I'd like to know what the known issues are in order to start working on it, so I don't have to find them all out for myself.  Undoubtedly there will be unknown issues as well.
>
> My intended targets are OpenWRT for various MIPS targets, and an embedded Linux for ethernet switches that runs on PowerPC and MIPS platforms.  Ideally, the aim would be to compile the whole distribution, but even portions of userspace would be valuable.

Clang is naturally a cross-compiler, but it needs to know about the target and its ABI to generate code. Linux, FreeBSD, and Darwin for x86 and ARM are supported and well-tested; other platforms are likely to need work. There are a few places to start:

        Target definition: lib/Basic/Targets.cpp. Here are the predefined macros, the sizes of basic types, and other bits needed for Clang to properly parse code on that platform (e.g., with -fsyntax-only)
        Target ABI: lib/CodeGen/TargetInfo.cpp. Here's where we generate the IR needed to pass arguments for function calls within the target's ABI.

There may be LLVM back-end work as well, but someone else will have to chime in about that.

Clang doesn't yet have a clean user interface for using it as a cross-compiler. Currently, it involves manually passing various include paths, link library paths, libraries to link against, etc. That's the subject of the universal driver, which is described

        http://clang.llvm.org/UniversalDriver.html

but is not actively being worked on.

        - Doug


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev