summaryrefslogtreecommitdiffstats
path: root/src/boot/efi/meson.build
diff options
context:
space:
mode:
authorJan Janssen <medhefgo@web.de>2022-02-02 11:24:41 +0100
committerJan Janssen <medhefgo@web.de>2022-04-07 18:45:03 +0200
commit7faded269dec9347543b43654cdc99aabc461da7 (patch)
treee93982b97b73d438ab291276db1889715e0af0c3 /src/boot/efi/meson.build
parentmeson: Add efi-cflags option (diff)
downloadsystemd-7faded269dec9347543b43654cdc99aabc461da7.tar.xz
systemd-7faded269dec9347543b43654cdc99aabc461da7.zip
meson: Add support for building efi binaries on multilib
This allows building 32bit versions of efi binaries on x86_64 machines and vice-versa by passing "-Defi-cflags=-m32" to meson, provided the 32bit gnu-efi and gcc-multilib are available. It is expected that distros that want to provide both ia32 and x64 versions to use a second build dir to build the non-native version by adding -m32 to efi-cflags and then running the sd-boot/sd-stub ninja target directly.
Diffstat (limited to '')
-rw-r--r--src/boot/efi/meson.build30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build
index b2b090256c..a17857e63e 100644
--- a/src/boot/efi/meson.build
+++ b/src/boot/efi/meson.build
@@ -10,6 +10,12 @@ if not get_option('efi') or get_option('gnu-efi') == 'false'
subdir_done()
endif
+efi_arch = host_machine.cpu_family()
+if efi_arch == 'x86' and '-m64' in get_option('efi-cflags')
+ efi_arch = 'x86_64'
+elif efi_arch == 'x86_64' and '-m32' in get_option('efi-cflags')
+ efi_arch = 'x86'
+endif
efi_arch = {
# host_cc_arch: [efi_arch (see Table 3-2 in UEFI spec), gnu_efi_inc_arch]
'x86': ['ia32', 'ia32'],
@@ -17,10 +23,13 @@ efi_arch = {
'arm': ['arm', 'arm'],
'aarch64': ['aa64', 'aarch64'],
'riscv64': ['riscv64', 'riscv64'],
-}.get(host_machine.cpu_family(), [])
+}.get(efi_arch, [])
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]))
+if efi_arch.length() > 0 and not cc.has_header(
+ '@0@/@1@/efibind.h'.format(efi_incdir, efi_arch[1]),
+ args: get_option('efi-cflags'))
+
efi_arch = []
endif
@@ -33,7 +42,7 @@ if efi_arch.length() == 0
endif
if not cc.has_header_symbol('efi.h', 'EFI_IMAGE_MACHINE_X64',
- args: ['-nostdlib', '-ffreestanding', '-fshort-wchar'],
+ args: ['-nostdlib', '-ffreestanding', '-fshort-wchar'] + get_option('efi-cflags'),
include_directories: include_directories(efi_incdir, efi_incdir / efi_arch[1]))
if get_option('gnu-efi') == 'true'
@@ -54,14 +63,19 @@ if efi_ld == 'auto'
endif
endif
+efi_multilib = run_command(
+ cc.cmd_array(), '-print-multi-os-directory', get_option('efi-cflags'),
+ check: false
+).stdout().strip()
+efi_multilib = run_command(
+ 'realpath', '-e', '/usr/lib' / efi_multilib,
+ check: false
+).stdout().strip()
+
efi_libdir = ''
foreach dir : [get_option('efi-libdir'),
'/usr/lib/gnuefi' / efi_arch[0],
- run_command(
- 'realpath', '-e',
- '/usr/lib' / run_command(cc.cmd_array(), '-print-multi-os-directory', check: false).stdout().strip(),
- check: false
- ).stdout().strip()]
+ efi_multilib]
if dir != '' and fs.is_dir(dir)
efi_libdir = dir
break