Source: systemd
Version: 239-7
Tags: patch
User: helm...@debian.org
Usertags: rebootstrap

cross building systemd to arm64 presently fails, because the build
system uses plain gcc and plain ld (build architecture compiler and
linker respectively) for building src/boot/efi. These values come from
the efi-cc and efi-ld options respectively. It rather should be using
host tools here.

The attached patch fixes that by changing the defaults for these options
to canary values '$cc' and '$ld' respectively. Using get_compiler is not
possible in meson_options.txt. Then in the respective use, the canary is
replaced with the detected compiler or linker. Thus only the default is
changed to sane values and overriding the with options is still
possible. I'm Ccing Jussi in case there is a better way to achieve the
same thing.

In any case, the attached patch fixes the cross build problem for arm64.
Please consider applying or improving it.

Helmut
--- systemd-239.orig/meson_options.txt
+++ systemd-239/meson_options.txt
@@ -276,9 +276,9 @@
 
 option('gnu-efi', type : 'combo', choices : ['auto', 'true', 'false'],
        description : 'gnu-efi support for sd-boot')
-option('efi-cc', type : 'string', value : 'gcc',
+option('efi-cc', type : 'string', value : '$cc',
        description : 'the compiler to use for EFI modules')
-option('efi-ld', type : 'string', value : 'ld',
+option('efi-ld', type : 'string', value : '$ld',
        description : 'the linker to use for EFI modules')
 option('efi-libdir', type : 'string',
        description : 'path to the EFI lib directory')
--- systemd-239.orig/src/boot/efi/meson.build
+++ systemd-239/src/boot/efi/meson.build
@@ -33,8 +33,16 @@
 '''.split()
 
 if conf.get('ENABLE_EFI') == 1 and get_option('gnu-efi') != 'false'
-        efi_cc = get_option('efi-cc')
-        efi_ld = get_option('efi-ld')
+        if get_option('efi-cc') == '$cc'
+                efi_cc = ' '.join(cc.cmd_array())
+        else
+                efi_cc = get_option('efi-cc')
+        endif
+        if get_option('efi-ld') == '$ld'
+                efi_ld = find_program('ld', required: true)
+        else
+                efi_ld = get_option('efi-ld')
+        endif
         efi_incdir = get_option('efi-includedir')
 
         gnu_efi_path_arch = ''

Reply via email to