public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/2] configure: Fix -D_FORTIFY_SOURCE=2 check when CFLAGS contains -Wno-error
  2019-12-12  0:23 [PATCH 0/2] elfutils: minor build system fixes Omar Sandoval
@ 2019-12-12  0:23 ` Omar Sandoval
  2019-12-12  0:23 ` [PATCH 2/2] libcpu: Compile i386_lex.c with -Wno-implicit-fallthrough Omar Sandoval
  2019-12-12 11:17 ` [PATCH 0/2] elfutils: minor build system fixes Mark Wielaard
  2 siblings, 0 replies; 5+ messages in thread
From: Omar Sandoval @ 2019-12-12  0:23 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

If CFLAGS contains -Wno-error, then the check for -D_FORTIFY_SOURCE=2
won't fail when appropriate. E.g., compiling with:

  ./configure CFLAGS='-Wno-error -O0' &&

Results in a flood of "_FORTIFY_SOURCE requires compiling with
optimization (-O)" warnings.

Make sure we add -Werror after the user-defined CFLAGS.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 ChangeLog    | 5 +++++
 configure.ac | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index ed5f5866..ff012e3c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-12-11  Omar Sandoval  <osandov@fb.com>
+
+	* configure.ac: Apply -Werror after user-defined CFLAGS in
+	-D_FORTIFY_SOURCE=2 check.
+
 2019-12-06  Mark Wielaard  <mark@klomp.org>
 
 	* configure.ac: Add ac_cv_buildid check.
diff --git a/configure.ac b/configure.ac
index 36a6b6c2..25555d0b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -273,7 +273,7 @@ case "$CFLAGS" in
     ;;
   *)
     save_CFLAGS="$CFLAGS"
-    CFLAGS="-D_FORTIFY_SOURCE=2 -Werror $CFLAGS"
+    CFLAGS="-D_FORTIFY_SOURCE=2 $CFLAGS -Werror"
     AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
       #include <string.h>
       int main() { return 0; }
-- 
2.24.0

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

* [PATCH 2/2] libcpu: Compile i386_lex.c with -Wno-implicit-fallthrough
  2019-12-12  0:23 [PATCH 0/2] elfutils: minor build system fixes Omar Sandoval
  2019-12-12  0:23 ` [PATCH 1/2] configure: Fix -D_FORTIFY_SOURCE=2 check when CFLAGS contains -Wno-error Omar Sandoval
@ 2019-12-12  0:23 ` Omar Sandoval
  2019-12-12 11:17 ` [PATCH 0/2] elfutils: minor build system fixes Mark Wielaard
  2 siblings, 0 replies; 5+ messages in thread
From: Omar Sandoval @ 2019-12-12  0:23 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

elfutils is compiled with -Wimplicit-fallthrough=5, so the fallthrough
comment in i386_lex.c (generated by flex) doesn't prevent the implicit
fallthrough warning. Add -Wno-implicit-fallthrough to i386_lex_CFLAGS.

Signed-off-by: Omar Sandoval <osandov@fb.com>
---
 libcpu/ChangeLog   | 4 ++++
 libcpu/Makefile.am | 3 ++-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog
index 52567be8..70796514 100644
--- a/libcpu/ChangeLog
+++ b/libcpu/ChangeLog
@@ -1,3 +1,7 @@
+2019-12-11  Omar Sandoval  <osandov@fb.com>
+
+	* Makefile.am (i386_lex_CFLAGS): Add -Wno-implicit-fallthrough.
+
 2019-10-17  Mark Wielaard  <mark@klomp.org>
 
 	* i386_data.h (FCT_sel): Check for param_start + 2 >= end instead
diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index 03c71ea3..59def7d1 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -81,7 +81,8 @@ i386_lex_no_Werror = yes
 
 libeu = ../lib/libeu.a
 
-i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare
+i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare \
+		  -Wno-implicit-fallthrough
 i386_parse.o: i386_parse.c i386.mnemonics
 i386_parse_CFLAGS = -DNMNES="`wc -l < i386.mnemonics`"
 i386_lex.o: i386_parse.h
-- 
2.24.0

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

