diff options
author | Peter Eisentraut | 2024-06-07 06:50:51 +0000 |
---|---|---|
committer | Peter Eisentraut | 2024-06-07 07:36:26 +0000 |
commit | 3482bab5e30a0cc7fba4c904ba21b4957b2876bd (patch) | |
tree | 738030042a047a38f71a24a83276a49111cdf969 | |
parent | b560a98a17aebf3fabbb8dec89f506b52e61c26b (diff) |
meson: Restore implicit warning/debug/optimize flags for extensions
Meson uses 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.
But we need these flags for Makefile.global (for extensions) and
pg_config, so we need to compute them manually based on the
higher-level options.
Without this change, extensions building using pgxs wouldn't get -Wall
or optimization options.
Author: Sutou Kouhei <[email protected]>
Discussion: https://www.postgresql.org/message-id/flat/20240122.141139.931086145628347157.kou%40clear-code.com
-rw-r--r-- | meson.build | 32 | ||||
-rw-r--r-- | src/include/meson.build | 4 |
2 files changed, 34 insertions, 2 deletions
diff --git a/meson.build b/meson.build index d6401fb8e30..f9279c837dd 100644 --- a/meson.build +++ b/meson.build @@ -1946,6 +1946,38 @@ if cc.get_id() == 'msvc' endif +# Compute flags that are built into Meson. We need these to +# substitute into Makefile.global and for pg_config. We only compute +# the flags for Unix-style compilers, since that's the only style that +# would use Makefile.global or pg_config. + +# We don't use get_option('warning_level') here, because the other +# warning levels are not useful with PostgreSQL source code. +common_builtin_flags = ['-Wall'] + +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 + + ############################################################### # Atomics diff --git a/src/include/meson.build b/src/include/meson.build index a28f115d867..58b7a9c1e7e 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 |