From 20c19ae03d29cf08cfd6ba8d70b257bfb20b8d4e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 5 Jun 2023 13:16:22 -0700 Subject: [PATCH] manywarnings: more nuance about optimization MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * doc/manywarnings.texi (manywarnings): Suggest compiling with the optimization flags commonly used, as opposed to -O2 and -O0 specificially. -ggdb shouldn’t affect warnings so don’t mention it. --- ChangeLog | 7 +++++++ doc/manywarnings.texi | 21 +++++++++++++-------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index b761ca3a8e..d8f04f737d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2023-06-05 Paul Eggert + + manywarnings: more nuance about optimization + * doc/manywarnings.texi (manywarnings): Suggest compiling with the + optimization flags commonly used, as opposed to -O2 and -O0 + specificially. -ggdb shouldn’t affect warnings so don’t mention it. + 2023-06-05 Bruno Haible posix_spawn-internal: Fix a warning (regression 2022-11-20). diff --git a/doc/manywarnings.texi b/doc/manywarnings.texi index 19b58f8e47..33506dccef 100644 --- a/doc/manywarnings.texi +++ b/doc/manywarnings.texi @@ -66,18 +66,23 @@ This will save you time, because some warning options produce many false alarms with older versions of GCC (such as @code{-Wstrict-overflow} or @code{-Wunsafe-loop-optimizations}). @item -Compile the package with an empty @code{nw} value, that is, with all -possible warnings enabled. -Do this once with optimizations (@code{CPPFLAGS=-O2}) and once with no -optimizations (@code{CPPFLAGS=-O0} or @code{CPPFLAGS=-ggdb}). -The exercise with optimizations will catch more bugs, because the -compiler does a better static analysis of the program when optimizing. +Consider the platforms commonly used when enabling GCC warnings. +This includes not only target architectures and operating systems, but also +optimization options, which can greatly affect the warnings generated. +Makefiles generated by @code{configure} default to @option{-O2} optimization. +If you also commonly build with @option{-O0} or other optimization options, +you can compile again with those options. +Using more optimizations catches more bugs, because the compiler does +a better static analysis of the program when optimizing more. Also, some warning options that diagnose suboptimal code generation, such as @code{-Winline}, are not effective when not optimizing. -On the other hand, it's frequent to build the package without -optimizations, for debugging purposes, and you don't want to see +On the other hand, if it's frequent to build the package with warnings but +without optimizations, for debugging purposes, then you don't want to see undesired warnings in these phases of development either. @item +Compile the package with an empty @code{nw} value, that is, with all +possible warnings enabled. +@item Then you will go through the list of warnings. Since there are likely many warnings, the first time, it's a good idea to sort them by warning option first: -- 2.39.5