Skip to content

Commit 3482bab

Browse files
committed
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 <kou@clear-code.com> Discussion: https://www.postgresql.org/message-id/flat/20240122.141139.931086145628347157.kou%40clear-code.com
1 parent b560a98 commit 3482bab

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

meson.build

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,6 +1946,38 @@ if cc.get_id() == 'msvc'
19461946
endif
19471947

19481948

1949+
# Compute flags that are built into Meson. We need these to
1950+
# substitute into Makefile.global and for pg_config. We only compute
1951+
# the flags for Unix-style compilers, since that's the only style that
1952+
# would use Makefile.global or pg_config.
1953+
1954+
# We don't use get_option('warning_level') here, because the other
1955+
# warning levels are not useful with PostgreSQL source code.
1956+
common_builtin_flags = ['-Wall']
1957+
1958+
if get_option('debug')
1959+
common_builtin_flags += ['-g']
1960+
endif
1961+
1962+
optimization = get_option('optimization')
1963+
if optimization == '0'
1964+
common_builtin_flags += ['-O0']
1965+
elif optimization == '1'
1966+
common_builtin_flags += ['-O1']
1967+
elif optimization == '2'
1968+
common_builtin_flags += ['-O2']
1969+
elif optimization == '3'
1970+
common_builtin_flags += ['-O3']
1971+
elif optimization == 's'
1972+
common_builtin_flags += ['-Os']
1973+
endif
1974+
1975+
cflags_builtin = cc.get_supported_arguments(common_builtin_flags)
1976+
if llvm.found()
1977+
cxxflags_builtin = cpp.get_supported_arguments(common_builtin_flags)
1978+
endif
1979+
1980+
19491981

19501982
###############################################################
19511983
# Atomics

src/include/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ config_paths_data.set_quoted('MANDIR', dir_prefix / dir_man)
4444

4545
var_cc = ' '.join(cc.cmd_array())
4646
var_cpp = ' '.join(cc.cmd_array() + ['-E'])
47-
var_cflags = ' '.join(cflags + cflags_warn + get_option('c_args'))
47+
var_cflags = ' '.join(cflags + cflags_builtin + cflags_warn + get_option('c_args'))
4848
if llvm.found()
49-
var_cxxflags = ' '.join(cxxflags + cxxflags_warn + get_option('cpp_args'))
49+
var_cxxflags = ' '.join(cxxflags + cxxflags_builtin + cxxflags_warn + get_option('cpp_args'))
5050
else
5151
var_cxxflags = ''
5252
endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy