From owner-freebsd-toolchain@FreeBSD.ORG Fri Jun 17 19:20:19 2011 Return-Path: Delivered-To: toolchain@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6A821106564A for ; Fri, 17 Jun 2011 19:20:19 +0000 (UTC) (envelope-from imp@bsdimp.com) Received: from harmony.bsdimp.com (bsdimp.com [199.45.160.85]) by mx1.freebsd.org (Postfix) with ESMTP id 1DF5D8FC0C for ; Fri, 17 Jun 2011 19:20:19 +0000 (UTC) Received: from [10.30.101.53] ([209.117.142.2]) (authenticated bits=0) by harmony.bsdimp.com (8.14.4/8.14.3) with ESMTP id p5HJGul9033418 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES128-SHA bits=128 verify=NO); Fri, 17 Jun 2011 13:17:00 -0600 (MDT) (envelope-from imp@bsdimp.com) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: <15B76B64-D26E-420D-AE37-B52A694CDF98@gmail.com> Date: Fri, 17 Jun 2011 13:16:48 -0600 Content-Transfer-Encoding: quoted-printable Message-Id: References: <15B76B64-D26E-420D-AE37-B52A694CDF98@gmail.com> To: Damjan Marion X-Mailer: Apple Mail (2.1084) X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.0.1 (harmony.bsdimp.com [10.0.0.6]); Fri, 17 Jun 2011 13:17:00 -0600 (MDT) Cc: toolchain@FreeBSD.org Subject: Re: cross-compiling for arm with clang X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Jun 2011 19:20:19 -0000 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