# TODO Use meson's -Db_sanitize option?
# subdir('meson/sanitizers') # Sanitizers
subdir('meson/malloc-trace') # Malloc-trace
+# TODO Use meson's -Db_lto* options?
+subdir('meson/lto') # Link-time Optimization
# Find or generate pdns/dnslabeltext.cc
if not ragel.found() and not fs.exists('pdns/dnslabeltext.cc')
--- /dev/null
+# Link-time Optimization
+
+opt_lto = get_option('lto')
+
+if opt_lto == 'thin'
+ compiler_opt = '-flto=thin'
+ if cxx.has_argument(compiler_opt)
+ add_global_arguments(compiler_opt, language: ['c', 'cpp'])
+ add_global_link_arguments(compiler_opt, language: ['c', 'cpp'])
+ else
+ opt_lto = 'auto'
+ endif
+endif
+
+if opt_lto == 'auto'
+ compiler_opt = '-flto=auto'
+ if cxx.has_argument(compiler_opt)
+ add_global_arguments(compiler_opt, language: ['c', 'cpp'])
+ add_global_link_arguments(compiler_opt, language: ['c', 'cpp'])
+ else
+ opt_lto = 'yes'
+ endif
+endif
+
+if opt_lto == 'yes'
+ compiler_opt = '-flto'
+ if cxx.has_argument(compiler_opt)
+ add_global_arguments(compiler_opt, language: ['c', 'cpp'])
+ add_global_link_arguments(compiler_opt, language: ['c', 'cpp'])
+ else
+ error('LTO was requested but is not supported')
+ endif
+endif
+
+summary('LTO', opt_lto, section: 'Configuration')
# 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')