From owner-freebsd-toolchain@freebsd.org Fri Jan 5 12:57:41 2018 Return-Path: Delivered-To: freebsd-toolchain@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 04D8BEA7B14 for ; Fri, 5 Jan 2018 12:57:41 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id E159367B61 for ; Fri, 5 Jan 2018 12:57:40 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: by mailman.ysv.freebsd.org (Postfix) id DDBF5EA7B13; Fri, 5 Jan 2018 12:57:40 +0000 (UTC) Delivered-To: toolchain@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 DB907EA7B12 for ; Fri, 5 Jan 2018 12:57:40 +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 87C5167B5F; Fri, 5 Jan 2018 12:57:37 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from coleburn.home.andric.com (coleburn.home.andric.com [192.168.0.15]) (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 DBE8945743; Fri, 5 Jan 2018 13:57:33 +0100 (CET) From: Dimitry Andric Message-Id: <41A329D5-0554-4450-A675-718F32A29EBF@FreeBSD.org> Content-Type: multipart/signed; boundary="Apple-Mail=_302B3B81-9735-4AB0-8D29-518B7B2E850D"; protocol="application/pgp-signature"; micalg=pgp-sha1 Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: Re: Is -march/-mtune=native actually supported on FreeBSD arm* or aarch64? Date: Fri, 5 Jan 2018 13:57:33 +0100 In-Reply-To: Cc: toolchain@freebsd.org, linimon@freebsd.org To: Jan Beich References: X-Mailer: Apple Mail (2.3273) X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.25 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, 05 Jan 2018 12:57:41 -0000 --Apple-Mail=_302B3B81-9735-4AB0-8D29-518B7B2E850D Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 5 Jan 2018, at 06:52, Jan Beich wrote: > > Some ports pass -march=native and/or -mtune=native. Both are extensively > documented by GCC for x86. For other architectures some excerpts say > "native" is only supported on Linux (via /proc/cpuinfo). For example, > > $ uname -p > armv6 > $ echo 'int main() {}' >a.c > $ clang -march=native a.c > clang: error: the clang compiler does not support '-march=native' > $ clang -mtune=native a.c > $ pkg install -qy gcc7 > $ gcc7 -march=native a.c > $ gcc7 -mtune=native a.c > > $ uname -p > aarch64 > $ echo 'int main() {}' >a.c > $ clang -march=native a.c > clang: error: the clang compiler does not support '-march=native' > $ clang -mtune=native a.c > clang: error: the clang compiler does not support '-mtune=native' > $ pkg install -qy gcc7 > $ gcc7 -march=native a.c > $ gcc7 -mtune=native a.c > > What's the rationale for Clang vs. GCC difference? Is it safe to run > FreeBSD arm* -mtune=native binaries on CPUs older than build machine? On non-x86, llvm has not implemented CPU detection, as far as I know. And since we don't export any CPU identification sysctl or even a /proc/cpuinfo, getting that information from userland is tricky. (I've seen programs that attempt to parse /var/run/dmesg.boot, but it is very error-prone, obviously.) It is safer to just specify the target CPU explicitly, IMO. -Dimitry --Apple-Mail=_302B3B81-9735-4AB0-8D29-518B7B2E850D 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 iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCWk92PQAKCRCwXqMKLiCW o4xoAJ9beS3z/uwkg8xamoG7bbTIUNpXgwCgjUNp96orf4z3tekSrEtx5dEtlbo= =rR2M -----END PGP SIGNATURE----- --Apple-Mail=_302B3B81-9735-4AB0-8D29-518B7B2E850D--