summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--meson.build26
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'