dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
594167
From 38afe3074812ab355bc20a36d41871f1b4f4386b Mon Sep 17 00:00:00 2001
594167
From: Jan Janssen <medhefgo@web.de>
594167
Date: Wed, 29 Dec 2021 15:02:04 +0100
594167
Subject: [PATCH] meson: Remove efi-cc option
594167
594167
Changing the efi compiler this way doesn't really work. The gnu-efi
594167
header checks as well as supported compiler flag checks use the
594167
regular cc that meson detects. Changing the compiler this way will
594167
end up with bad compiler flags. For the very same reason, this does
594167
not work with a cross-compiler without going through proper meson
594167
cross-compilation steps either.
594167
594167
The proper way to build systemd-boot with a different compiler is to
594167
use a different build folder and then just use the proper ninja build
594167
target to only build the bootloader/stub.
594167
594167
(cherry picked from commit 52adf0e91ef00d21a2e83f7669d0823667ce6b6c)
594167
594167
Related: #2017035
594167
---
594167
 meson_options.txt        |  2 --
594167
 src/boot/efi/meson.build | 14 ++++----------
594167
 2 files changed, 4 insertions(+), 12 deletions(-)
594167
594167
diff --git a/meson_options.txt b/meson_options.txt
594167
index 401f0933d7..62cdeb4201 100644
594167
--- a/meson_options.txt
594167
+++ b/meson_options.txt
594167
@@ -414,8 +414,6 @@ option('dbus', type : 'combo', choices : ['auto', 'true', 'false'],
594167
 
594167
 option('gnu-efi', type : 'combo', choices : ['auto', 'true', 'false'],
594167
        description : 'gnu-efi support for sd-boot')
594167
-option('efi-cc', type : 'array',
594167
-       description : 'the compiler to use for EFI modules')
594167
 # Note that LLD does not support PE/COFF relocations
594167
 # https://lists.llvm.org/pipermail/llvm-dev/2021-March/149234.html
594167
 option('efi-ld', type : 'combo', choices : ['auto', 'bfd', 'gold'],
594167
diff --git a/src/boot/efi/meson.build b/src/boot/efi/meson.build
594167
index 6a0c8da9ba..11e6bf2dd0 100644
594167
--- a/src/boot/efi/meson.build
594167
+++ b/src/boot/efi/meson.build
594167
@@ -44,10 +44,6 @@ if not cc.has_header_symbol('efi.h', 'EFI_IMAGE_MACHINE_X64',
594167
 endif
594167
 
594167
 objcopy = find_program('objcopy')
594167
-efi_cc = get_option('efi-cc')
594167
-if efi_cc.length() == 0
594167
-        efi_cc = cc.cmd_array()
594167
-endif
594167
 
594167
 efi_ld = get_option('efi-ld')
594167
 if efi_ld == 'auto'
594167
@@ -62,7 +58,7 @@ efi_libdir = ''
594167
 foreach dir : [get_option('efi-libdir'),
594167
                '/usr/lib/gnuefi' / efi_arch[0],
594167
                run_command('realpath', '-e',
594167
-                        '/usr/lib' / run_command(efi_cc, '-print-multi-os-directory').stdout().strip()).stdout().strip()]
594167
+                        '/usr/lib' / run_command(cc.cmd_array(), '-print-multi-os-directory').stdout().strip()).stdout().strip()]
594167
         if dir != '' and fs.is_dir(dir)
594167
                 efi_libdir = dir
594167
                 break
594167
@@ -275,15 +271,13 @@ if run_command('grep', '-q', '__CTOR_LIST__', efi_lds).returncode() == 0
594167
         ]
594167
 endif
594167
 
594167
-efi_cc_version = run_command(efi_cc, '--version').stdout().split('\n')[0]
594167
-if efi_cc_version.contains('clang') and efi_cc_version.split('.')[0].split(' ')[-1].to_int() <= 10
594167
+if cc.get_id() == 'clang' and cc.version().split('.')[0].to_int() <= 10
594167
         # clang <= 10 doesn't pass -T to the linker and then even complains about it being unused
594167
         efi_ldflags += ['-Wl,-T,' + efi_lds, '-Wno-unused-command-line-argument']
594167
 endif
594167
 
594167
 summary({
594167
         'EFI machine type' :                efi_arch[0],
594167
-        'EFI CC' :                          '@0@'.format(' '.join(efi_cc)),
594167
         'EFI LD' :                          efi_ld,
594167
         'EFI lds' :                         efi_lds,
594167
         'EFI crt0' :                        efi_crt0,
594167
@@ -368,7 +362,7 @@ foreach file : fundamental_source_paths + common_sources + systemd_boot_sources
594167
         o_file = custom_target(file.split('/')[-1] + '.o',
594167
                                input : file,
594167
                                output : file.split('/')[-1] + '.o',
594167
-                               command : [efi_cc, '-c', '@INPUT@', '-o', '@OUTPUT@', efi_cflags],
594167
+                               command : [cc.cmd_array(), '-c', '@INPUT@', '-o', '@OUTPUT@', efi_cflags],
594167
                                depend_files : efi_headers + fundamental_headers)
594167
         if (fundamental_source_paths + common_sources + systemd_boot_sources).contains(file)
594167
                 systemd_boot_objects += o_file
594167
@@ -389,7 +383,7 @@ foreach tuple : [['systemd_boot.so', systemd_boot_efi_name, systemd_boot_objects
594167
                 tuple[0],
594167
                 input : tuple[2],
594167
                 output : tuple[0],
594167
-                command : [efi_cc, '-o', '@OUTPUT@', efi_ldflags, efi_cflags, tuple[2], '-lefi', '-lgnuefi', '-lgcc'],
594167
+                command : [cc.cmd_array(), '-o', '@OUTPUT@', efi_ldflags, efi_cflags, tuple[2], '-lefi', '-lgnuefi', '-lgcc'],
594167
                 install : tuple[3],
594167
                 install_dir : bootlibdir)
594167