Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rl3zw-00HOON-Rd for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2024 09:37:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rl3zu-007Xdr-TD for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2024 09:37:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rl3zu-007Xdi-JY for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2024 09:37:07 +0000 Received: from mail.clear-code.com ([153.126.206.245]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rl3zs-004dMz-7S for pgsql-hackers@postgresql.org; Fri, 15 Mar 2024 09:37:06 +0000 Received: from localhost (unknown [IPv6:2404:7a80:89c1:1200:6af9:2266:1443:f149]) by mail.clear-code.com (Postfix) with ESMTPSA id 039DD109AA4; Fri, 15 Mar 2024 18:36:57 +0900 (JST) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.clear-code.com 039DD109AA4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=clear-code.com; s=default; t=1710495418; bh=+hnI6JAFt5PUq97Eg6EjpBK3VyfERk/vfGX1tw0RGj0=; h=Date:To:Cc:Subject:From:In-Reply-To:References:From; b=Lxg5M/dGbkTaoVxSZ0oFvi8Jl8BbHN/NcaIZCatrSyQwP5XtSPNgfqhRxOHj+BcGI EMoIn022Xwqi9GohF9Epr6S461HJCCtX7IyK6wwlPt8yhy5iN2NzxE27clBMQyDi1I UypZ8no8Nwtdcgh7NfTmo3ejNGePTtfzTUxbAWvg= Date: Fri, 15 Mar 2024 18:36:55 +0900 (JST) Message-Id: <20240315.183655.616433279210896579.kou@clear-code.com> To: peter@eisentraut.org Cc: tristan@neon.tech, michael@paquier.xyz, pgsql-hackers@postgresql.org Subject: Re: meson: Specify -Wformat as a common warning flag for extensions From: Sutou Kouhei In-Reply-To: <49e97fd0-c17e-4cbc-aeee-80ac51400736@eisentraut.org> References: <49e97fd0-c17e-4cbc-aeee-80ac51400736@eisentraut.org> X-Mailer: Mew version 6.8 on Emacs 29.1 Mime-Version: 1.0 Content-Type: Multipart/Mixed; boundary="--Next_Part(Fri_Mar_15_18_36_55_2024_733)--" Content-Transfer-Encoding: 7bit X-Rspamd-Server: mail.clear-code.com X-Rspamd-Queue-Id: 039DD109AA4 X-Rspamd-Action: no action X-Spamd-Result: default: False [1.40 / 999.00]; MID_CONTAINS_FROM(1.00)[]; MV_CASE(0.50)[]; MIME_GOOD(-0.10)[multipart/mixed,text/plain,text/x-patch]; RCVD_COUNT_ZERO(0.00)[0]; MIME_TRACE(0.00)[0:+,1:+,2:+]; ARC_NA(0.00)[]; ASN(0.00)[asn:2518, ipnet:2404:7a80::/29, country:JP]; FROM_HAS_DN(0.00)[]; URIBL_BLOCKED(0.00)[eisentraut.org:email,localhost:helo,mesonbuild.com:url]; FROM_EQ_ENVFROM(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_NONE(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; SURBL_MULTI_FAIL(0.00)[eisentraut.org:server fail,mesonbuild.com:server fail,localhost:server fail] List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ----Next_Part(Fri_Mar_15_18_36_55_2024_733)-- Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Hi, In <49e97fd0-c17e-4cbc-aeee-80ac51400736@eisentraut.org> "Re: meson: Specify -Wformat as a common warning flag for extensions" on Wed, 13 Mar 2024 08:38:28 +0100, Peter Eisentraut wrote: > I think the fix then is to put -Wall into CFLAGS in > Makefile.global. Looking at a diff of Makefile.global between an > autoconf and a meson build, I also see that under meson, CFLAGS > doesn't get -O2 -g (or similar, depending on settings). This > presumably has the same underlying issue that meson handles those > flags internally. > > For someone who wants to write a fix for this, the relevant variable > is var_cflags in our meson scripts. And var_cxxflags as well. How about the attached v4 patch? Thanks, -- kou ----Next_Part(Fri_Mar_15_18_36_55_2024_733)-- Content-Type: Text/X-Patch; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="v4-0001-meson-Restore-implicit-warning-debug-optimize-fla.patch" From a515720338dc49e764f598021200316c6d01ddf9 Mon Sep 17 00:00:00 2001 From: Sutou Kouhei Date: Fri, 15 Mar 2024 18:27:30 +0900 Subject: [PATCH v4] meson: Restore implicit warning/debug/optimize flags for extensions Meson specifies warning/debug/optimize flags such as "-Wall", "-g" and "-O2" automatically based on "--warnlevel" and "--buildtype" options. And we use "--warning_level=1" and "--buildtype=debugoptimized" by default. We don't specify warning/debug/optimize flags explicitly to build PostgreSQL with Meson. Because Meson does it automatically as we said. But Meson doesn't care about flags in Makefile.global and pg_config. So we need to care about them manually. This changes do it. They detect warning/debug/optimize flags based on warning_level/debug/optimization option values because Meson doesn't tell us flags Meson guessed. --- meson.build | 40 ++++++++++++++++++++++++++++++++++++++++ src/include/meson.build | 4 ++-- 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/meson.build b/meson.build index c8fdfeb0ec..3c5c449a0a 100644 --- a/meson.build +++ b/meson.build @@ -1824,6 +1824,46 @@ endif vectorize_cflags = cc.get_supported_arguments(['-ftree-vectorize']) unroll_loops_cflags = cc.get_supported_arguments(['-funroll-loops']) +# They aren't used for building PostgreSQL itself because Meson does +# everything internally. They are used by extensions via pg_config or +# Makefile.global. +common_builtin_flags = [] + +warning_level = get_option('warning_level') +# See https://mesonbuild.com/Builtin-options.html#details-for-warning_level for +# warning_level values. +if warning_level == '1' + common_builtin_flags += ['-Wall', '/W2'] +elif warning_level == '2' + common_builtin_flags += ['-Wall', '-Wextra', '/W3'] +elif warning_level == '3' + common_builtin_flags += ['-Wall', '-Wextra', '-Wpedantic', '/W4'] +elif warning_level == 'everything' + common_builtin_flags += ['-Weverything', '/Wall'] +endif + +if get_option('debug') + common_builtin_flags += ['-g'] +endif + +optimization = get_option('optimization') +if optimization == '0' + common_builtin_flags += ['-O0'] +elif optimization == '1' + common_builtin_flags += ['-O1'] +elif optimization == '2' + common_builtin_flags += ['-O2'] +elif optimization == '3' + common_builtin_flags += ['-O3'] +elif optimization == 's' + common_builtin_flags += ['-Os'] +endif + +cflags_builtin = cc.get_supported_arguments(common_builtin_flags) +if llvm.found() + cxxflags_builtin = cpp.get_supported_arguments(common_builtin_flags) +endif + common_warning_flags = [ '-Wmissing-prototypes', '-Wpointer-arith', diff --git a/src/include/meson.build b/src/include/meson.build index a28f115d86..58b7a9c1e7 100644 --- a/src/include/meson.build +++ b/src/include/meson.build @@ -44,9 +44,9 @@ config_paths_data.set_quoted('MANDIR', dir_prefix / dir_man) var_cc = ' '.join(cc.cmd_array()) var_cpp = ' '.join(cc.cmd_array() + ['-E']) -var_cflags = ' '.join(cflags + cflags_warn + get_option('c_args')) +var_cflags = ' '.join(cflags + cflags_builtin + cflags_warn + get_option('c_args')) if llvm.found() - var_cxxflags = ' '.join(cxxflags + cxxflags_warn + get_option('cpp_args')) + var_cxxflags = ' '.join(cxxflags + cxxflags_builtin + cxxflags_warn + get_option('cpp_args')) else var_cxxflags = '' endif -- 2.43.0 ----Next_Part(Fri_Mar_15_18_36_55_2024_733)----