1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-07 17:17:44 +03:00

sd-boot: Add LTO support

This commit is contained in:
Jan Janssen 2021-11-10 13:30:23 +01:00
parent 0e3bcb02d2
commit b848b7e166

View File

@ -244,9 +244,12 @@ if get_option('b_ndebug') == 'true' or (
get_option('b_ndebug') == 'if-release' and get_option('buildtype') in ['plain', 'release'])
efi_cflags += ['-DNDEBUG']
endif
if get_option('b_lto')
efi_cflags += ['-flto']
endif
foreach arg : get_option('c_args')
if arg in ['-Werror', '-g', '-ggdb', '-O1', '-O2', '-O3', '-Og', '-Os', '-DNDEBUG']
if arg in ['-Werror', '-g', '-ggdb', '-O1', '-O2', '-O3', '-Og', '-Os', '-DNDEBUG', '-flto', '-fno-lto']
message('Using "@0@" from c_args for EFI compiler'.format(arg))
efi_cflags += arg
endif
@ -256,7 +259,6 @@ efi_ldflags = [
'-fuse-ld=' + get_option('efi-ld'),
'-L', efi_libdir,
'-nostdlib',
'-shared',
'-T', efi_lds,
'-Wl,--build-id=sha1',
'-Wl,--fatal-warnings',
@ -267,11 +269,16 @@ efi_ldflags = [
efi_crt0,
]
if efi_arch[1] in ['aarch64', 'arm', 'riscv64']
efi_ldflags += ['-shared', '-fwhole-program']
# Aarch64, ARM32 and 64bit RISC-V don't have an EFI capable objcopy.
# Use 'binary' instead, and add required symbols manually.
efi_ldflags += ['-Wl,--defsym=EFI_SUBSYSTEM=0xa']
efi_format = ['-O', 'binary']
else
efi_ldflags += ['-pie']
if get_option('efi-ld') == 'bfd'
efi_ldflags += '-Wl,--no-dynamic-linker'
endif
efi_format = ['--target=efi-app-@0@'.format(efi_arch[1])]
endif
@ -325,7 +332,7 @@ foreach tuple : [['systemd_boot.so', systemd_boot_efi_name, systemd_boot_objects
tuple[0],
input : tuple[2],
output : tuple[0],
command : [efi_cc, '-o', '@OUTPUT@', efi_ldflags, tuple[2], '-lefi', '-lgnuefi', '-lgcc'],
command : [efi_cc, '-o', '@OUTPUT@', efi_ldflags, efi_cflags, tuple[2], '-lefi', '-lgnuefi', '-lgcc'],
install : tuple[3],
install_dir : bootlibdir)
@ -334,6 +341,7 @@ foreach tuple : [['systemd_boot.so', systemd_boot_efi_name, systemd_boot_objects
input : so,
output : tuple[1],
command : [objcopy,
'-j', '.bss*',
'-j', '.data',
'-j', '.dynamic',
'-j', '.dynsym',