This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[RFA] Make macOS build warning-free


I noticed thousands of warnings, mostly from the _() macro, when
building on macOS.  This patch makes the macOS build be warning-free,
without requiring --disable-nls.

The warning.m4 change should be self-explanatory.

The symfile.c change fixes a clang warning coming from
-Wmissing-braces.

Tested by rebuilding on macOS and on x86-64 Fedora 28.

gdb/ChangeLog
2018-06-29  Tom Tromey  <tom@tromey.com>

	* symfile.c (set_objfile_default_section_offset): Use extra braces
	around initializer.
	* warning.m4 (AM_GDB_WARNINGS): Use -Wno-deprecated-declarations,
	-Wno-format-nonliteral, and -Wno-format-security on *-*-darwin*.
	* configure: Rebuild.
---
 gdb/ChangeLog  |  8 ++++++++
 gdb/configure  | 11 +++++++++++
 gdb/symfile.c  |  2 +-
 gdb/warning.m4 | 11 +++++++++++
 4 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4c04d0ba728..df573d35394 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2018-06-29  Tom Tromey  <tom@tromey.com>
+
+	* symfile.c (set_objfile_default_section_offset): Use extra braces
+	around initializer.
+	* warning.m4 (AM_GDB_WARNINGS): Use -Wno-deprecated-declarations,
+	-Wno-format-nonliteral, and -Wno-format-security on *-*-darwin*.
+	* configure: Rebuild.
+
 2018-06-28  Tom Tromey  <tom@tromey.com>
 
 	* NEWS: Mention --enable-codesign.
diff --git a/gdb/configure b/gdb/configure
index 28756ed9826..a4d0d0a6cda 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -15488,6 +15488,17 @@ case "${host}" in
     build_warnings="$build_warnings -Wno-unknown-pragmas"
     # Solaris 11 <unistd.h> marks vfork deprecated.
     build_warnings="$build_warnings -Wno-deprecated-declarations" ;;
+  *-*-darwin*)
+    # macOS deprecates syscall (needed by darwin-nat.c) and
+    # sbrk (used only for some maint commands).
+    build_warnings="$build_warnings -Wno-deprecated-declarations"
+    # -Wformat-nonliteral doesn't work properly on macOS -- apparently
+    # it does not interact properly with the format_arg attribute.
+    # (libgnuintl.h disables this attribute for macOS, but re-enabling
+    # it there did not work.)
+    build_warnings="$build_warnings -Wno-format-nonliteral"
+    build_warnings="$build_warnings -Wno-format-security"
+    ;;
   *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
 esac
 
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 48eca5cc0ea..62b38bd6182 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -2088,7 +2088,7 @@ set_objfile_default_section_offset (struct objfile *objf,
 {
   /* Add OFFSET to all sections by default.  */
   std::vector<struct section_offsets> offsets (objf->num_sections,
-					       { offset });
+					       { { offset } });
 
   /* Create sorted lists of all sections in ADDRS as well as all
      sections in OBJF.  */
diff --git a/gdb/warning.m4 b/gdb/warning.m4
index 632cc214ac0..17afc5455a1 100644
--- a/gdb/warning.m4
+++ b/gdb/warning.m4
@@ -58,6 +58,17 @@ case "${host}" in
     build_warnings="$build_warnings -Wno-unknown-pragmas"
     # Solaris 11 <unistd.h> marks vfork deprecated.
     build_warnings="$build_warnings -Wno-deprecated-declarations" ;;
+  *-*-darwin*)
+    # macOS deprecates syscall (needed by darwin-nat.c) and
+    # sbrk (used only for some maint commands).
+    build_warnings="$build_warnings -Wno-deprecated-declarations"
+    # -Wformat-nonliteral doesn't work properly on macOS -- apparently
+    # it does not interact properly with the format_arg attribute.
+    # (libgnuintl.h disables this attribute for macOS, but re-enabling
+    # it there did not work.)
+    build_warnings="$build_warnings -Wno-format-nonliteral"
+    build_warnings="$build_warnings -Wno-format-security"
+    ;;
   *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
 esac
 
-- 
2.17.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]