All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
@ 2016-02-25  8:42 larsxschneider
  2016-02-25  9:26 ` Matthieu Moy
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: larsxschneider @ 2016-02-25  8:42 UTC (permalink / raw)
  To: git; +Cc: peff, gitster, Lars Schneider

From: Lars Schneider <larsxschneider@gmail.com>

We assume Git developers have a reasonably modern compiler and recommend
them to enable the DEVELOPER makefile knob to ensure their patches are
clear of all compiler warnings the Git core project cares about.

Enable the DEVELOPER makefile knob in the Travis-CI build.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
---

This patch is the successor of "[PATCH v1] travis-ci: override CFLAGS properly,
add -Wdeclaration-after-statement" [1] which enables compiler warnings for the
Travis-CI build.

Peff suggested to codify the knowledge about the compiler warnings the Git
project cares about [2] which I have done here.

The only problem is the "-Wold-style-declaration" compiler warning as this is
only supported by GCC and not Clang. Should we ignore that warning or would you
prefer to detect the GCC compiler and add the warning? The Linux kernel project
does a similar thing [3].


Thanks,
Lars


[1] http://thread.gmane.org/gmane.comp.version-control.git/285752
[2] http://article.gmane.org/gmane.comp.version-control.git/285761
[3] https://github.com/torvalds/linux/blob/6dc390ad61ac8dfca5fa9b0823981fb6f7ec17a0/Makefile#L303-L306


 .travis.yml                    |  2 +-
 Documentation/CodingGuidelines |  4 ++++
 Makefile                       | 12 ++++++++++++
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index c3bf9c6..168ae21 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,12 +15,12 @@ addons:

 env:
   global:
+    - DEVELOPER=1
     - P4_VERSION="15.2"
     - GIT_LFS_VERSION="1.1.0"
     - DEFAULT_TEST_TARGET=prove
     - GIT_PROVE_OPTS="--timer --jobs 3"
     - GIT_TEST_OPTS="--verbose --tee"
-    - CFLAGS="-g -O2 -Wall -Werror"
     - GIT_TEST_CLONE_2GB=YesPlease
     # t9810 occasionally fails on Travis CI OS X
     # t9816 occasionally fails with "TAP out of sequence errors" on Travis CI OS X
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index c6e536f..1c676c2 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -171,6 +171,10 @@ For C programs:

  - We try to keep to at most 80 characters per line.

+ - As a Git developer we assume you have a reasonably modern compiler
+   and we recommend you to enable the DEVELOPER makefile knob to
+   ensure your patch is clear of all compiler warnings we care about.
+
  - We try to support a wide range of C compilers to compile Git with,
    including old ones. That means that you should not use C99
    initializers, even if a lot of compilers grok it.
diff --git a/Makefile b/Makefile
index fd19b54..9d4614d 100644
--- a/Makefile
+++ b/Makefile
@@ -380,6 +380,18 @@ ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
 ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip

+ifdef DEVELOPER
+	CFLAGS +=	-Werror \
+				-Wdeclaration-after-statement \
+				-Wno-format-zero-length \
+				-Wold-style-definition \
+				-Woverflow \
+				-Wpointer-arith \
+				-Wstrict-prototypes \
+				-Wunused \
+				-Wvla
+endif
+
 # Create as necessary, replace existing, make ranlib unneeded.
 ARFLAGS = rcs

--
2.5.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-25  8:42 [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings larsxschneider
@ 2016-02-25  9:26 ` Matthieu Moy
  2016-02-25 10:20 ` Michael Haggerty
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Matthieu Moy @ 2016-02-25  9:26 UTC (permalink / raw)
  To: larsxschneider; +Cc: git, peff, gitster

larsxschneider@gmail.com writes:

> --- a/Makefile
> +++ b/Makefile
> @@ -380,6 +380,18 @@ ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
>  ALL_LDFLAGS = $(LDFLAGS)
>  STRIP ?= strip
>
> +ifdef DEVELOPER
> +	CFLAGS +=	-Werror \
> +				-Wdeclaration-after-statement \
> +				-Wno-format-zero-length \
> +				-Wold-style-definition \
> +				-Woverflow \
> +				-Wpointer-arith \
> +				-Wstrict-prototypes \
> +				-Wunused \
> +				-Wvla
> +endif
> +

I guess you have tab-width=4. This portion looks ugly with tab-width=8.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-25  8:42 [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings larsxschneider
  2016-02-25  9:26 ` Matthieu Moy
