From 00b1a33729d8feb8d573a9f19b4a372fc86c8df3 Mon Sep 17 00:00:00 2001 From: Mintsuki Date: Sat, 29 Mar 2025 22:53:18 +0100 Subject: [PATCH] build: Compile with -fdata-sections and -ffunction-sections --- meson.build | 4 ++++ tests/meson.build | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index bb9afe70df..fa8ca833ad 100644 --- a/meson.build +++ b/meson.build @@ -77,6 +77,10 @@ if not headers_only add_project_arguments('-fno-rtti', '-fno-exceptions', language: 'cpp') add_project_link_arguments('-nostdlib', language: ['c', 'cpp']) + if library_type == 'static' + add_project_arguments('-fdata-sections', '-ffunction-sections', language: ['c', 'cpp']) + endif + if get_option('buildtype').startswith('debug') add_project_arguments('-D__MLIBC_DEBUG', language : ['c', 'cpp']) endif diff --git a/tests/meson.build b/tests/meson.build index 93e61ec6a3..f1d9ca6cfc 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -154,7 +154,7 @@ extra_cflags_test_cases = { test_sources = [] test_objects = [] -test_link_args = [] +test_link_args = ['-Wl,--gc-sections'] test_c_args = ['-D_GNU_SOURCE', '-U__MLIBC_DEBUG', '-U__MLIBC_BUILDING_MLIBC', '-fhosted', '-fno-builtin'] use_pie = false