richardphibel / rpms / systemd

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