* [PATCH 0/2] elfutils: minor build system fixes
@ 2019-12-12  0:23 Omar Sandoval
  2019-12-12  0:23 ` [PATCH 1/2] configure: Fix -D_FORTIFY_SOURCE=2 check when CFLAGS contains -Wno-error Omar Sandoval
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Omar Sandoval @ 2019-12-12  0:23 UTC (permalink / raw)
  To: elfutils-devel

From: Omar Sandoval <osandov@fb.com>

Hello,

This small series fixes a couple of  issues I encountered when building
elfutils. Patch 1 fixes an issue when compiling with CFLAGS='-Wno-error
-O0'. Patch 2 gets rid of a warning.

Thanks!

Omar Sandoval (2):
  configure: Fix -D_FORTIFY_SOURCE=2 check when CFLAGS contains
    -Wno-error
  libcpu: Compile i386_lex.c with -Wno-implicit-fallthrough

 ChangeLog          | 5 +++++
 configure.ac       | 2 +-
 libcpu/ChangeLog   | 4 ++++
 libcpu/Makefile.am | 3 ++-
 4 files changed, 12 insertions(+), 2 deletions(-)

-- 
2.24.0

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

* Re: [PATCH 0/2] elfutils: minor build system fixes
  2019-12-12  0:23 [PATCH 0/2] elfutils: minor build system fixes Omar Sandoval
  2019-12-12  0:23 ` [PATCH 1/2] configure: Fix -D_FORTIFY_SOURCE=2 check when CFLAGS contains -Wno-error Omar Sandoval
  2019-12-12  0:23 ` [PATCH 2/2] libcpu: Compile i386_lex.c with -Wno-implicit-fallthrough Omar Sandoval
@ 2019-12-12 11:17 ` Mark Wielaard
  2019-12-12 15:25   ` Omar Sandoval
  2 siblings, 1 reply; 5+ messages in thread
From: Mark Wielaard @ 2019-12-12 11:17 UTC (permalink / raw)
  To: Omar Sandoval, elfutils-devel

On Wed, 2019-12-11 at 16:23 -0800, Omar Sandoval wrote:
> This small series fixes a couple of  issues I encountered when building
> elfutils. Patch 1 fixes an issue when compiling with CFLAGS='-Wno-error
> -O0'. Patch 2 gets rid of a warning.

Both look good, pushed to master. Thanks.

Do you still need -Wno-error?

Cheers,

Mark

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

* Re: [PATCH 0/2] elfutils: minor build system fixes
  2019-12-12 11:17 ` [PATCH 0/2] elfutils: minor build system fixes Mark Wielaard
@ 2019-12-12 15:25   ` Omar Sandoval
  0 siblings, 0 replies; 5+ messages in thread
From: Omar Sandoval @ 2019-12-12 15:25 UTC (permalink / raw)
  To: Mark Wielaard; +Cc: elfutils-devel

On Thu, Dec 12, 2019 at 12:17:23PM +0100, Mark Wielaard wrote:
> On Wed, 2019-12-11 at 16:23 -0800, Omar Sandoval wrote:
> > This small series fixes a couple of  issues I encountered when building
> > elfutils. Patch 1 fixes an issue when compiling with CFLAGS='-Wno-error
> > -O0'. Patch 2 gets rid of a warning.
> 
> Both look good, pushed to master. Thanks.
> 
> Do you still need -Wno-error?

Nope, at least with GCC 9.2.0 that I'm using, it builds cleanly.

Thanks!

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

end of thread, other threads:[~2019-12-12 15:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-12  0:23 [PATCH 0/2] elfutils: minor build system fixes Omar Sandoval
2019-12-12  0:23 ` [PATCH 1/2] configure: Fix -D_FORTIFY_SOURCE=2 check when CFLAGS contains -Wno-error Omar Sandoval
2019-12-12  0:23 ` [PATCH 2/2] libcpu: Compile i386_lex.c with -Wno-implicit-fallthrough Omar Sandoval
2019-12-12 11:17 ` [PATCH 0/2] elfutils: minor build system fixes Mark Wielaard
2019-12-12 15:25   ` Omar Sandoval

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).