HomeFreeBSD

bsd.compiler.mk: Detect distribution-provided GCC when executed as cc

Description

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)

Details

Provenance
jrtc27Authored on Feb 9 2021, 9:40 PM
arichardsonCommitted on Apr 10 2021, 12:55 PM
Reviewer
brooks
Differential Revision
D28315: bsd.compiler.mk: Detect distribution-provided GCC when executed as cc
Parents
rG502d647d75c8: tests/sys/netgraph: Further CI fixes
Branches
Unknown
Tags
Unknown