From ee6d9760206b59baa8f2d9adb09cf730ca2d24a4 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Wed, 28 Dec 2022 10:09:48 -0800 Subject: [PATCH] wip: perl: If supported, use gcc's system_header pragma to hide warnings Author: Reviewed-by: Discussion: https://postgr.es/m/ Backpatch: --- meson.build | 9 +++++++++ src/pl/plperl/plperl.h | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/meson.build b/meson.build index b872470cdfe..1532b04c62a 100644 --- a/meson.build +++ b/meson.build @@ -1408,6 +1408,15 @@ if not cc.compiles(c99_test, name: 'c99', args: test_c_args) endif endif +# Does the compiler support #pragma GCC system_header? We optionally use it to +# avoid warnings that we can't fix (e.g. in the perl headers). +# See https://gcc.gnu.org/onlinedocs/cpp/System-Headers.html +if cc.compiles('#pragma GCC system_header', + name: 'pragma system header', + args: test_c_args + ['-Werror=unknown-pragmas']) + cdata.set('HAVE_PRAGMA_SYSTEM_HEADER', 1) +endif + sizeof_long = cc.sizeof('long', args: test_c_args) cdata.set('SIZEOF_LONG', sizeof_long) if sizeof_long == 8 diff --git a/src/pl/plperl/plperl.h b/src/pl/plperl/plperl.h index 5243f308bd5..2656a0376ee 100644 --- a/src/pl/plperl/plperl.h +++ b/src/pl/plperl/plperl.h @@ -74,6 +74,14 @@ #define HAS_BOOL 1 #endif +/* + * At least in newer versions the perl headers trigger a lot of warnings with + * our compiler flags. The system_header pragma hides warnings from within the + * rest of this file, if supported. + */ +#if HAVE_PRAGMA_SYSTEM_HEADER +#pragma GCC system_header +#endif /* * Get the basic Perl API. We use PERL_NO_GET_CONTEXT mode so that our code -- 2.38.0