Hi, I'm an extension developer. If I use PostgreSQL built with Meson, I get the following warning:
cc1: warning: '-Wformat-security' ignored without '-Wformat' [-Wformat-security] Because "pg_config --cflags" includes -Wformat-security but doesn't include -Wformat. Can we specify -Wformat as a common warning flag too? If we do it, "pg_config --cflags" includes both of -Wformat-security and -Wformat. So I don't get the warning. Thanks, -- kou
>From 0913033512c9b75ee3d2941c89ff8696f3c5f53b Mon Sep 17 00:00:00 2001 From: Sutou Kouhei <k...@clear-code.com> Date: Mon, 22 Jan 2024 13:51:58 +0900 Subject: [PATCH v1] meson: Specify -Wformat explicitly for extensions We specify -Wformat-security as a common warning flag explicitly. Our common warning flags are used by extensions via pgxs/src/Makefile.global or "pg_config --cflags". If -Wformat-security is used without -Wall/-Wformat, GCC shows the following warning: cc1: warning: '-Wformat-security' ignored without '-Wformat' [-Wformat-security] We can't assume that all extensions use -Wall/-Wformat. So specifying only -Wformat-security may cause the warning. If we specify -Wformat explicitly, the warning isn't shown. --- meson.build | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/meson.build b/meson.build index 55184db248..de6ce778fc 100644 --- a/meson.build +++ b/meson.build @@ -1822,6 +1822,14 @@ common_warning_flags = [ '-Wimplicit-fallthrough=3', '-Wcast-function-type', '-Wshadow=compatible-local', + # This is for preventing the "cc1: warning: '-Wformat-security' + # ignored without '-Wformat' [-Wformat-security]" warning. We don't + # need this for PostgreSQL itself. This is just for + # extensions. Extensions use "pg_config --cflags" to build + # themselves. If extensions use only -Wformat-security, the warning + # is shown. If we have this here, extensions use both of -Wformat + # and -Wformat-security. So the warning isn't shown. + '-Wformat', # This was included in -Wall/-Wformat in older GCC versions '-Wformat-security', ] -- 2.43.0