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
'-Wl,--fatal-warnings',
'-Wl,-z,now',
'-Wl,-z,relro',
+ '-Wl,--gc-sections',
]
if get_option('b_sanitize') == 'none'
'-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