From 3a95850dfeb20378183efcb4e2f78c7dc347e41f Mon Sep 17 00:00:00 2001 From: Fred Morcos Date: Fri, 4 Aug 2023 13:53:49 +0200 Subject: [PATCH] Meson: Automatic Variable Initialization --- meson.build | 1 + meson/auto-var-init/meson.build | 15 +++++++++++++++ meson_options.txt | 1 + 3 files changed, 17 insertions(+) create mode 100644 meson/auto-var-init/meson.build diff --git a/meson.build b/meson.build index 5351dd54fe..3624957873 100644 --- a/meson.build +++ b/meson.build @@ -67,6 +67,7 @@ subdir('meson/auth-tools') # Tools subdir('meson/ixfrdist') # Ixfrdist subdir('meson/systemd') # Systemd and unit file handling subdir('meson/code-coverage') # Code coverage +subdir('meson/auto-var-init') # Automatic Variable Initialization # Find or generate pdns/dnslabeltext.cc if not ragel.found() and not fs.exists('pdns/dnslabeltext.cc') diff --git a/meson/auto-var-init/meson.build b/meson/auto-var-init/meson.build new file mode 100644 index 0000000000..5fc4d31bbf --- /dev/null +++ b/meson/auto-var-init/meson.build @@ -0,0 +1,15 @@ +# Automatic Variable Initialization + +auto_var_init = get_option('auto-var-init') + +if auto_var_init != 'disabled' + arg = '-ftrivial-auto-var-init=' + auto_var_init + if not cxx.has_argument(arg) + error('Compiler does not support ' + arg + ', which is needed for automatic variable initialization') + subdir_done() + endif + + add_global_arguments(arg) +endif + +summary('Auto Var Init', auto_var_init, section: 'Configuration') diff --git a/meson_options.txt b/meson_options.txt index a824379211..8732734a9c 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -47,3 +47,4 @@ option('lua-records', type: 'boolean', value: true, description: 'Build support option('systemd-service-user', type: 'string', value: 'pdns', description: 'User to run the systemd pdns service as. Only the setuid setting and User field in the systemd unit file are affected, the user is not created') option('systemd-service-group', type: 'string', value: 'pdns', description: 'Group to run the systemd pdns service under. Only the setgid setting and Group field in the systemd unit file are affected, the group is not created') option('code-coverage', type: 'boolean', value: false, description: 'Enable code coverage') +option('auto-var-init', type: 'combo', value: 'disabled', choices: ['zero', 'pattern', 'disabled'], description: 'Enable initialization of automatic variables') -- 2.47.2