From: Zbigniew Jędrzejewski-Szmek Date: Tue, 8 Jul 2025 11:18:07 +0000 (+0200) Subject: meson: drop -ffunction-sections -fdata-sections X-Git-Tag: v258-rc1~136^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F38118%2Fhead;p=thirdparty%2Fsystemd.git meson: drop -ffunction-sections -fdata-sections I added them in 41afb5eb7214727301132aedc381831fbfc78e37 without too much explanation. Most likely the idea was to get rid of unused code in libsystemd.so [1]. But now that I'm testing this, it doesn't seem to have an effect. LTO is needed to get rid of unused functions, and it's enough to have LTO without those options. Those options might have some downsides [2], so let's disable them since there are doubts and no particularly good reason to have them. But keep the -Wl,--gc-sections option. Without this, libsystemd.so grows a little: -rwxr-xr-x 1 zbyszek zbyszek 5532424 07-08 13:24 build/libsystemd.so.0.40.0-orig -rwxr-xr-x 1 zbyszek zbyszek 5614472 07-08 13:26 build/libsystemd.so.0.40.0-no-sections -rwxr-xr-x 1 zbyszek zbyszek 5532392 07-08 13:27 build/libsystemd.so.0.40.0 Let's apply the --gc-sections option always to make the debug and final builds more similar. We need to verify that distro packages don't unexpectedly grow after this. [1] https://unix.stackexchange.com/a/715901 [2] https://stackoverflow.com/a/36033811 --- diff --git a/meson.build b/meson.build index 127daa419b7..6f8397c966b 100644 --- a/meson.build +++ b/meson.build @@ -484,6 +484,7 @@ possible_link_flags = [ '-Wl,--fatal-warnings', '-Wl,-z,now', '-Wl,-z,relro', + '-Wl,--gc-sections', ] if get_option('b_sanitize') == 'none' @@ -503,15 +504,6 @@ possible_cc_flags = [ '-fvisibility=hidden', ] -if get_option('buildtype') != 'debug' - possible_cc_flags += [ - '-ffunction-sections', - '-fdata-sections', - ] - - possible_link_flags += '-Wl,--gc-sections' -endif - if get_option('mode') == 'developer' possible_cc_flags += '-fno-omit-frame-pointer' endif