mirror of
https://github.com/systemd/systemd.git
synced 2025-12-10 16:24:23 +03:00
meson: Rework gnu-efi detection
Moving all of the gnu-efi detection into src/boot/efi/meson.build makes more sense than having it partially split. And thanks to subdir_done() we can simplify the code a lot. Fixes: #21258
This commit is contained in:
committed by
Luca Boccassi
parent
fe63d890fd
commit
9cf75222f2
46
meson.build
46
meson.build
@@ -1641,39 +1641,8 @@ conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', slow_tests)
|
|||||||
|
|
||||||
#####################################################################
|
#####################################################################
|
||||||
|
|
||||||
if get_option('efi')
|
|
||||||
efi_arch = host_machine.cpu_family()
|
|
||||||
|
|
||||||
if efi_arch == 'x86'
|
|
||||||
EFI_MACHINE_TYPE_NAME = 'ia32'
|
|
||||||
gnu_efi_arch = 'ia32'
|
|
||||||
elif efi_arch == 'x86_64'
|
|
||||||
EFI_MACHINE_TYPE_NAME = 'x64'
|
|
||||||
gnu_efi_arch = 'x86_64'
|
|
||||||
elif efi_arch == 'arm'
|
|
||||||
EFI_MACHINE_TYPE_NAME = 'arm'
|
|
||||||
gnu_efi_arch = 'arm'
|
|
||||||
elif efi_arch == 'aarch64'
|
|
||||||
EFI_MACHINE_TYPE_NAME = 'aa64'
|
|
||||||
gnu_efi_arch = 'aarch64'
|
|
||||||
elif efi_arch == 'riscv64'
|
|
||||||
EFI_MACHINE_TYPE_NAME = 'riscv64'
|
|
||||||
gnu_efi_arch = 'riscv64'
|
|
||||||
else
|
|
||||||
EFI_MACHINE_TYPE_NAME = ''
|
|
||||||
gnu_efi_arch = ''
|
|
||||||
endif
|
|
||||||
|
|
||||||
have = true
|
|
||||||
conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
|
|
||||||
else
|
|
||||||
have = false
|
|
||||||
endif
|
|
||||||
conf.set10('ENABLE_EFI', have)
|
|
||||||
|
|
||||||
subdir('src/fundamental')
|
subdir('src/fundamental')
|
||||||
subdir('src/boot/efi')
|
subdir('src/boot/efi')
|
||||||
conf.set10('HAVE_GNU_EFI', have_gnu_efi)
|
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
@@ -3887,19 +3856,14 @@ summary({
|
|||||||
# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
|
# CPPFLAGS: ${OUR_CPPFLAGS} ${CPPFLAGS}
|
||||||
# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
|
# LDFLAGS: ${OUR_LDFLAGS} ${LDFLAGS}
|
||||||
|
|
||||||
if conf.get('ENABLE_EFI') == 1
|
if conf.get('ENABLE_EFI') == 1 and conf.get('HAVE_GNU_EFI') == 1
|
||||||
summary({'EFI arch' : efi_arch},
|
|
||||||
section : 'Extensible Firmware Interface')
|
|
||||||
|
|
||||||
if have_gnu_efi
|
|
||||||
summary({
|
summary({
|
||||||
'EFI machine type' : EFI_MACHINE_TYPE_NAME,
|
'EFI machine type' : efi_arch[0],
|
||||||
'EFI CC' : '@0@'.format(' '.join(efi_cc)),
|
'EFI CC' : '@0@'.format(' '.join(efi_cc)),
|
||||||
'EFI lds' : efi_lds,
|
'EFI lds' : efi_lds,
|
||||||
'EFI crt0' : efi_crt0,
|
'EFI crt0' : efi_crt0,
|
||||||
'EFI include directory' : efi_incdir},
|
'EFI include directory' : efi_incdir},
|
||||||
section : 'Extensible Firmware Interface')
|
section : 'Extensible Firmware Interface')
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
found = []
|
found = []
|
||||||
@@ -3947,11 +3911,11 @@ foreach tuple : [
|
|||||||
# components
|
# components
|
||||||
['backlight'],
|
['backlight'],
|
||||||
['binfmt'],
|
['binfmt'],
|
||||||
['bpf-framework', conf.get('BPF_FRAMEWORK') == 1],
|
['bpf-framework'],
|
||||||
['coredump'],
|
['coredump'],
|
||||||
['environment.d'],
|
['environment.d'],
|
||||||
['efi'],
|
['efi'],
|
||||||
['gnu-efi', have_gnu_efi],
|
['gnu-efi'],
|
||||||
['firstboot'],
|
['firstboot'],
|
||||||
['hibernate'],
|
['hibernate'],
|
||||||
['homed'],
|
['homed'],
|
||||||
@@ -4008,7 +3972,7 @@ foreach tuple : [
|
|||||||
['debug hashmap'],
|
['debug hashmap'],
|
||||||
['debug mmap cache'],
|
['debug mmap cache'],
|
||||||
['debug siphash'],
|
['debug siphash'],
|
||||||
['valgrind', conf.get('VALGRIND') == 1],
|
['valgrind'],
|
||||||
['trace logging', conf.get('LOG_TRACE') == 1],
|
['trace logging', conf.get('LOG_TRACE') == 1],
|
||||||
['install tests', install_tests],
|
['install tests', install_tests],
|
||||||
['link-udev-shared', get_option('link-udev-shared')],
|
['link-udev-shared', get_option('link-udev-shared')],
|
||||||
|
|||||||
@@ -1,5 +1,102 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
|
conf.set10('ENABLE_EFI', get_option('efi'))
|
||||||
|
conf.set10('HAVE_GNU_EFI', false)
|
||||||
|
|
||||||
|
if not get_option('efi') or get_option('gnu-efi') == 'false'
|
||||||
|
if get_option('gnu-efi') == 'true'
|
||||||
|
error('gnu-efi support requested, but general efi support is disabled')
|
||||||
|
endif
|
||||||
|
subdir_done()
|
||||||
|
endif
|
||||||
|
|
||||||
|
efi_arch = {
|
||||||
|
# host_cc_arch: [efi_arch (see Table 3-2 in UEFI spec), gnu_efi_inc_arch]
|
||||||
|
'x86': ['ia32', 'ia32'],
|
||||||
|
'x86_64': ['x64', 'x86_64'],
|
||||||
|
'arm': ['arm', 'arm'],
|
||||||
|
'aarch64': ['aa64', 'aarch64'],
|
||||||
|
'riscv64': ['riscv64', 'riscv64'],
|
||||||
|
}.get(host_machine.cpu_family(), [])
|
||||||
|
|
||||||
|
efi_incdir = get_option('efi-includedir')
|
||||||
|
if efi_arch.length() > 0 and not cc.has_header('@0@/@1@/efibind.h'.format(efi_incdir, efi_arch[1]))
|
||||||
|
efi_arch = []
|
||||||
|
endif
|
||||||
|
|
||||||
|
if efi_arch.length() == 0
|
||||||
|
if get_option('gnu-efi') == 'true'
|
||||||
|
error('gnu-efi support requested, but headers not found or efi arch is unkown')
|
||||||
|
endif
|
||||||
|
warning('gnu-efi headers not found or efi arch is unkown, disabling gnu-efi support')
|
||||||
|
subdir_done()
|
||||||
|
endif
|
||||||
|
|
||||||
|
if not cc.has_header_symbol('efi.h', 'EFI_IMAGE_MACHINE_X64',
|
||||||
|
include_directories: include_directories(efi_incdir, efi_incdir / efi_arch[1]))
|
||||||
|
|
||||||
|
if get_option('gnu-efi') == 'true'
|
||||||
|
error('gnu-efi support requested, but found headers are too old (3.0.5+ required)')
|
||||||
|
endif
|
||||||
|
warning('gnu-efi headers are too old (3.0.5+ required), disabling gnu-efi support')
|
||||||
|
subdir_done()
|
||||||
|
endif
|
||||||
|
|
||||||
|
objcopy = find_program('objcopy')
|
||||||
|
efi_cc = get_option('efi-cc')
|
||||||
|
if efi_cc.length() == 0
|
||||||
|
efi_cc = cc.cmd_array()
|
||||||
|
endif
|
||||||
|
|
||||||
|
efi_ld = find_program(get_option('efi-ld'))
|
||||||
|
efi_ld_name = efi_ld.path().split('/')[-1]
|
||||||
|
if efi_ld_name == 'lld' or efi_ld_name == 'ld.lld'
|
||||||
|
# LLVM/LLD does not support PE/COFF relocations
|
||||||
|
# https://lists.llvm.org/pipermail/llvm-dev/2021-March/149234.html
|
||||||
|
error('LLVM/lld does not support PE/COFF relocations. Use different linker for EFI image.')
|
||||||
|
endif
|
||||||
|
|
||||||
|
efi_libdir = ''
|
||||||
|
foreach dir : [get_option('efi-libdir'),
|
||||||
|
'/usr/lib/gnuefi' / efi_arch[0],
|
||||||
|
run_command('realpath', '-e',
|
||||||
|
'/usr/lib' / run_command(efi_cc, '-print-multi-os-directory').stdout().strip()).stdout().strip()]
|
||||||
|
if run_command(test, '-d', dir).returncode() == 0
|
||||||
|
efi_libdir = dir
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
if efi_libdir == ''
|
||||||
|
if get_option('gnu-efi') == 'true'
|
||||||
|
error('gnu-efi support requested, but efi-libdir was not found')
|
||||||
|
endif
|
||||||
|
warning('efi-libdir was not found, disabling gnu-efi support')
|
||||||
|
subdir_done()
|
||||||
|
endif
|
||||||
|
|
||||||
|
efi_lds = ''
|
||||||
|
foreach location : [ # New locations first introduced with gnu-efi 3.0.11
|
||||||
|
[efi_libdir / 'efi.lds',
|
||||||
|
efi_libdir / 'crt0.o'],
|
||||||
|
# Older locations...
|
||||||
|
[efi_libdir / 'gnuefi' / 'elf_@0@_efi.lds'.format(efi_arch[1]),
|
||||||
|
efi_libdir / 'gnuefi' / 'crt0-efi-@0@.o'.format(efi_arch[1])],
|
||||||
|
[efi_libdir / 'elf_@0@_efi.lds'.format(efi_arch[1]),
|
||||||
|
efi_libdir / 'crt0-efi-@0@.o'.format(efi_arch[1])]]
|
||||||
|
if run_command(test, '-f', location[0], '-a', '-f', location[1]).returncode() == 0
|
||||||
|
efi_lds = location[0]
|
||||||
|
efi_crt0 = location[1]
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endforeach
|
||||||
|
if efi_lds == ''
|
||||||
|
if get_option('gnu-efi') == 'true'
|
||||||
|
error('gnu-efi support requested, but cannot find efi.lds')
|
||||||
|
endif
|
||||||
|
warning('efi.lds was not found, disabling gnu-efi support')
|
||||||
|
subdir_done()
|
||||||
|
endif
|
||||||
|
|
||||||
efi_headers = files('''
|
efi_headers = files('''
|
||||||
console.h
|
console.h
|
||||||
cpio.h
|
cpio.h
|
||||||
@@ -39,95 +136,33 @@ systemd_boot_sources = '''
|
|||||||
'''.split()
|
'''.split()
|
||||||
|
|
||||||
stub_sources = '''
|
stub_sources = '''
|
||||||
|
cpio.c
|
||||||
initrd.c
|
initrd.c
|
||||||
splash.c
|
splash.c
|
||||||
stub.c
|
stub.c
|
||||||
cpio.c
|
|
||||||
'''.split()
|
'''.split()
|
||||||
|
|
||||||
if efi_arch in ['x86', 'x86_64']
|
if efi_arch[1] in ['ia32', 'x86_64']
|
||||||
stub_sources += 'linux_x86.c'
|
stub_sources += 'linux_x86.c'
|
||||||
else
|
else
|
||||||
stub_sources += 'linux.c'
|
stub_sources += 'linux.c'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if conf.get('ENABLE_EFI') == 1 and get_option('gnu-efi') != 'false'
|
conf.set10('HAVE_GNU_EFI', true)
|
||||||
efi_cc = get_option('efi-cc')
|
conf.set_quoted('EFI_MACHINE_TYPE_NAME', efi_arch[0])
|
||||||
if efi_cc.length() == 0
|
|
||||||
efi_cc = cc.cmd_array()
|
|
||||||
endif
|
|
||||||
|
|
||||||
efi_ld = find_program(get_option('efi-ld'), required: true)
|
efi_conf = configuration_data()
|
||||||
efi_ld_name = efi_ld.path().split('/')[-1]
|
efi_conf.set_quoted('EFI_MACHINE_TYPE_NAME', efi_arch[0])
|
||||||
if efi_ld_name == 'lld' or efi_ld_name == 'ld.lld'
|
efi_conf.set10('ENABLE_TPM', get_option('tpm'))
|
||||||
# LLVM/LLD does not support PE/COFF relocations
|
|
||||||
# https://lists.llvm.org/pipermail/llvm-dev/2021-March/149234.html
|
|
||||||
error('LLVM/lld does not support PE/COFF relocations. Use different linker for EFI image.')
|
|
||||||
endif
|
|
||||||
|
|
||||||
efi_incdir = get_option('efi-includedir')
|
foreach ctype : ['color-normal', 'color-entry', 'color-highlight', 'color-edit']
|
||||||
|
|
||||||
gnu_efi_path_arch = ''
|
|
||||||
foreach name : [gnu_efi_arch, EFI_MACHINE_TYPE_NAME]
|
|
||||||
if (gnu_efi_path_arch == '' and name != '' and
|
|
||||||
cc.has_header('@0@/@1@/efibind.h'.format(efi_incdir, name)))
|
|
||||||
gnu_efi_path_arch = name
|
|
||||||
endif
|
|
||||||
endforeach
|
|
||||||
|
|
||||||
if gnu_efi_path_arch != '' and EFI_MACHINE_TYPE_NAME == ''
|
|
||||||
error('gnu-efi is available, but EFI_MACHINE_TYPE_NAME is unknown')
|
|
||||||
endif
|
|
||||||
|
|
||||||
efi_libdir = get_option('efi-libdir')
|
|
||||||
if efi_libdir == ''
|
|
||||||
# New location first introduced with gnu-efi 3.0.11
|
|
||||||
efi_libdir = '/usr/lib/gnuefi' / EFI_MACHINE_TYPE_NAME
|
|
||||||
cmd = run_command(test, '-e', efi_libdir)
|
|
||||||
|
|
||||||
if cmd.returncode() != 0
|
|
||||||
# Fall back to the old approach
|
|
||||||
cmd = run_command(efi_cc + ['-print-multi-os-directory'])
|
|
||||||
if cmd.returncode() == 0
|
|
||||||
path = '/usr/lib' / cmd.stdout().strip()
|
|
||||||
cmd = run_command(env, 'realpath', '-e', path)
|
|
||||||
if cmd.returncode() == 0
|
|
||||||
efi_libdir = cmd.stdout().strip()
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
have_gnu_efi = gnu_efi_path_arch != '' and efi_libdir != ''
|
|
||||||
|
|
||||||
if have_gnu_efi and not cc.has_header_symbol('efi.h', 'EFI_IMAGE_MACHINE_X64',
|
|
||||||
include_directories: include_directories(efi_incdir, efi_incdir / gnu_efi_path_arch))
|
|
||||||
have_gnu_efi = false
|
|
||||||
if get_option('gnu-efi') == 'true'
|
|
||||||
error('gnu-efi support requested, but found headers are too old (3.0.5+ required)')
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
have_gnu_efi = false
|
|
||||||
endif
|
|
||||||
|
|
||||||
if get_option('gnu-efi') == 'true' and not have_gnu_efi
|
|
||||||
error('gnu-efi support requested, but headers were not found')
|
|
||||||
endif
|
|
||||||
|
|
||||||
if have_gnu_efi
|
|
||||||
efi_conf = configuration_data()
|
|
||||||
efi_conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
|
|
||||||
efi_conf.set10('ENABLE_TPM', get_option('tpm'))
|
|
||||||
|
|
||||||
foreach ctype : ['color-normal', 'color-entry', 'color-highlight', 'color-edit']
|
|
||||||
c = get_option('efi-' + ctype).split(',')
|
c = get_option('efi-' + ctype).split(',')
|
||||||
fg = 'EFI_' + c[0].strip().underscorify().to_upper()
|
efi_conf.set(ctype.underscorify().to_upper(), 'EFI_TEXT_ATTR(@0@, @1@)'.format(
|
||||||
bg = 'EFI_BACKGROUND_' + c[1].strip().underscorify().to_upper()
|
'EFI_' + c[0].strip().underscorify().to_upper(),
|
||||||
efi_conf.set(ctype.underscorify().to_upper(), '(' + fg + '|' + bg + ')')
|
'EFI_' + c[1].strip().underscorify().to_upper()))
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
if get_option('sbat-distro') != ''
|
if get_option('sbat-distro') != ''
|
||||||
efi_conf.set_quoted('SBAT_PROJECT', meson.project_name())
|
efi_conf.set_quoted('SBAT_PROJECT', meson.project_name())
|
||||||
efi_conf.set_quoted('PROJECT_VERSION', meson.project_version())
|
efi_conf.set_quoted('PROJECT_VERSION', meson.project_version())
|
||||||
efi_conf.set('PROJECT_URL', conf.get('PROJECT_URL'))
|
efi_conf.set('PROJECT_URL', conf.get('PROJECT_URL'))
|
||||||
@@ -135,10 +170,9 @@ if have_gnu_efi
|
|||||||
error('SBAT Distro Generation must be a positive integer')
|
error('SBAT Distro Generation must be a positive integer')
|
||||||
endif
|
endif
|
||||||
efi_conf.set('SBAT_DISTRO_GENERATION', get_option('sbat-distro-generation'))
|
efi_conf.set('SBAT_DISTRO_GENERATION', get_option('sbat-distro-generation'))
|
||||||
sbatvars = [['sbat-distro', 'ID'],
|
foreach sbatvar : [['sbat-distro', 'ID'],
|
||||||
['sbat-distro-summary', 'NAME'],
|
['sbat-distro-summary', 'NAME'],
|
||||||
['sbat-distro-url', 'BUG_REPORT_URL']]
|
['sbat-distro-url', 'BUG_REPORT_URL']]
|
||||||
foreach sbatvar : sbatvars
|
|
||||||
value = get_option(sbatvar[0])
|
value = get_option(sbatvar[0])
|
||||||
if (value == '' and not meson.is_cross_build()) or value == 'auto'
|
if (value == '' and not meson.is_cross_build()) or value == 'auto'
|
||||||
cmd = 'if [ -e /etc/os-release ]; then . /etc/os-release; else . /usr/lib/os-release; fi; echo $@0@'.format(sbatvar[1])
|
cmd = 'if [ -e /etc/os-release ]; then . /etc/os-release; else . /usr/lib/os-release; fi; echo $@0@'.format(sbatvar[1])
|
||||||
@@ -163,44 +197,13 @@ if have_gnu_efi
|
|||||||
else
|
else
|
||||||
efi_conf.set_quoted('SBAT_DISTRO_VERSION', pkgver)
|
efi_conf.set_quoted('SBAT_DISTRO_VERSION', pkgver)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
efi_config_h = configure_file(
|
efi_config_h = configure_file(
|
||||||
output : 'efi_config.h',
|
output : 'efi_config.h',
|
||||||
configuration : efi_conf)
|
configuration : efi_conf)
|
||||||
|
|
||||||
objcopy = find_program('objcopy')
|
compile_args = cc.get_supported_arguments(
|
||||||
|
|
||||||
efi_location_map = [
|
|
||||||
# New locations first introduced with gnu-efi 3.0.11
|
|
||||||
[efi_libdir / 'efi.lds',
|
|
||||||
efi_libdir / 'crt0.o'],
|
|
||||||
# Older locations...
|
|
||||||
[efi_libdir / 'gnuefi' / 'elf_@0@_efi.lds'.format(gnu_efi_path_arch),
|
|
||||||
efi_libdir / 'gnuefi' / 'crt0-efi-@0@.o'.format(gnu_efi_path_arch)],
|
|
||||||
[efi_libdir / 'elf_@0@_efi.lds'.format(gnu_efi_path_arch),
|
|
||||||
efi_libdir / 'crt0-efi-@0@.o'.format(gnu_efi_path_arch)]]
|
|
||||||
efi_lds = ''
|
|
||||||
foreach location : efi_location_map
|
|
||||||
if efi_lds == ''
|
|
||||||
cmd = run_command(test, '-f', location[0])
|
|
||||||
if cmd.returncode() == 0
|
|
||||||
efi_lds = location[0]
|
|
||||||
efi_crt0 = location[1]
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endforeach
|
|
||||||
if efi_lds == ''
|
|
||||||
if get_option('gnu-efi') == 'true'
|
|
||||||
error('gnu-efi support requested, but cannot find efi.lds')
|
|
||||||
else
|
|
||||||
have_gnu_efi = false
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
if have_gnu_efi
|
|
||||||
compile_args = cc.get_supported_arguments(
|
|
||||||
basic_disabled_warnings +
|
basic_disabled_warnings +
|
||||||
possible_common_cc_flags + [
|
possible_common_cc_flags + [
|
||||||
'-fno-stack-protector',
|
'-fno-stack-protector',
|
||||||
@@ -211,59 +214,51 @@ if have_gnu_efi
|
|||||||
'-Wextra',
|
'-Wextra',
|
||||||
'-Wsign-compare',
|
'-Wsign-compare',
|
||||||
]
|
]
|
||||||
) + [
|
) + [
|
||||||
'-nostdlib',
|
'-nostdlib',
|
||||||
'-std=gnu99',
|
'-std=gnu99',
|
||||||
'-ffreestanding',
|
'-ffreestanding',
|
||||||
'-fshort-wchar',
|
'-fshort-wchar',
|
||||||
'-isystem', efi_incdir,
|
'-isystem', efi_incdir,
|
||||||
'-isystem', efi_incdir / gnu_efi_path_arch,
|
'-isystem', efi_incdir / efi_arch[1],
|
||||||
'-I', fundamental_path,
|
'-I', fundamental_path,
|
||||||
'-DSD_BOOT',
|
'-DSD_BOOT',
|
||||||
'-DGNU_EFI_USE_MS_ABI',
|
'-DGNU_EFI_USE_MS_ABI',
|
||||||
'-include', efi_config_h,
|
'-include', efi_config_h,
|
||||||
'-include', version_h,
|
'-include', version_h,
|
||||||
]
|
]
|
||||||
|
|
||||||
if efi_arch == 'x86_64'
|
compile_args += cc.get_supported_arguments({
|
||||||
compile_args += ['-mno-red-zone',
|
'ia32': ['-mno-sse', '-mno-mmx'],
|
||||||
'-mno-sse',
|
'x86_64': ['-mno-red-zone', '-mno-sse', '-mno-mmx'],
|
||||||
'-mno-mmx']
|
'arm': ['-mgeneral-regs-only', '-mfpu=none'],
|
||||||
elif efi_arch == 'x86'
|
}.get(efi_arch[1], []))
|
||||||
compile_args += ['-mno-sse',
|
|
||||||
'-mno-mmx']
|
|
||||||
elif efi_arch == 'arm'
|
|
||||||
compile_args += cc.get_supported_arguments([
|
|
||||||
'-mgeneral-regs-only',
|
|
||||||
'-mfpu=none'
|
|
||||||
])
|
|
||||||
endif
|
|
||||||
|
|
||||||
# We are putting the efi_cc command line together ourselves, so make sure to pull any
|
# We are putting the efi_cc command line together ourselves, so make sure to pull any
|
||||||
# relevant compiler flags from meson/CFLAGS as povided by the user or distro.
|
# relevant compiler flags from meson/CFLAGS as povided by the user or distro.
|
||||||
|
|
||||||
if get_option('werror')
|
if get_option('werror')
|
||||||
compile_args += ['-Werror']
|
compile_args += ['-Werror']
|
||||||
endif
|
endif
|
||||||
if get_option('debug')
|
if get_option('debug')
|
||||||
compile_args += ['-ggdb', '-DEFI_DEBUG']
|
compile_args += ['-ggdb', '-DEFI_DEBUG']
|
||||||
endif
|
endif
|
||||||
if get_option('optimization') != '0'
|
if get_option('optimization') != '0'
|
||||||
compile_args += ['-O' + get_option('optimization')]
|
compile_args += ['-O' + get_option('optimization')]
|
||||||
endif
|
endif
|
||||||
if get_option('b_ndebug') == 'true' or (
|
if get_option('b_ndebug') == 'true' or (
|
||||||
get_option('b_ndebug') == 'if-release' and ['plain', 'release'].contains(get_option('buildtype')))
|
get_option('b_ndebug') == 'if-release' and get_option('buildtype') in ['plain', 'release'])
|
||||||
compile_args += ['-DNDEBUG']
|
compile_args += ['-DNDEBUG']
|
||||||
endif
|
endif
|
||||||
|
|
||||||
foreach arg : get_option('c_args')
|
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']
|
||||||
message('Using "@0@" from c_args for EFI compiler'.format(arg))
|
message('Using "@0@" from c_args for EFI compiler'.format(arg))
|
||||||
compile_args += arg
|
compile_args += arg
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
efi_ldflags = ['-T', efi_lds,
|
efi_ldflags = ['-T', efi_lds,
|
||||||
'-shared',
|
'-shared',
|
||||||
'-Bsymbolic',
|
'-Bsymbolic',
|
||||||
'-nostdlib',
|
'-nostdlib',
|
||||||
@@ -274,23 +269,22 @@ if have_gnu_efi
|
|||||||
'--build-id=sha1',
|
'--build-id=sha1',
|
||||||
'-L', efi_libdir,
|
'-L', efi_libdir,
|
||||||
efi_crt0]
|
efi_crt0]
|
||||||
if ['aarch64', 'arm', 'riscv64'].contains(efi_arch)
|
if efi_arch[1] in ['aarch64', 'arm', 'riscv64']
|
||||||
# Aarch64, ARM32 and 64bit RISC-V don't have an EFI capable objcopy.
|
# Aarch64, ARM32 and 64bit RISC-V don't have an EFI capable objcopy.
|
||||||
# Use 'binary' instead, and add required symbols manually.
|
# Use 'binary' instead, and add required symbols manually.
|
||||||
efi_ldflags += ['--defsym=EFI_SUBSYSTEM=0xa']
|
efi_ldflags += ['--defsym=EFI_SUBSYSTEM=0xa']
|
||||||
efi_format = ['-O', 'binary']
|
efi_format = ['-O', 'binary']
|
||||||
else
|
else
|
||||||
efi_format = ['--target=efi-app-@0@'.format(gnu_efi_arch)]
|
efi_format = ['--target=efi-app-@0@'.format(efi_arch[1])]
|
||||||
endif
|
endif
|
||||||
|
|
||||||
systemd_boot_objects = []
|
systemd_boot_objects = []
|
||||||
stub_objects = []
|
stub_objects = []
|
||||||
foreach file : fundamental_source_paths + common_sources + systemd_boot_sources + stub_sources
|
foreach file : fundamental_source_paths + common_sources + systemd_boot_sources + stub_sources
|
||||||
o_file = custom_target(file.split('/')[-1] + '.o',
|
o_file = custom_target(file.split('/')[-1] + '.o',
|
||||||
input : file,
|
input : file,
|
||||||
output : file.split('/')[-1] + '.o',
|
output : file.split('/')[-1] + '.o',
|
||||||
command : efi_cc + ['-c', '@INPUT@', '-o', '@OUTPUT@']
|
command : [efi_cc, '-c', '@INPUT@', '-o', '@OUTPUT@', compile_args],
|
||||||
+ compile_args,
|
|
||||||
depend_files : efi_headers + fundamental_headers)
|
depend_files : efi_headers + fundamental_headers)
|
||||||
if (fundamental_source_paths + common_sources + systemd_boot_sources).contains(file)
|
if (fundamental_source_paths + common_sources + systemd_boot_sources).contains(file)
|
||||||
systemd_boot_objects += o_file
|
systemd_boot_objects += o_file
|
||||||
@@ -298,23 +292,21 @@ if have_gnu_efi
|
|||||||
if (fundamental_source_paths + common_sources + stub_sources).contains(file)
|
if (fundamental_source_paths + common_sources + stub_sources).contains(file)
|
||||||
stub_objects += o_file
|
stub_objects += o_file
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
libgcc_file_name = run_command(efi_cc + ['-print-libgcc-file-name']).stdout().strip()
|
libgcc_file_name = run_command(efi_cc + ['-print-libgcc-file-name']).stdout().strip()
|
||||||
systemd_boot_efi_name = 'systemd-boot@0@.efi'.format(EFI_MACHINE_TYPE_NAME)
|
systemd_boot_efi_name = 'systemd-boot@0@.efi'.format(efi_arch[0])
|
||||||
stub_elf_name = 'linux@0@.elf.stub'.format(EFI_MACHINE_TYPE_NAME)
|
stub_elf_name = 'linux@0@.elf.stub'.format(efi_arch[0])
|
||||||
stub_efi_name = 'linux@0@.efi.stub'.format(EFI_MACHINE_TYPE_NAME)
|
stub_efi_name = 'linux@0@.efi.stub'.format(efi_arch[0])
|
||||||
|
|
||||||
efi_stubs = []
|
efi_stubs = []
|
||||||
foreach tuple : [['systemd_boot.so', systemd_boot_efi_name, systemd_boot_objects, false],
|
foreach tuple : [['systemd_boot.so', systemd_boot_efi_name, systemd_boot_objects, false],
|
||||||
[stub_elf_name, stub_efi_name, stub_objects, true]]
|
[stub_elf_name, stub_efi_name, stub_objects, true]]
|
||||||
so = custom_target(
|
so = custom_target(
|
||||||
tuple[0],
|
tuple[0],
|
||||||
input : tuple[2],
|
input : tuple[2],
|
||||||
output : tuple[0],
|
output : tuple[0],
|
||||||
command : [efi_ld, '-o', '@OUTPUT@',
|
command : [efi_ld, '-o', '@OUTPUT@', efi_ldflags, tuple[2], '-lefi', '-lgnuefi', libgcc_file_name],
|
||||||
efi_ldflags, tuple[2],
|
|
||||||
'-lefi', '-lgnuefi', libgcc_file_name],
|
|
||||||
install : tuple[3],
|
install : tuple[3],
|
||||||
install_dir : bootlibdir)
|
install_dir : bootlibdir)
|
||||||
|
|
||||||
@@ -338,13 +330,12 @@ if have_gnu_efi
|
|||||||
install_dir : bootlibdir)
|
install_dir : bootlibdir)
|
||||||
|
|
||||||
efi_stubs += [[so, stub]]
|
efi_stubs += [[so, stub]]
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
test_efi_disk_img = custom_target(
|
test_efi_disk_img = custom_target(
|
||||||
'test-efi-disk.img',
|
'test-efi-disk.img',
|
||||||
input : [efi_stubs[0][0], efi_stubs[1][1]],
|
input : [efi_stubs[0][0], efi_stubs[1][1]],
|
||||||
output : 'test-efi-disk.img',
|
output : 'test-efi-disk.img',
|
||||||
command : [test_efi_create_disk_sh, '@OUTPUT@','@INPUT@', splash_bmp])
|
command : [test_efi_create_disk_sh, '@OUTPUT@','@INPUT@', splash_bmp])
|
||||||
endif
|
|
||||||
|
|||||||
Reference in New Issue
Block a user