Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Jun 2011 13:16:48 -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:  <BF24BE90-48B7-48A0-90FE-234C28AE9CA9@bsdimp.com>
In-Reply-To: <15B76B64-D26E-420D-AE37-B52A694CDF98@gmail.com>
References:  <D0F647ED-4AB2-4A61-AD37-423F0AF9805D@gmail.com> <C29B8240-9D19-46CC-A1FC-1B9150547B1D@bsdimp.com> <15B76B64-D26E-420D-AE37-B52A694CDF98@gmail.com>

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

On Jun 17, 2011, at 12:38 PM, Damjan Marion wrote:

>=20
> On Jun 17, 2011, at 7:29 PM, Warner Losh wrote:
>=20
>> Shouldn't you be modifying the CFLAGS and CXXFLAGS instead of CC and =
CXX?
>>=20
>> Warner
>=20
>=20
> Right, must be some "smart" reason why I used CC and CXX, but now I =
don't remember why.

Redefining CC usually leads to tears, since it blurs the host compiler =
and the cross compiler.

> 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.

Warner



>=20
>=20
>=20
> make CC=3Dclang CXX=3Dclang++ TARGET=3Darm TARGET_CPUTYPE=3Dcortex-a9  =
-DNO_CLEAN _libraries
>=20
> --------------------------------------------------------------
>>>> stage 4.2: building libraries
> --------------------------------------------------------------
> cd /usr/src-svn;  MAKEOBJDIRPREFIX=3D/zfs/data2/src/obj/arm.arm  =
MACHINE_ARCH=3Darm  MACHINE=3Darm  CPUTYPE=3Dcortex-a9 =
GROFF_BIN_PATH=3D/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/legacy/usr/bin=
  =
GROFF_FONT_PATH=3D/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/legacy/usr/sh=
are/groff_font  =
GROFF_TMAC_PATH=3D/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/legacy/usr/sh=
are/tmac CFLAGS=3D"-O2 -pipe  -v -ccc-host-triple arm-unknown-freebsd"  =
CXXFLAGS=3D"-O2 -pipe -ccc-host-triple arm-elf-freebsd"  =
_SHLIBDIRPREFIX=3D/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp  =
VERSION=3D"FreeBSD 9.0-CURRENT i386 900036"  INSTALL=3D"sh =
/usr/src-svn/tools/install.sh"  =
PATH=3D/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/legacy/usr/sbin:/zfs/dat=
a2/src/obj/arm.arm/usr/src-svn/tmp/legacy/usr/bin:/zfs/data2/src/obj/arm.a=
rm/usr/src-svn/tmp/legacy/usr/games:/zfs/data2/src/obj/arm.arm/usr/src-svn=
/tmp/usr/sbin:/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/bin:/zfs/data=
2/src/obj/arm.arm/usr/src-svn/tmp/usr/games:/sbin:/bin:/usr/sbin:/usr/bin =
make -f Makefile.inc1 DESTDIR=3D/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp=
 -DNO_FSCHG -DWITHOUT_HTML -DWITHOUT_INFO -DNO_LINT  -DWITHOUT_MAN =
