-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy path9018-do-not-build-32-bit-ia32-sd-boot.patch
More file actions
94 lines (86 loc) · 3.78 KB
/
Copy path9018-do-not-build-32-bit-ia32-sd-boot.patch
File metadata and controls
94 lines (86 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
From 7a35885f3294c0cde362edcb5021556b8906be80 Mon Sep 17 00:00:00 2001
From: Arnaldo Garcia Rincon <agarrcia@amazon.com>
Date: Tue, 4 Aug 2026 03:50:03 +0000
Subject: [PATCH] build: correct sd-boot EFI arch on the Bottlerocket SDK
The SDK cross sysroot mis-reports host_machine.cpu_family(), so systemd's
efi_arch lookup resolves to the wrong EFI target: 'ia32' on x86_64 and 'arm' on
aarch64. Correct both from host_machine.cpu(), and drop the IA-32 mixed-mode
alternate build, which cannot link in this sysroot.
---
meson.build | 38 ++++++++++++++++++++++++++++++--------
src/boot/meson.build | 4 ++--
2 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/meson.build b/meson.build
index b9d8d52..b5e995f 100644
--- a/meson.build
+++ b/meson.build
@@ -1942,6 +1942,36 @@ efi_arch = {
'x86' : 'ia32',
}.get(host_machine.cpu_family(), '')
+# Bottlerocket SDK fix: the cross sysroot reports cpu_family 'x86' even for
+# x86_64 targets, which makes efi_arch resolve to 'ia32'. Force x64 when the
+# real target cpu is x86_64.
+if efi_arch == 'ia32' and host_machine.cpu() == 'x86_64'
+ efi_arch = 'x64'
+endif
+
+# The same SDK quirk applies on 64-bit ARM: cpu_family is reported as 'arm',
+# so efi_arch resolves to the 32-bit 'arm' EFI target and sd-boot is emitted as
+# systemd-bootarm.efi with EFI_MACHINE_TYPE_NAME=arm. Force aa64 when the real
+# target cpu is aarch64, so the binary is named and typed per the EFI spec and
+# matches the bootaa64.efi/grubaa64.efi convention used by shim and GRUB.
+# Note: efi_cpu_family is deliberately left resolving to 'arm' below, since the
+# 'arm' and 'aarch64' entries of efi_arch_c_args are identical
+# (-mgeneral-regs-only) and the extra 'arm' link arg
+# (-Wl,--no-wchar-size-warning) is harmless here.
+if efi_arch == 'arm' and host_machine.cpu() == 'aarch64'
+ efi_arch = 'aa64'
+endif
+
+# Single corrected arch key for all EFI flag lookups, so no flag site can
+# silently regress to the -m32 (ia32) path on this SDK.
+if efi_arch == 'x64'
+ efi_cpu_family = 'x86_64'
+elif efi_arch == 'ia32'
+ efi_cpu_family = 'x86'
+else
+ efi_cpu_family = host_machine.cpu_family()
+endif
+
pyelftools = pymod.find_installation('python3',
required : get_option('bootloader'),
modules : ['elftools'])
@@ -1954,14 +1984,8 @@ conf.set_quoted('EFI_MACHINE_TYPE_NAME', have ? efi_arch : '')
efi_arch_alt = ''
efi_cpu_family_alt = ''
-if have and efi_arch == 'x64' and cc.links('''
- #include <limits.h>
- int main(int argc, char *argv[]) {
- return __builtin_popcount(argc - CHAR_MAX);
- }''', args : ['-m32', '-march=i686'], name : '32bit build possible')
- efi_arch_alt = 'ia32'
- efi_cpu_family_alt = 'x86'
-endif
+# IA-32 mixed-mode alternate build disabled for Bottlerocket: the SDK cross
+# sysroot lacks 32-bit glibc headers (gnu/stubs-32.h), so -m32 cannot build.
pefile = pymod.find_installation('python3', required: false, modules : ['pefile'])
diff --git a/src/boot/meson.build b/src/boot/meson.build
index 6327717..28089ef 100644
--- a/src/boot/meson.build
+++ b/src/boot/meson.build
@@ -313,11 +313,11 @@ efi_archspecs = [
'c_args' : [
efi_c_args,
'-DEFI_MACHINE_TYPE_NAME="' + efi_arch + '"',
- efi_arch_c_args.get(host_machine.cpu_family(), []),
+ efi_arch_c_args.get(efi_cpu_family, []),
],
'link_args' : [
efi_c_ld_args,
- efi_arch_c_ld_args.get(host_machine.cpu_family(), []),
+ efi_arch_c_ld_args.get(efi_cpu_family, []),
],
},
]
--
2.52.0