Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 21 Jun 2011 11:06:17 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Damjan Marion <damjan.marion@gmail.com>
Cc:        toolchain@FreeBSD.org
Subject:   Re: cross-compiling for arm with clang
Message-ID:  <AC8BF81A-2EF4-48FF-ABDE-E928C1B4A06E@bsdimp.com>
In-Reply-To: <8E65FA9C-330B-4055-8959-75EE06E557E8@gmail.com>
References:  <D0F647ED-4AB2-4A61-AD37-423F0AF9805D@gmail.com> <C29B8240-9D19-46CC-A1FC-1B9150547B1D@bsdimp.com> <15B76B64-D26E-420D-AE37-B52A694CDF98@gmail.com> <BF24BE90-48B7-48A0-90FE-234C28AE9CA9@bsdimp.com> <8E65FA9C-330B-4055-8959-75EE06E557E8@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

On Jun 21, 2011, at 3:12 AM, Damjan Marion wrote:

>=20
> On Jun 17, 2011, at 9:16 PM, Warner Losh wrote:
>=20
>>=20
>> On Jun 17, 2011, at 12:38 PM, Damjan Marion wrote:
>>=20
>>> Now, I'm back on my original problem, clang invokes /usr/bin/as =
which is i386 AS instead of ARM version in obj tree.
>>=20
>> 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.
>>=20
>>> How this works on other platforms (i.e. cross-compiling for amd64)?
>>=20
>> 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).
>>=20
>> It works by accident for i386 on amd64, I think.  as treats the more =
or less as the same.
>=20
> 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.
>=20
> For me it works well, even when I use clang on Darwin host, it calls =
proper as/ld.
>=20
> # /opt/llvm/bin/clang -ccc-host-triple arm-unknown-freebsd =
-mfloat-abi=3Dsoft  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
>=20
>=20
> Is this what we need to support cross-compiling freebsd with clang?

As we do it today?  No.  Today we build the binaries as 'as' which are =
part of the buildworld.  These binaries aren't called =
arm-unknown-freebsd-as, but instead 'as'.

Do we want to switch? Maybe.

There's a make xdev target that installs both the =
/usr/arm-freebsd/usr/bin/as type files as well as symbolic links in =
/usr/local/bin/arm-freebsd-as.  But that target isn't part of =
buildworld.  It has been tested recently (it was broken for a while in =
8, and I'm not sure I've merged the patches over yet).  However, it =
doesn't include the extra bogus 'unknown' which if you were to have =
included it breaks many of the autoconf scripts that I ran into when I =
did this patch.  Also, I install things as =
/usr/local/bin/arm-freebsd9-as as well, since that's what we needed for =
gcc compatibility.  I suppose we could include a unknown thing.

However, you'd need to install symlinks to make this work in a =
build-world setting.

> Is there any other comment to this patch[1]?
>=20
>=20
> [1] =
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20110620/043072=
.html

Not enough of a llvm guy to know if this patch is good or bad.

Warner




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AC8BF81A-2EF4-48FF-ABDE-E928C1B4A06E>