Re: [PATCH] Makefile: detect compiler and enable more warnings in DEVELOPER=1
- From
Jeff King <peff@peff.net>
- Date
- Mar 18, 2018, 09:20 UTC
- Message-ID
- <20180318092001.GA29208@sigill.intra.peff.net>
- In-Reply-To
- <CACsJy8BGZV1hHKNzDaFkt=9zfhzv+GR1JUN-fOcQRk_2+tctZA@mail.gmail.com>
On Sun, Mar 18, 2018 at 10:17:41AM +0100, Duy Nguyen wrote:
Show 31 quoted lines
> On Sun, Mar 18, 2018 at 10:06 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> > On Sun, Mar 18, 2018 at 09:18:34AM +0100, Nguyễn Thái Ngọc Duy wrote:
> >> The set of extra warnings we enable when DEVELOPER has to be
> >> conservative because we can't assume any compiler version the
> >> developer may use. Detect the compiler version so we know when it's
> >> safe to enable -Wextra and maybe more.
> >>
> >> Helped-by: Jeff King <peff@peff.net>
> >> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> >> ---
> >> diff --git a/detect-compiler b/detect-compiler
> >> --- /dev/null
> >> +++ b/detect-compiler
> >> @@ -0,0 +1,50 @@
> >> +get_version_line() {
> >> + "$CC" -v 2>&1 | grep ' version '
> >> +}
> >
> > On MacOS, "cc -v" output is:
> >
> > --- >8 ---
> > Apple LLVM version 9.0.0 (clang-900.0.39.2)
> > Target: x86_64-apple-darwin16.7.0
> > Thread model: posix
> > InstalledDir: ...
> > --- >8 ---
>
> Does it still build ok for you with your changes squashed in? I think
> the check for clang4/gcc6 and setting -Wextra in config.mak.dev may
> backfire because clang9 probably has a lot more warnings enabled and
> some of them we don't want and cause compile error...I don't think we can predict that going forward, though. We'd have to wait for people to use the new compiler and then send a patch disabling whatever causes a problem (or better yet, fixing the code if appropriate).
This framework can only help us write those patches; I don't think it can save us from having to do them in the first place.
-Peff