8d419f
From 2d3b47dcd5a4b356c481f89c483db3eb308fcab9 Mon Sep 17 00:00:00 2001
8d419f
From: Jan Janssen <medhefgo@web.de>
8d419f
Date: Tue, 28 Dec 2021 13:10:39 +0100
8d419f
Subject: [PATCH] boot: Build BCD parser only on arches supported by Windows
8d419f
8d419f
(cherry picked from commit 77fcf28cb88b302453b4c991a6571cb37f10634d)
8d419f
8d419f
Related: #2017035
8d419f
---
8d419f
 src/boot/efi/boot.c      |  2 ++
8d419f
 src/boot/efi/meson.build | 21 ++++++++++++---------
8d419f
 2 files changed, 14 insertions(+), 9 deletions(-)
8d419f
8d419f
diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c
8d419f
index 0286914b8b..83358406f2 100644
8d419f
--- a/src/boot/efi/boot.c
8d419f
+++ b/src/boot/efi/boot.c
8d419f
@@ -1941,6 +1941,7 @@ static void config_entry_add_osx(Config *config) {
8d419f
 }
8d419f
 
8d419f
 static void config_entry_add_windows(Config *config, EFI_HANDLE *device, EFI_FILE *root_dir) {
8d419f
+#if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__)
8d419f
         _cleanup_freepool_ CHAR8 *bcd = NULL;
8d419f
         CHAR16 *title = NULL;
8d419f
         EFI_STATUS err;
8d419f
@@ -1961,6 +1962,7 @@ static void config_entry_add_windows(Config *config, EFI_HANDLE *device, EFI_FIL
8d419f
         config_entry_add_loader_auto(config, device, root_dir, NULL,
8d419f
                                      L"auto-windows", 'w', title ?: L"Windows Boot Manager",
8d419f
                                      L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi");
8d419f
+#endif
8d419f
 }
8d419f
 
8d419f
 static void config_entry_add_linux(
8d419f
diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build
8d419f
index e628068596..6a0c8da9ba 100644
8d419f
--- a/src/boot/efi/meson.build
8d419f
+++ b/src/boot/efi/meson.build
8d419f
@@ -331,7 +331,6 @@ common_sources = [
8d419f
         'util.c']
8d419f
 
8d419f
 systemd_boot_sources = [
8d419f
-        'bcd.c',
8d419f
         'boot.c',
8d419f
         'console.c',
8d419f
         'drivers.c',
8d419f
@@ -351,6 +350,18 @@ else
8d419f
         stub_sources += 'linux.c'
8d419f
 endif
8d419f
 
8d419f
+# BCD parser only makes sense on arches that Windows supports.
8d419f
+if efi_arch[1] in ['ia32', 'x86_64', 'arm', 'aarch64']
8d419f
+        systemd_boot_sources += 'bcd.c'
8d419f
+        tests += [
8d419f
+                [['src/boot/efi/test-bcd.c'],
8d419f
+                 [],
8d419f
+                 [libzstd],
8d419f
+                 [],
8d419f
+                 'HAVE_ZSTD'],
8d419f
+        ]
8d419f
+endif
8d419f
+
8d419f
 systemd_boot_objects = []
8d419f
 stub_objects = []
8d419f
 foreach file : fundamental_source_paths + common_sources + systemd_boot_sources + stub_sources
8d419f
@@ -408,14 +419,6 @@ endforeach
8d419f
 
8d419f
 ############################################################
8d419f
 
8d419f
-tests += [
8d419f
-        [['src/boot/efi/test-bcd.c'],
8d419f
-         [],
8d419f
-         [libzstd],
8d419f
-         [],
8d419f
-         'HAVE_ZSTD'],
8d419f
-]
8d419f
-
8d419f
 test_efi_disk_img = custom_target(
8d419f
         'test-efi-disk.img',
8d419f
         input : [efi_stubs[0][0], efi_stubs[1][1]],