autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AC_PROG_CC: how to distinguish clang from gcc?


From: Russ Allbery
Subject: Re: AC_PROG_CC: how to distinguish clang from gcc?
Date: Fri, 05 Feb 2021 09:33:19 -0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

"David A. Wheeler" <dwheeler@dwheeler.com> writes:

> The gcc & clang groups coordinate with each other; they try to provide
> the same flags & API for the same functionality, and occasionally copy
> from each other.

This is not my experience.  In particular, the warning flags for Clang are
significantly different than the warning flags for GCC, giving rise to
logic like this to configure warnings used for maintainer builds:

 AS_IF([test x"$CLANG" = xyes],
    [WARNINGS_CFLAGS="-Werror"
     m4_foreach_w([flag],
        [-Weverything -Wno-cast-qual -Wno-disabled-macro-expansion -Wno-padded
         -Wno-sign-conversion -Wno-reserved-id-macro
         -Wno-tautological-pointer-compare -Wno-undef -Wno-unreachable-code
         -Wno-unreachable-code-return -Wno-unused-macros
         -Wno-used-but-marked-unused],
        [RRA_PROG_CC_FLAG(flag,
            [WARNINGS_CFLAGS="${WARNINGS_CFLAGS} flag"])])],
    [WARNINGS_CFLAGS="-g -O2 -D_FORTIFY_SOURCE=2 -Werror"
     m4_foreach_w([flag],
        [-fstrict-overflow -fstrict-aliasing -Wall -Wextra -Wformat=2
         -Wformat-overflow=2 -Wformat-signedness -Wformat-truncation=2
         -Wnull-dereference -Winit-self -Wswitch-enum -Wstrict-overflow=5
         -Wmissing-format-attribute -Walloc-zero -Wduplicated-branches
         -Wduplicated-cond -Wtrampolines -Wfloat-equal
         -Wdeclaration-after-statement -Wshadow -Wpointer-arith
         -Wbad-function-cast -Wcast-align -Wwrite-strings -Wconversion
         -Wno-sign-conversion -Wdate-time -Wjump-misses-init -Wlogical-op
         -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes
         -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wredundant-decls
         -Wrestrict -Wnested-externs -Winline -Wvla],
        [RRA_PROG_CC_FLAG(flag,
            [WARNINGS_CFLAGS="${WARNINGS_CFLAGS} flag"])])])

-- 
Russ Allbery (eagle@eyrie.org)             <https://www.eyrie.org/~eagle/>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]