Skip to content
  • Jessica Clarke's avatar
    bsd.compiler.mk: Detect distribution-provided GCC when executed as cc · 9c695432
    Jessica Clarke authored
    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
    9c695432