Date: Fri, 5 Jan 2018 13:57:33 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: Jan Beich <jbeich@FreeBSD.org> Cc: toolchain@freebsd.org, linimon@freebsd.org Subject: Re: Is -march/-mtune=native actually supported on FreeBSD arm* or aarch64? Message-ID: <41A329D5-0554-4450-A675-718F32A29EBF@FreeBSD.org> In-Reply-To: <d12o-am47-wny@FreeBSD.org> References: <d12o-am47-wny@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On 5 Jan 2018, at 06:52, Jan Beich <jbeich@FreeBSD.org> 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
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.2
iF0EARECAB0WIQR6tGLSzjX8bUI5T82wXqMKLiCWowUCWk92PQAKCRCwXqMKLiCW
o4xoAJ9beS3z/uwkg8xamoG7bbTIUNpXgwCgjUNp96orf4z3tekSrEtx5dEtlbo=
=rR2M
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?41A329D5-0554-4450-A675-718F32A29EBF>