@ 2016-02-25 10:20 ` Michael Haggerty
  2016-02-25 17:40 ` Junio C Hamano
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Michael Haggerty @ 2016-02-25 10:20 UTC (permalink / raw)
  To: larsxschneider, git; +Cc: peff, gitster

On 02/25/2016 09:42 AM, larsxschneider@gmail.com wrote:
> From: Lars Schneider <larsxschneider@gmail.com>
> 
> We assume Git developers have a reasonably modern compiler and recommend
> them to enable the DEVELOPER makefile knob to ensure their patches are
> clear of all compiler warnings the Git core project cares about.
> 
> Enable the DEVELOPER makefile knob in the Travis-CI build.
> 
> Suggested-by: Jeff King <peff@peff.net>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---
> 
> This patch is the successor of "[PATCH v1] travis-ci: override CFLAGS properly,
> add -Wdeclaration-after-statement" [1] which enables compiler warnings for the
> Travis-CI build.
> 
> Peff suggested to codify the knowledge about the compiler warnings the Git
> project cares about [2] which I have done here.
> 
> The only problem is the "-Wold-style-declaration" compiler warning as this is
> only supported by GCC and not Clang. Should we ignore that warning or would you
> prefer to detect the GCC compiler and add the warning? The Linux kernel project
> does a similar thing [3].
> 
> 
> Thanks,
> Lars
> 
> 
> [1] http://thread.gmane.org/gmane.comp.version-control.git/285752
> [2] http://article.gmane.org/gmane.comp.version-control.git/285761
> [3] https://github.com/torvalds/linux/blob/6dc390ad61ac8dfca5fa9b0823981fb6f7ec17a0/Makefile#L303-L306
> 
> 
>  .travis.yml                    |  2 +-
>  Documentation/CodingGuidelines |  4 ++++
>  Makefile                       | 12 ++++++++++++
>  3 files changed, 17 insertions(+), 1 deletion(-)
> 
> [...]
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index c6e536f..1c676c2 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -171,6 +171,10 @@ For C programs:
> 
>   - We try to keep to at most 80 characters per line.
> 
> + - As a Git developer we assume you have a reasonably modern compiler
> +   and we recommend you to enable the DEVELOPER makefile knob to
> +   ensure your patch is clear of all compiler warnings we care about.
> +

Instead of saying "enable the DEVELOPER makefile knob" could you be more
explicit? Like maybe "create a file called `config.mak` and add the line
`DEVELOPER=1` to it"? (Or whatever is your preferred way to tweak this
setting.)

>   - We try to support a wide range of C compilers to compile Git with,
>     including old ones. That means that you should not use C99
>     initializers, even if a lot of compilers grok it.
> [...]

