subdir('meson/systemd') # Systemd and unit file handling
subdir('meson/code-coverage') # Code coverage
subdir('meson/auto-var-init') # Automatic Variable Initialization
-# TODO Use meson's -Db_sanitize option?
-# subdir('meson/sanitizers') # Sanitizers
+subdir('meson/sanitizers') # Sanitizers
subdir('meson/malloc-trace') # Malloc-trace
# TODO Use meson's -Db_lto* options?
subdir('meson/lto') # Link-time Optimization
--- /dev/null
+# Address Sanitizer Fiber Switching
+# Inputs: conf
+
+prog_single_pointer = '''
+#include <sanitizer/common_interface_defs.h>
+
+int main() {
+ __sanitizer_finish_switch_fiber(nullptr);
+ return 0;
+}
+'''
+
+prog_three_pointers = '''
+#include <sanitizer/common_interface_defs.h>
+
+int main() {
+ __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr);
+ return 0;
+}
+'''
+
+single_pointer = false
+three_pointers = false
+
+if cxx.check_header('sanitizer/common_interface_defs.h', required: false)
+ if cxx.has_header_symbol('sanitizer/common_interface_defs.h', '__sanitizer_start_switch_fiber', required: false)
+ if cxx.compiles(prog_single_pointer, name: '__sanitizer_finish_switch_fiber with a single pointer')
+ single_pointer = true
+ endif
+
+ if cxx.compiles(prog_three_pointers, name: '__sanitizer_finish_switch_fiber with three pointers')
+ three_pointers = true
+ endif
+ else
+ warning('Address Sanitizer fiber switching is not available')
+ endif
+
+else
+ warning('Address Sanitizer requested but `sanitizer/common_interface_defs.h` is invalid or cannot be found. Address Sanitizer fiber switching is not available')
+endif
+
+if not single_pointer and not three_pointers
+ warning('Address Sanitizer fiber switching is not available due to an unknown API version')
+endif
+
+conf.set10('HAVE_FIBER_SANITIZER', single_pointer or three_pointers, description: 'Address Sanitizer fiber annotation interface is available')
+conf.set10('HAVE_SANITIZER_FINISH_SWITCH_FIBER_SINGLE_PTR', single_pointer, description: 'Address Sanitizer: __sanitizer_finish_switch_fiber takes only a pointer')
+conf.set10('HAVE_SANITIZER_FINISH_SWITCH_FIBER_THREE_PTRS', three_pointers, description: 'Address Sanitizer: __sanitizer_finish_switch_fiber takes three pointers')
+++ /dev/null
-# Address Sanitizer
-# Inputs: conf
-
-opt_address_sanitizer = get_option('sanitizer-address')
-
-if not opt_address_sanitizer
- subdir_done()
-endif
-
-if not cxx.has_argument('-fsanitize=address')
- error('Address Sanitizer requested but compiler does not support `-fsanitize=address`')
-endif
-
-if not cxx.check_header('sanitizer/common_interface_defs.h')
- error('Address Sanitizer requested but `sanitizer/common_interface_defs.h` is invalid or cannot be found')
-endif
-
-if not cxx.has_header_symbol('sanitizer/common_interface_defs.h', '__sanitizer_start_switch_fiber', required: false)
- warning('Address Sanitizer fiber switching is not available')
-endif
-
-single_pointer = false
-prog_single_pointer = '''
-#include <sanitizer/common_interface_defs.h>
-
-int main() {
- __sanitizer_finish_switch_fiber(nullptr);
- return 0;
-}
-'''
-
-three_pointers = false
-prog_three_pointers = '''
-#include <sanitizer/common_interface_defs.h>
-
-int main() {
- __sanitizer_finish_switch_fiber(nullptr, nullptr, nullptr);
- return 0;
-}
-'''
-
-if cxx.compiles(prog_single_pointer, name: '__sanitizer_finish_switch_fiber with a single pointer')
- single_pointer = true
-endif
-
-if cxx.compiles(prog_three_pointers, name: '__sanitizer_finish_switch_fiber with three pointers')
- three_pointers = true
-endif
-
-if not single_pointer and not three_pointers
- warning('Address Sanitizer fiber switching is not available due to an unknown API version')
-endif
-
-conf.set10('HAVE_FIBER_SANITIZER', single_pointer or three_pointers, description: 'Address Sanitizer fiber annotation interface is available')
-conf.set10('HAVE_SANITIZER_FINISH_SWITCH_FIBER_SINGLE_PTR', single_pointer, description: 'Address Sanitizer: __sanitizer_finish_switch_fiber takes only a pointer')
-conf.set10('HAVE_SANITIZER_FINISH_SWITCH_FIBER_THREE_PTRS', three_pointers, description: 'Address Sanitizer: __sanitizer_finish_switch_fiber takes three pointers')
-
-add_global_arguments('-fsanitize=address', language: ['cpp'])
-
-summary('address', opt_address_sanitizer, bool_yn: true, section: 'Sanitizers')
# Sanitizers
-subdir('address-sanitizer')
+opt_sanitize = get_option('b_sanitize')
-sanitizers = {
- 'memory': 'Memory',
- 'thread': 'Thread',
- 'leak': 'Leak',
- 'undefined': 'Undefined Behavior',
-}
-
-foreach sanitizer, name: sanitizers
- opt_name = 'opt_' + sanitizer + '_sanitizer'
- set_variable(opt_name, get_option('sanitizer-' + sanitizer))
-
- if not get_variable(opt_name)
- continue
- endif
-
- compiler_opt = '-fsanitize=' + sanitizer
- if not cxx.has_argument(compiler_opt)
- error(name + ' Sanitizer requested but compiler does not support `' + compiler_opt + '`')
- endif
- add_global_arguments(compiler_opt, language: ['cpp'])
- summary(name, get_variable(opt_name), bool_yn: true, section: 'Sanitizers')
-endforeach
-
-if opt_address_sanitizer and opt_thread_sanitizer
- error('Address Sanitizer is not compatible with Thread Sanitizer')
+if opt_sanitize == 'address' or opt_sanitize == 'address,undefined'
+ subdir('address-sanitizer-fiber-switching')
endif
-if opt_memory_sanitizer and opt_address_sanitizer
- error('Memory Sanitizer is not compatible with Address Sanitizer')
+if opt_sanitize != 'none'
+ add_global_arguments('-fno-omit-frame-pointer', language: ['c', 'cpp'])
endif
-if opt_memory_sanitizer and opt_leak_sanitizer
- error('Memory Sanitizer is not compatible with Leak Sanitizer')
-endif
-
-if opt_memory_sanitizer and opt_thread_sanitizer
- error('Memory Sanitizer is not compatible with Thread Sanitizer')
-endif
-
-if opt_address_sanitizer or opt_thread_sanitizer or opt_leak_sanitizer or opt_undefined_behavior_sanitizer or opt_memory_sanitizer
- add_global_arguments('-fno-omit-frame-pointer', language: ['cpp'])
-endif
+summary('Sanitizers', opt_sanitize, bool_yn: true, section: 'Configuration')
option('systemd-service-user', type: 'string', value: 'pdns', description: 'Systemd service user (setuid and unit file; user is not created)')
option('systemd-service-group', type: 'string', value: 'pdns', description: 'Systemd service group (setgid and unit file; group is not created)')
option('auto-var-init', type: 'combo', value: 'disabled', choices: ['zero', 'pattern', 'disabled'], description: 'Enable initialization of automatic variables')
-# TODO Use meson's -Db_sanitize option?
-# option('sanitizer-address', type: 'boolean', value: false, description: 'Enable the Address Sanitizer')
-# option('sanitizer-memory', type: 'boolean', value: false, description: 'Enable the Memory Sanitizer')
-# option('sanitizer-thread', type: 'boolean', value: false, description: 'Enable the Thread Sanitizer')
-# option('sanitizer-leak', type: 'boolean', value: false, description: 'Enable the Leak Sanitizer')
-# option('sanitizer-undefined', type: 'boolean', value: false, description: 'Enable the Undefined Behavior Sanitizer')
option('malloc-trace', type: 'boolean', value: false, description: 'Enable malloc-trace')
# TODO Use meson's -Db_lto* options?
option('lto', type: 'combo', choices: ['yes', 'no', 'thin', 'auto'], value: 'no', description: 'Enable link-time optimization')