build: Try harder to work with nongnu ld
authorMatthias Clasen <mclasen@redhat.com>
Wed, 28 Jun 2023 20:54:34 +0000 (16:54 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Wed, 28 Jun 2023 20:54:34 +0000 (16:54 -0400)
Only try to be fast with gnu ld.

meson.build

index 19e0d96fba55c0b83a83dd3cb55eecf4b3444198..b7717e18c9128a7c2c6de641096bb78e21f1a735 100644 (file)
@@ -746,9 +746,13 @@ if objcopy.found()
   objcopy_supports_add_symbol = run_command(objcopy, '--help', check: false).stdout().contains('--add-symbol')
 endif
 
-ld = find_program('ld.bfd', 'ld', required : false)
+ld_is_bfd = false
+ld = find_program('ld', required : false)
+if ld.found()
+  ld_is_bfd = run_command(ld, '--version', check: false).stdout().contains('GNU ld')
+endif
 
-if not meson.is_cross_build() and build_machine.cpu_family() == 'x86_64' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found()
+if not meson.is_cross_build() and build_machine.cpu_family() == 'x86_64' and build_machine.system() == 'linux' and objcopy.found() and objcopy_supports_add_symbol and ld.found() and ld_is_bfd
   can_use_objcopy_for_resources = true
 else
   can_use_objcopy_for_resources = false