]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: drop -ffunction-sections -fdata-sections 38118/head
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jul 2025 11:18:07 +0000 (13:18 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 8 Jul 2025 12:51:56 +0000 (14:51 +0200)
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

meson.build

index 127daa419b712448a1518ec9a670e9bbbdffc9a4..6f8397c966b27fd7f3362c875fe50d68eed488e3 100644 (file)
@@ -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