From owner-freebsd-toolchain@FreeBSD.ORG Tue Jun 21 21:31:49 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 1B9BF10656E4 for ; Tue, 21 Jun 2011 21:31:49 +0000 (UTC) (envelope-from damjan.marion@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 9B6468FC13 for ; Tue, 21 Jun 2011 21:31:48 +0000 (UTC) Received: by wwe6 with SMTP id 6so194686wwe.31 for ; Tue, 21 Jun 2011 14:31:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=2j97zLGtj+9+Vc3G6f57duNHVlZvBU963z/asmUpdKw=; b=eKPhE/0Xu/W4dVE/O4RlTgkx2HGx66YfjqKC1sWuyePh8LNaVeFwy0me4yXnUO++ZN YlAfTC1Hk5jufiK+eqrDo03xmZt1OWH9T76kQhgJ21JpGgDo9UDLf5jD/o7xA6av5r6y o2ADriT9uN2sUsoIue366JLO6wmwW+/TluVNQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=Q7w7Jy+UOiGxpKEXkGn8soJlt2NQa7UX1snkWMptJo8JbGkjmRRQKCoIZT8xjyaHIj 054eoCPuIM9qDV4ZUt7skwysWLL7vqjLsrPDXhHSMFFUO/VrS4aN21te0Dh/5HGWW4jY CPJOwif3OgBZ8tj+KuOt0xE19piJcFquHoYxQ= Received: by 10.227.177.72 with SMTP id bh8mr254354wbb.67.1308691907438; Tue, 21 Jun 2011 14:31:47 -0700 (PDT) Received: from [192.168.123.4] (cpe-109-60-79-155.zg3.cable.xnet.hr [109.60.79.155]) by mx.google.com with ESMTPS id et5sm4322256wbb.16.2011.06.21.14.31.45 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Jun 2011 14:31:46 -0700 (PDT) Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Damjan Marion In-Reply-To: Date: Tue, 21 Jun 2011 23:31:43 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <932DB8CA-22DA-495F-89AC-F547146780B6@gmail.com> References: <15B76B64-D26E-420D-AE37-B52A694CDF98@gmail.com> <8E65FA9C-330B-4055-8959-75EE06E557E8@gmail.com> To: Warner Losh X-Mailer: Apple Mail (2.1084) 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: Tue, 21 Jun 2011 21:31:49 -0000 On Jun 21, 2011, at 7:06 PM, Warner Losh wrote: >=20 > On Jun 21, 2011, at 3:12 AM, Damjan Marion wrote: >>=20 >> On Jun 17, 2011, at 9:16 PM, Warner Losh wrote: >>>=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? >=20 > 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'. >=20 > Do we want to switch? Maybe. Seems that clang will first try to run as/ld which is in the same = directory like clang. That is exactly what we have in /usr/obj/.../bin = so seems that buildworld should work out of the box. Problem with ARM is that clang is not build as part of cross-tools, so = clang from /usr/bin is called instead which also means that as/ld from = /usr/bin are used. --- share/mk/bsd.own.mk (revision 223366) +++ share/mk/bsd.own.mk (working copy) @@ -415,7 +415,7 @@ __T=3D${MACHINE_ARCH} .endif # Clang is only for x86 and 32-bit powerpc right now, by default. -.if ${__T} =3D=3D "amd64" || ${__T} =3D=3D "i386" || ${__T} =3D=3D = "powerpc" +.if ${__T} =3D=3D "amd64" || ${__T} =3D=3D "i386" || ${__T} =3D=3D = "powerpc" || ${__T} =3D=3D "arm" __DEFAULT_YES_OPTIONS+=3DCLANG .else Unfortunately this doesn't mean that cross-compiling works fine now for = ARM. It fails on building lib/libcompiler_rt. Here is output if anybody have idea how to fix it: = http://pastebin.com/Ly2jARjd Damjan