From owner-freebsd-arm@freebsd.org Sat Oct 28 11:12:16 2017 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 44299E3F5ED; Sat, 28 Oct 2017 11:12:16 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from tensor.andric.com (tensor.andric.com [87.251.56.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DABD56C561; Sat, 28 Oct 2017 11:12:15 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from [IPv6:2001:470:7a58::5d71:227a:7bb3:8fe3] (unknown [IPv6:2001:470:7a58:0:5d71:227a:7bb3:8fe3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 1BB16FAED; Sat, 28 Oct 2017 13:12:07 +0200 (CEST) From: Dimitry Andric Message-Id: Content-Type: multipart/signed; boundary="Apple-Mail=_4487EF25-E903-4C28-9200-AB2D7E95F7F3"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: lib/clan/llvm.build.mk: Shouldn't BUILD_TRIPLE definition rely host 'cc -dumpmachine'? Date: Sat, 28 Oct 2017 13:11:59 +0200 In-Reply-To: Cc: freebsd-toolchain@freebsd.org, freebsd-arm@freebsd.org To: =?utf-8?Q?Eddy_Petri=C8=99or?= References: X-Mailer: Apple Mail (2.3273) X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 28 Oct 2017 11:12:16 -0000 --Apple-Mail=_4487EF25-E903-4C28-9200-AB2D7E95F7F3 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 On 27 Oct 2017, at 08:23, Eddy Petri=C8=99or = wrote: >=20 > I am trying to make the FreeBSD code base build from a Linux host and > found this bit which defines BUILD_TRIPLE in a way which to my > untrained eyes look like overengineering. >=20 > .if ${TARGET_ARCH:Marmv6*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} = =3D=3D "") > TARGET_ABI=3D -gnueabihf > .elif ${TARGET_ARCH:Marm*} > TARGET_ABI=3D -gnueabi > .else > TARGET_ABI=3D > .endif > VENDOR=3D unknown > OS_VERSION=3D freebsd12.0 >=20 > TARGET_TRIPLE?=3D > = ${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}${T= ARGET_ABI} > BUILD_TRIPLE?=3D > ${BUILD_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION} I don't see much overengineering here? :) We simply trust BUILD_ARCH, as it is passed in by the top-level Makefile.inc1. This is how most of these down-level Makefiles work. Running all kinds of commands to figure out architectures and the like should be avoided in such Makefiles. > To support a Linux host I made these changes that is using 'cc > -dumpmachine' to get the correct BUILD_TRIPLE, Unfortunately, this is the wrong option to do so. The gcc manual says: -dumpmachine Print the compiler=E2=80=99s target machine (for example, = =E2=80=98i686-pc-linux-gnu=E2=80=99) -and don=E2=80=99t do anything else. E.g, it prints the *target* tripe, not the build triple. > but I am wondering if > it shouldn't be OK for building on a FreeBSD host >=20 > .if ${TARGET_ARCH:Marmv6*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} = =3D=3D "") > TARGET_ABI=3D -gnueabihf > .elif ${TARGET_ARCH:Marm*} > TARGET_ABI=3D -gnueabi > .else > TARGET_ABI=3D > .endif > VENDOR=3D unknown > OS_VERSION=3D freebsd12.0 > +BUILD_OS!=3D uname -s > + Again, this should be set by the top-level Makefiles, not in this one. >=20 > TARGET_TRIPLE?=3D > = ${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}${T= ARGET_ABI} > +.if ${BUILD_OS} =3D=3D FreeBSD > BUILD_TRIPLE?=3D > ${BUILD_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION} > +.else > +HOST_CC_DUMPMACHINE!=3D cc -dumpmachine > +BUILD_TRIPLE?=3D ${HOST_CC_DUMPMACHINE} > +.endif >=20 > What do you think, should the code be instead: >=20 > .if ${TARGET_ARCH:Marmv6*} && (!defined(CPUTYPE) || ${CPUTYPE:M*soft*} = =3D=3D "") > TARGET_ABI=3D -gnueabihf > .elif ${TARGET_ARCH:Marm*} > TARGET_ABI=3D -gnueabi > .else > TARGET_ABI=3D > .endif > VENDOR=3D unknown > OS_VERSION=3D freebsd12.0 >=20 > TARGET_TRIPLE?=3D > = ${TARGET_ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-${VENDOR}-${OS_VERSION}${T= ARGET_ABI} > +HOST_CC_DUMPMACHINE!=3D cc -dumpmachine > +BUILD_TRIPLE?=3D ${HOST_CC_DUMPMACHINE} No, this is definitely incorrect, as stated above. -Dimitry --Apple-Mail=_4487EF25-E903-4C28-9200-AB2D7E95F7F3 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.2 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCWfRl/wAKCRCwXqMKLiCW o8fKAJ9cFTHTwp5Xa5nkDxxiefnU9mgmhACgiunmA7tOZhsUH2EPq4GNJQ5Ruqc= =9N23 -----END PGP SIGNATURE----- --Apple-Mail=_4487EF25-E903-4C28-9200-AB2D7E95F7F3--