-DWITHOUT_PROFILE libraries
> cd /usr/src-svn;  make -f Makefile.inc1 _prereq_libs;  make -f =
Makefile.inc1 _startup_libs;  make -f Makefile.inc1 _prebuild_libs;  =
make -f Makefile.inc1 _generic_libs;
> =3D=3D=3D> gnu/lib/libssp/libssp_nonshared (obj,depend,all,install)
> sh /usr/src-svn/tools/install.sh -C -o root -g wheel -m 444   =
libssp_nonshared.a /zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib
> =3D=3D=3D> gnu/lib/libgcc (obj,depend,all,install)
> sh /usr/src-svn/tools/install.sh -C -o root -g wheel -m 444   =
libgcc_eh.a /zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib
> =3D=3D=3D> lib/libcompiler_rt (obj,depend,all,install)
> sh /usr/src-svn/tools/install.sh -C -o root -g wheel -m 444   =
libcompiler_rt.a /zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib
> /zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib/libgcc.a -> =
libcompiler_rt.a
> =3D=3D=3D> gnu/lib/csu (obj,depend,all,install)
> sh /usr/src-svn/tools/install.sh -o root -g wheel -m 444  crtbegin.o =
/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib/crtbegin.o
> sh /usr/src-svn/tools/install.sh -o root -g wheel -m 444  crtend.o =
/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib/crtend.o
> sh /usr/src-svn/tools/install.sh -o root -g wheel -m 444  crtbeginT.o =
/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib/crtbeginT.o
> sh /usr/src-svn/tools/install.sh -o root -g wheel -m 444  crtbegin.So =
/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib/crtbeginS.o
> sh /usr/src-svn/tools/install.sh -o root -g wheel -m 444  crtend.So =
/zfs/data2/src/obj/arm.arm/usr/src-svn/tmp/usr/lib/crtendS.o
> =3D=3D=3D> lib/csu/arm (obj,depend,all,install)
> clang -O2 -pipe  -v -ccc-host-triple arm-unknown-freebsd =
-mcpu=3Dcortex-a9 -I/usr/src-svn/lib/csu/arm/../common  =
-I/usr/src-svn/lib/csu/arm/../../libc/include -std=3Dgnu99 =
-Wsystem-headers -Wall -Wno-format-y2k -W -Wno-unused-parameter =
-Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type =
-Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter =
-Wcast-align -Wchar-subscripts -Winline -Wnested-externs =
-Wredundant-decls -Wold-style-definition -Wno-pointer-sign -c -o crt1.o =
crt1.s
> FreeBSD clang version 3.0 (trunk 130700) 20110502
> Target: arm-unknown-freebsd
> Thread model: posix
> clang: warning: argument unused during compilation: '-O2'
> clang: warning: argument unused during compilation: '-mcpu=3Dcortex-a9'
> clang: warning: argument unused during compilation: '-I =
/usr/src-svn/lib/csu/arm/../common'
> clang: warning: argument unused during compilation: '-I =
/usr/src-svn/lib/csu/arm/../../libc/include'
> clang: warning: argument unused during compilation: '-std=3Dgnu99'
> clang: warning: argument unused during compilation: '-Wsystem-headers'
> clang: warning: argument unused during compilation: '-Wall'
> clang: warning: argument unused during compilation: '-Wno-format-y2k'
> clang: warning: argument unused during compilation: '-W'
> clang: warning: argument unused during compilation: =
'-Wno-unused-parameter'
> clang: warning: argument unused during compilation: =
'-Wstrict-prototypes'
> clang: warning: argument unused during compilation: =
'-Wmissing-prototypes'
> clang: warning: argument unused during compilation: '-Wpointer-arith'
> clang: warning: argument unused during compilation: '-Wreturn-type'
> clang: warning: argument unused during compilation: '-Wcast-qual'
> clang: warning: argument unused during compilation: '-Wwrite-strings'
> clang: warning: argument unused during compilation: '-Wswitch'
> clang: warning: argument unused during compilation: '-Wshadow'
> clang: warning: argument unused during compilation: =
'-Wunused-parameter'
> clang: warning: argument unused during compilation: '-Wcast-align'
> clang: warning: argument unused during compilation: =
'-Wchar-subscripts'
> clang: warning: argument unused during compilation: '-Winline'
> clang: warning: argument unused during compilation: '-Wnested-externs'
> clang: warning: argument unused during compilation: =
'-Wredundant-decls'
> clang: warning: argument unused during compilation: =
'-Wold-style-definition'
> clang: warning: argument unused during compilation: =
'-Wno-pointer-sign'
> "/usr/bin/as" -o crt1.o crt1.s
> crt1.s: Assembler messages:
> crt1.s:11: Error: too many memory references for `mov'
> crt1.s:12: Error: too many memory references for `mov'
> crt1.s:13: Error: too many memory references for `mov'
> crt1.s:15: Error: no such instruction: `ldr r0,[sp,'
> crt1.s:16: Error: too many memory references for `add'
> crt1.s:17: Error: too many memory references for `add'
> crt1.s:18: Error: too many memory references for `add'
> crt1.s:20: Error: no such instruction: `bic sp,sp,'
> crt1.s:21: Error: too many memory references for `sub'
> crt1.s:22: Error: invalid char '[' beginning operand 2 `[sp'
> crt1.s:23: Error: invalid char '[' beginning operand 2 `[sp'
> crt1.s:25: Error: no such instruction: `b __start'
> clang: error: assembler command failed with exit code 1 (use -v to see =
invocation)
> *** Error code 1
>=20
> Stop in /usr/src-svn/lib/csu/arm.
> *** Error code 1
>=20
> Stop in /usr/src-svn.
> *** Error code 1
>=20
> Stop in /usr/src-svn.
> *** Error code 1
>=20
> Stop in /usr/src-svn.
> *** Error code 1
>=20
> Stop in /usr/src-svn.
>=20
>=20
>=20
>=20




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BF24BE90-48B7-48A0-90FE-234C28AE9CA9>