]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
meson: Test correct efi linker for supported args
authorJan Janssen <medhefgo@web.de>
Tue, 9 Aug 2022 08:32:41 +0000 (10:32 +0200)
committerJan Janssen <medhefgo@web.de>
Wed, 10 Aug 2022 07:44:21 +0000 (09:44 +0200)
Fixes: #24241
src/boot/efi/meson.build

index 127b4e17a3a722c6ef90a95d8c732a8053f30e5d..95785dfd5d83d41895079a7f38b24b1a7877533f 100644 (file)
@@ -266,11 +266,19 @@ efi_ldflags = [
         efi_crt0,
 ]
 
-possible_link_flags = [
-        '-Wl,--no-warn-execstack',
-        '-Wl,--no-warn-rwx-segments',
-]
-efi_ldflags += cc.get_supported_link_arguments(possible_link_flags)
+foreach arg : ['-Wl,--no-warn-execstack',
+               '-Wl,--no-warn-rwx-segments']
+        # We need to check the correct linker for supported args. This is what
+        # cc.has_multi_link_arguments() is for, but it helpfully overrides our
+        # choice of linker by putting its own -fuse-ld= arg after ours.
+        if run_command('bash', '-c',
+                       'exec "$@" -x c -o/dev/null <(echo "int main(void){return 0;}")' +
+                       ' -fuse-ld=' + efi_ld + ' -Wl,--fatal-warnings ' + arg,
+                       'bash', cc.cmd_array(),
+                       check : false).returncode() == 0
+                efi_ldflags += arg
+        endif
+endforeach
 
 if efi_arch[1] in ['aarch64', 'arm', 'riscv64']
         efi_ldflags += ['-shared']