Michael

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-25  8:42 [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings larsxschneider
  2016-02-25  9:26 ` Matthieu Moy
  2016-02-25 10:20 ` Michael Haggerty
@ 2016-02-25 17:40 ` Junio C Hamano
  2016-02-26  9:26   ` Lars Schneider
  2016-02-26  9:26 ` Duy Nguyen
  2017-05-02 13:22 ` Ævar Arnfjörð Bjarmason
  4 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2016-02-25 17:40 UTC (permalink / raw)
  To: larsxschneider, Matthieu Moy, Michael Haggerty; +Cc: git, peff

Perhaps squash these two while queuing to address comments from you two?

Thanks.

 Documentation/CodingGuidelines |  3 ++-
 Makefile                       | 18 +++++++++---------
 2 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 1c676c2..0ddd368 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -173,7 +173,8 @@ For C programs:
 
  - As a Git developer we assume you have a reasonably modern compiler
    and we recommend you to enable the DEVELOPER makefile knob to
-   ensure your patch is clear of all compiler warnings we care about.
+   ensure your patch is clear of all compiler warnings we care about,
+   by e.g. "echo DEVELOPER=1 >>config.mak".
 
  - We try to support a wide range of C compilers to compile Git with,
    including old ones. That means that you should not use C99
diff --git a/Makefile b/Makefile
index 9eb4032..7dc5b88 100644
--- a/Makefile
+++ b/Makefile
@@ -381,15 +381,15 @@ ALL_LDFLAGS = $(LDFLAGS)
 STRIP ?= strip
 
 ifdef DEVELOPER
-	CFLAGS +=	-Werror \
-				-Wdeclaration-after-statement \
-				-Wno-format-zero-length \
-				-Wold-style-definition \
-				-Woverflow \
-				-Wpointer-arith \
-				-Wstrict-prototypes \
-				-Wunused \
-				-Wvla
+CFLAGS += -Werror \
+	-Wdeclaration-after-statement \
+	-Wno-format-zero-length \
+	-Wold-style-definition \
+	-Woverflow \
+	-Wpointer-arith \
+	-Wstrict-prototypes \
+	-Wunused \
+	-Wvla
 endif
 
 # Create as necessary, replace existing, make ranlib unneeded.

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-25  8:42 [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings larsxschneider
                   ` (2 preceding siblings ...)
  2016-02-25 17:40 ` Junio C Hamano
@ 2016-02-26  9:26 ` Duy Nguyen
  2016-02-26  9:30   ` Lars Schneider
  2017-05-02 13:22 ` Ævar Arnfjörð Bjarmason
  4 siblings, 1 reply; 12+ messages in thread
From: Duy Nguyen @ 2016-02-26  9:26 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Git Mailing List, Jeff King, Junio C Hamano

On Thu, Feb 25, 2016 at 3:42 PM,  <larsxschneider@gmail.com> wrote:
> +ifdef DEVELOPER
> +       CFLAGS +=       -Werror \
> +                               -Wdeclaration-after-statement \
> +                               -Wno-format-zero-length \
> +                               -Wold-style-definition \
> +                               -Woverflow \
> +                               -Wpointer-arith \
> +                               -Wstrict-prototypes \
> +                               -Wunused \
> +                               -Wvla

With the exception of $(SCRIPTS) in Makefile, I think we prefer to
avoid \ and have one addition per statement

> +endif
-- 
Duy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-25 17:40 ` Junio C Hamano
@ 2016-02-26  9:26   ` Lars Schneider
  0 siblings, 0 replies; 12+ messages in thread
From: Lars Schneider @ 2016-02-26  9:26 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Matthieu Moy, Michael Haggerty, Git Users, peff

Thanks for the reviews and the fix :-)

Any thought on the "-Wold-style-declaration" problem mentioned in my first v2 email?

- Lars

> On 25 Feb 2016, at 18:40, Junio C Hamano <gitster@pobox.com> wrote:
> 
> Perhaps squash these two while queuing to address comments from you two?
> 
> Thanks.
> 
> Documentation/CodingGuidelines |  3 ++-
> Makefile                       | 18 +++++++++---------
> 2 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index 1c676c2..0ddd368 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -173,7 +173,8 @@ For C programs:
> 
>  - As a Git developer we assume you have a reasonably modern compiler
>    and we recommend you to enable the DEVELOPER makefile knob to
> -   ensure your patch is clear of all compiler warnings we care about.
> +   ensure your patch is clear of all compiler warnings we care about,
> +   by e.g. "echo DEVELOPER=1 >>config.mak".
> 
>  - We try to support a wide range of C compilers to compile Git with,
>    including old ones. That means that you should not use C99
> diff --git a/Makefile b/Makefile
> index 9eb4032..7dc5b88 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -381,15 +381,15 @@ ALL_LDFLAGS = $(LDFLAGS)
> STRIP ?= strip
> 
> ifdef DEVELOPER
> -	CFLAGS +=	-Werror \
> -				-Wdeclaration-after-statement \
> -				-Wno-format-zero-length \
> -				-Wold-style-definition \
> -				-Woverflow \
> -				-Wpointer-arith \
> -				-Wstrict-prototypes \
> -				-Wunused \
> -				-Wvla
> +CFLAGS += -Werror \
> +	-Wdeclaration-after-statement \
> +	-Wno-format-zero-length \
> +	-Wold-style-definition \
> +	-Woverflow \
> +	-Wpointer-arith \
> +	-Wstrict-prototypes \
> +	-Wunused \
> +	-Wvla
> endif
> 
> # Create as necessary, replace existing, make ranlib unneeded.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-26  9:26 ` Duy Nguyen
@ 2016-02-26  9:30   ` Lars Schneider
  2016-02-26  9:33     ` Duy Nguyen
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Schneider @ 2016-02-26  9:30 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List, Jeff King, Junio C Hamano


> On 26 Feb 2016, at 10:26, Duy Nguyen <pclouds@gmail.com> wrote:
> 
> On Thu, Feb 25, 2016 at 3:42 PM,  <larsxschneider@gmail.com> wrote:
>> +ifdef DEVELOPER
>> +       CFLAGS +=       -Werror \
>> +                               -Wdeclaration-after-statement \
>> +                               -Wno-format-zero-length \
>> +                               -Wold-style-definition \
>> +                               -Woverflow \
>> +                               -Wpointer-arith \
>> +                               -Wstrict-prototypes \
>> +                               -Wunused \
>> +                               -Wvla
> 
> With the exception of $(SCRIPTS) in Makefile, I think we prefer to
> avoid \ and have one addition per statement
> 
I guessed that because I actually looked through the makefile to find how you deal with line 
brakes. The problem here was that this line gets really long and then it is hard to see what 
warnings are enabled.
Would you be OK with using \ for readability here?

Thanks,
Lars

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-26  9:30   ` Lars Schneider
@ 2016-02-26  9:33     ` Duy Nguyen
  2016-02-28 10:35       ` Lars Schneider
  0 siblings, 1 reply; 12+ messages in thread
From: Duy Nguyen @ 2016-02-26  9:33 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Git Mailing List, Jeff King, Junio C Hamano

On Fri, Feb 26, 2016 at 4:30 PM, Lars Schneider
<larsxschneider@gmail.com> wrote:
>
>> On 26 Feb 2016, at 10:26, Duy Nguyen <pclouds@gmail.com> wrote:
>>
>> On Thu, Feb 25, 2016 at 3:42 PM,  <larsxschneider@gmail.com> wrote:
>>> +ifdef DEVELOPER
>>> +       CFLAGS +=       -Werror \
>>> +                               -Wdeclaration-after-statement \
>>> +                               -Wno-format-zero-length \
>>> +                               -Wold-style-definition \
>>> +                               -Woverflow \
>>> +                               -Wpointer-arith \
>>> +                               -Wstrict-prototypes \
>>> +                               -Wunused \
>>> +                               -Wvla
>>
>> With the exception of $(SCRIPTS) in Makefile, I think we prefer to
>> avoid \ and have one addition per statement
>>
> I guessed that because I actually looked through the makefile to find how you deal with line
> brakes. The problem here was that this line gets really long and then it is hard to see what
> warnings are enabled.
> Would you be OK with using \ for readability here?

Probably misunderstanding. I meant something like this

CFLAGS += -Werror
CFLAGS += -Wdecl..
CFLAGS += -Wno-form..
-- 
Duy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-26  9:33     ` Duy Nguyen
@ 2016-02-28 10:35       ` Lars Schneider
  2016-02-28 10:49         ` Duy Nguyen
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Schneider @ 2016-02-28 10:35 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Git Mailing List, Jeff King, Junio C Hamano


On 26 Feb 2016, at 10:33, Duy Nguyen <pclouds@gmail.com> wrote:

> On Fri, Feb 26, 2016 at 4:30 PM, Lars Schneider
> <larsxschneider@gmail.com> wrote:
>> 
>>> On 26 Feb 2016, at 10:26, Duy Nguyen <pclouds@gmail.com> wrote:
>>> 
>>> On Thu, Feb 25, 2016 at 3:42 PM,  <larsxschneider@gmail.com> wrote:
>>>> +ifdef DEVELOPER
>>>> +       CFLAGS +=       -Werror \
>>>> +                               -Wdeclaration-after-statement \
>>>> +                               -Wno-format-zero-length \
>>>> +                               -Wold-style-definition \
>>>> +                               -Woverflow \
>>>> +                               -Wpointer-arith \
>>>> +                               -Wstrict-prototypes \
>>>> +                               -Wunused \
>>>> +                               -Wvla
>>> 
>>> With the exception of $(SCRIPTS) in Makefile, I think we prefer to
>>> avoid \ and have one addition per statement
>>> 
>> I guessed that because I actually looked through the makefile to find how you deal with line
>> brakes. The problem here was that this line gets really long and then it is hard to see what
>> warnings are enabled.
>> Would you be OK with using \ for readability here?
> 
> Probably misunderstanding. I meant something like this
> 
> CFLAGS += -Werror
> CFLAGS += -Wdecl..
> CFLAGS += -Wno-form..

Oh. I just realized the patch made it already into master. Do you think I should submit
a follow up patch? I also wonder, do you see an advantage of one style over the other
or do you want me to change it for consistency?

Thanks,
Lars

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-28 10:35       ` Lars Schneider
@ 2016-02-28 10:49         ` Duy Nguyen
  0 siblings, 0 replies; 12+ messages in thread
From: Duy Nguyen @ 2016-02-28 10:49 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Git Mailing List, Jeff King, Junio C Hamano

On Sun, Feb 28, 2016 at 5:35 PM, Lars Schneider
<larsxschneider@gmail.com> wrote:
> On 26 Feb 2016, at 10:33, Duy Nguyen <pclouds@gmail.com> wrote:
>> Probably misunderstanding. I meant something like this
>>
>> CFLAGS += -Werror
>> CFLAGS += -Wdecl..
>> CFLAGS += -Wno-form..
>
> Oh. I just realized the patch made it already into master. Do you think I should submit
> a follow up patch?

If it's already in, it's probably not worth changing it again.

> I also wonder, do you see an advantage of one style over the other or do you want me to change it for consistency?

If you add a new option at the end, then you only add one new line.
You need to add '\\' to the last line with the other format. It also
makes re-sorting a bit easier (but this point is not applicable here
because we need some special sort order, where we ignore "no-" part).
-- 
Duy

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2016-02-25  8:42 [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings larsxschneider
                   ` (3 preceding siblings ...)
  2016-02-26  9:26 ` Duy Nguyen
@ 2017-05-02 13:22 ` Ævar Arnfjörð Bjarmason
  2017-05-10  4:59   ` Jeff King
  4 siblings, 1 reply; 12+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2017-05-02 13:22 UTC (permalink / raw)
  To: Lars Schneider; +Cc: Git Mailing List, Jeff King, Junio C Hamano

On Thu, Feb 25, 2016 at 9:42 AM,  <larsxschneider@gmail.com> wrote:
> From: Lars Schneider <larsxschneider@gmail.com>
>
> We assume Git developers have a reasonably modern compiler and recommend
> them to enable the DEVELOPER makefile knob to ensure their patches are
> clear of all compiler warnings the Git core project cares about.
>
> Enable the DEVELOPER makefile knob in the Travis-CI build.
>
> Suggested-by: Jeff King <peff@peff.net>
> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
> ---
>
> This patch is the successor of "[PATCH v1] travis-ci: override CFLAGS properly,
> add -Wdeclaration-after-statement" [1] which enables compiler warnings for the
> Travis-CI build.
>
> Peff suggested to codify the knowledge about the compiler warnings the Git
> project cares about [2] which I have done here.
>
> The only problem is the "-Wold-style-declaration" compiler warning as this is
> only supported by GCC and not Clang. Should we ignore that warning or would you
> prefer to detect the GCC compiler and add the warning? The Linux kernel project
> does a similar thing [3].
>
>
> Thanks,
> Lars
>
>
> [1] http://thread.gmane.org/gmane.comp.version-control.git/285752
> [2] http://article.gmane.org/gmane.comp.version-control.git/285761
> [3] https://github.com/torvalds/linux/blob/6dc390ad61ac8dfca5fa9b0823981fb6f7ec17a0/Makefile#L303-L306
>
>
>  .travis.yml                    |  2 +-
>  Documentation/CodingGuidelines |  4 ++++
>  Makefile                       | 12 ++++++++++++
>  3 files changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/.travis.yml b/.travis.yml
> index c3bf9c6..168ae21 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -15,12 +15,12 @@ addons:
>
>  env:
>    global:
> +    - DEVELOPER=1
>      - P4_VERSION="15.2"
>      - GIT_LFS_VERSION="1.1.0"
>      - DEFAULT_TEST_TARGET=prove
>      - GIT_PROVE_OPTS="--timer --jobs 3"
>      - GIT_TEST_OPTS="--verbose --tee"
> -    - CFLAGS="-g -O2 -Wall -Werror"
>      - GIT_TEST_CLONE_2GB=YesPlease
>      # t9810 occasionally fails on Travis CI OS X
>      # t9816 occasionally fails with "TAP out of sequence errors" on Travis CI OS X
> diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
> index c6e536f..1c676c2 100644
> --- a/Documentation/CodingGuidelines
> +++ b/Documentation/CodingGuidelines
> @@ -171,6 +171,10 @@ For C programs:
>
>   - We try to keep to at most 80 characters per line.
>
> + - As a Git developer we assume you have a reasonably modern compiler
> +   and we recommend you to enable the DEVELOPER makefile knob to
> +   ensure your patch is clear of all compiler warnings we care about.
> +
>   - We try to support a wide range of C compilers to compile Git with,
>     including old ones. That means that you should not use C99
>     initializers, even if a lot of compilers grok it.
> diff --git a/Makefile b/Makefile
> index fd19b54..9d4614d 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -380,6 +380,18 @@ ALL_CFLAGS = $(CPPFLAGS) $(CFLAGS)
>  ALL_LDFLAGS = $(LDFLAGS)
>  STRIP ?= strip
>
> +ifdef DEVELOPER
> +       CFLAGS +=       -Werror \
> +                               -Wdeclaration-after-statement \
> +                               -Wno-format-zero-length \
> +                               -Wold-style-definition \
> +                               -Woverflow \
> +                               -Wpointer-arith \
> +                               -Wstrict-prototypes \
> +                               -Wunused \
> +                               -Wvla
> +endif
> +
>  # Create as necessary, replace existing, make ranlib unneeded.
>  ARFLAGS = rcs
>
> --
> 2.5.1

[I realize this patch has long since been integrated]

Is there any way with this to both supply CFLAGS & DEVELOPER=1 on the
command-line, to get my custom -O<whatever> & these -W flags? I.e.:

$ make DEVELOPER=1 V=1
[...] -g -O2 -Wall -Werror -Wdeclaration-after-statement
-Wno-format-zero-length -Wold-style-definition -Woverflow
-Wpointer-arith -Wstrict-prototypes -Wunused -Wvla -I. [...]
$ make DEVELOPER=1 CFLAGS="-g -O0 -Wall" V=1
[...] -g -O0 -Wall -I. [...]

I thought the second case would prepend my "-g -O0 -Wall" but then be
followed by the various -W developer flags, but it isn't, am I just
doing something stupid, or is there no way to combine these two?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings
  2017-05-02 13:22 ` Ævar Arnfjörð Bjarmason
@ 2017-05-10  4:59   ` Jeff King
  0 siblings, 0 replies; 12+ messages in thread
From: Jeff King @ 2017-05-10  4:59 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Lars Schneider, Git Mailing List, Junio C Hamano

On Tue, May 02, 2017 at 03:22:23PM +0200, Ævar Arnfjörð Bjarmason wrote:

> Is there any way with this to both supply CFLAGS & DEVELOPER=1 on the
> command-line, to get my custom -O<whatever> & these -W flags? I.e.:
> 
> $ make DEVELOPER=1 V=1
> [...] -g -O2 -Wall -Werror -Wdeclaration-after-statement
> -Wno-format-zero-length -Wold-style-definition -Woverflow
> -Wpointer-arith -Wstrict-prototypes -Wunused -Wvla -I. [...]
> $ make DEVELOPER=1 CFLAGS="-g -O0 -Wall" V=1
> [...] -g -O0 -Wall -I. [...]
> 
> I thought the second case would prepend my "-g -O0 -Wall" but then be
> followed by the various -W developer flags, but it isn't, am I just
> doing something stupid, or is there no way to combine these two?

The problem is that when you give "make" a variable on the command line,
it overrides all of the modifications. So if you were to set that CFLAGS
in your config.mak, I think everything would work as you expect.

I actually do this in my config.mak:

  O = 0
  CFLAGS += -g -O$(O)

which lets me override the optimization level as a one-off on the
command-line:

  make O=2

without disturbing the rest of the CFLAGS. I also do this:

  CFLAGS += $(EXTRA_CFLAGS)

as a catch-all, so that I can do:

  make EXTRA_CFLAGS=-Wone-off-warning-that-I-am-testing

Perhaps those are things the main Makefile should support. I dunno. You
could see the full depths of my depravity at:

  https://github.com/peff/git/blame/meta/config/config.mak

(I linked to the blame view because there are a lot of WTF bits in there
that are explained by the commit messages).

-Peff

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2017-05-10  4:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-25  8:42 [PATCH v2] add DEVELOPER makefile knob to check for acknowledged warnings larsxschneider
2016-02-25  9:26 ` Matthieu Moy
2016-02-25 10:20 ` Michael Haggerty
2016-02-25 17:40 ` Junio C Hamano
2016-02-26  9:26   ` Lars Schneider
2016-02-26  9:26 ` Duy Nguyen
2016-02-26  9:30   ` Lars Schneider
2016-02-26  9:33     ` Duy Nguyen
2016-02-28 10:35       ` Lars Schneider
2016-02-28 10:49         ` Duy Nguyen
2017-05-02 13:22 ` Ævar Arnfjörð Bjarmason
2017-05-10  4:59   ` Jeff King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.