This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFA] Make macOS build warning-free
- From: Simon Marchi <simon dot marchi at ericsson dot com>
- To: Tom Tromey <tom at tromey dot com>, <gdb-patches at sourceware dot org>
- Date: Fri, 29 Jun 2018 17:34:40 -0400
- Subject: Re: [RFA] Make macOS build warning-free
- References: <20180629165453.22888-1-tom@tromey.com>
On 2018-06-29 12:54 PM, Tom Tromey wrote:
> 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
About the gettext / non-literal warning, this is the patch I carry. I tried
to dig up why gettext doesn't define _INTL_MAY_RETURN_STRING_ARG for __APPLE_CC__
but couldn't find it. My guess is that in a distant past, the Apple compiler
did not know about that attribute. You need another change to get rid of the warning
though. Either:
1. Apply _INTL_MAY_RETURN_STRING_ARG to the gettext function (see patch below)
2. Remove the other __APPLE_CC__ guard that protects the _INTL_REDIRECT_ASM definition.
It will make it so the used gettext declaration will be the one at line 138, which
already has _INTL_MAY_RETURN_STRING_ARG.
Here's the diff I've been carrying for a while:
>From c40fdef23fb3c85e94454bb2e3e9559df02cb43c Mon Sep 17 00:00:00 2001
From: Simon Marchi <simon.marchi@polymtl.ca>
Date: Fri, 29 Jun 2018 17:20:06 -0400
Subject: [PATCH 1/2] Fix gettext warnings
---
intl/libgnuintl.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/intl/libgnuintl.h b/intl/libgnuintl.h
index acc9093a9d..aae7947b84 100644
--- a/intl/libgnuintl.h
+++ b/intl/libgnuintl.h
@@ -115,7 +115,7 @@ extern "C" {
/* _INTL_MAY_RETURN_STRING_ARG(n) declares that the given function may return
its n-th argument literally. This enables GCC to warn for example about
printf (gettext ("foo %y")). */
-#if __GNUC__ >= 3 && !(__APPLE_CC__ > 1 && defined __cplusplus)
+#if __GNUC__ >= 3
# define _INTL_MAY_RETURN_STRING_ARG(n) __attribute__ ((__format_arg__ (n)))
#else
# define _INTL_MAY_RETURN_STRING_ARG(n)
@@ -127,7 +127,7 @@ extern "C" {
#ifdef _INTL_REDIRECT_INLINE
extern char *libintl_gettext (const char *__msgid)
_INTL_MAY_RETURN_STRING_ARG (1);
-static inline char *gettext (const char *__msgid)
+static inline _INTL_MAY_RETURN_STRING_ARG (1) char *gettext (const char *__msgid)
{
return libintl_gettext (__msgid);
}
--
2.13.1
Simon