]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
bsd.compiler.mk: Detect distribution-provided GCC when executed as cc
authorJessica Clarke <jrtc27@FreeBSD.org>
Tue, 9 Feb 2021 21:40:24 +0000 (21:40 +0000)
committerAlex Richardson <arichardson@FreeBSD.org>
Sat, 10 Apr 2021 12:55:29 +0000 (13:55 +0100)
commit57971fe46793911bcd976928fed8b19df4497a0b
treebe467a0d0962d0fb6cbda52a6f9d02ab786d7120
parent502d647d75c81ea63735b898b94ebad0de13c58d
bsd.compiler.mk: Detect distribution-provided GCC when executed as cc

Clang always prints "clang $VERSION" regardless of the name used to
execute it, whereas GCC prints "$progname $VERSION", meaning if CC is
set to cc and cc is GCC it will print "cc $VERSION". We are able to
detect some of those cases since it then prints "($PKGVERSION)", where
the default is "GCC", but many distributions override that to print
their name and the package version number (e.g. "Debian 10.2.1-6"), so
nothing tells us it's GCC other than the fact that it's not Clang (and
that there's an FSF copyright disclaimer).

However, GCC's -v option will always print "gcc version $VERSION", so
fall back on using that to detect GCC. Whilst Clang also supports this
option, we should never get here, so Clang handling is not added.

Reviewed by: brooks, emaste, arichardson
Differential Revision: https://reviews.freebsd.org/D28315

(cherry picked from commit 9c6954329a9285547881ddd60e393b7c55ed30c4)
share/mk/bsd.compiler.mk