cross-compiling for arm with clang

Damjan Marion damjan.marion at gmail.com
Tue Jun 21 09:12:31 UTC 2011


On Jun 17, 2011, at 9:16 PM, Warner Losh wrote:

> 
> On Jun 17, 2011, at 12:38 PM, Damjan Marion wrote:
> 
>> Now, I'm back on my original problem, clang invokes /usr/bin/as which is i386 AS instead of ARM version in obj tree.
> 
> That's a bogus assumption on the part of clang.  At the very least, it should be adding the magic gas flags to use the correct triple for the platform.  But if you did that, your next complaint would be that we only build as for the native architecture and not anything else.
> 
>> How this works on other platforms (i.e. cross-compiling for amd64)?
> 
> How it normally works is that we build a compiler that invokes the right as, ld, etc for the architecture in question.  Clang is clearly broken here in assuming that as can cope with anything other than native assembler :)  We normally either build gcc that knows where to find these files.  In the buildworld case, this is communicate with weird paths and shell variables.  With the whole 'xdev' series of targets (which are instructive to look at), we build into a specific location /usr/freebsd-xdev-arm/bin, etc).
> 
> It works by accident for i386 on amd64, I think.  as treats the more or less as the same.

I submitted a patch[1] to clang mailer which invokes xxx-yyy-zzz-as/ld based on -ccc-host-triple. Patch is copy of netbsd code which is already in clang.

For me it works well, even when I use clang on Darwin host, it calls proper as/ld.

# /opt/llvm/bin/clang -ccc-host-triple arm-unknown-freebsd -mfloat-abi=soft  test.c -o test -v -c
clang version 3.0 (http://llvm.org/git/clang.git 98138cdfdee05c0afbab2b209ce8cfe4a52474e1)
Target: arm-unknown-freebsd
Thread model: posix
[snip]
End of search list.
 "/opt/llvm/bin/arm-unknown-freebsd-as" -o test /var/folders/kb/kbDaYaFqFQaCg3mXbTLH5U+16gE/-Tmp-/cc-RMHOwf.s


Is this what we need to support cross-compiling freebsd with clang?
Is there any other comment to this patch[1]?


[1] http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20110620/043072.html



More information about the freebsd-toolchain mailing list