diff options
author | David Härdeman <david@hardeman.nu> | 2020-06-24 10:32:54 +0200 |
---|---|---|
committer | David Härdeman <david@hardeman.nu> | 2020-06-24 10:32:54 +0200 |
commit | 7e980225821aaa3073fc46d2dc248e9571d3c298 (patch) | |
tree | 50879b24a0489df5c7c20528c83fca7d47b0b3ac | |
parent | 40de1bb4fec2d17ad0aa10d8b0f7fa05c4d4a196 (diff) |
Organise linker and cc flags a bit
-rw-r--r-- | meson.build | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/meson.build b/meson.build index eb9ae1e..8160a0a 100644 --- a/meson.build +++ b/meson.build @@ -6,17 +6,35 @@ project('minecproxy', 'c_std=gnu18', 'sysconfdir=/etc', 'warning_level=2', + 'b_lto=true', ] ) cc = meson.get_compiler('c') -basic_disabled_warnings = [ - '-Wno-sign-compare', +cc_flags = [ + '-D_GNU_SOURCE', ] -add_project_arguments(cc.get_supported_arguments(basic_disabled_warnings), language : 'c') +cc_warning_flags = [ + '-Wno-sign-compare', # Lots of pointless warnings +] +cc_flags += cc.get_supported_arguments(cc_warning_flags) +cc_extra_flags = [ + '-ffunction-sections', # Generate each function in a separate section + '-fdata-sections', # Ditto for data +] +cc_flags += cc.get_supported_arguments(cc_extra_flags) +add_project_arguments(cc_flags, language: 'c') -add_project_arguments('-D_GNU_SOURCE', language: 'c') +ld_flags = [] +ld_extra_flags = [ + '-Wl,-z,defs', # Detect and reject underlinking + '-Wl,-z,now', # Disable lazy binding + '-Wl,-z,relro', # Read-only segments after relocation + '-Wl,--gc-sections', # Remove unused sections +] +ld_flags += cc.get_supported_link_arguments(ld_extra_flags) +add_project_link_arguments(ld_flags, language: 'c') sysconfdir = join_paths(get_option('prefix'), get_option('sysconfdir'), meson.project_name()) mainconfname = meson.project_name() + '.conf' |