[AOT] Make native linker name configurable (#20816)
commitc66141a8c7ba2566c578c2dd012b2b723e006213
authorMarek Habersack <grendel@twistedcode.net>
Wed, 3 Feb 2021 11:03:27 +0000 (3 12:03 +0100)
committerGitHub <noreply@github.com>
Wed, 3 Feb 2021 11:03:27 +0000 (3 12:03 +0100)
tree2d2db976c7d952aa9d8dcffc175dac607412a42a
parent64368a00d85ce66de90bdae44605723838287a7b
[AOT] Make native linker name configurable (#20816)

Context: https://github.com/android/ndk/wiki/Changelog-r22#announcements
Context: https://github.com/xamarin/xamarin-android/pull/5475

This commit fixes a problem where the AOT compiler hard-codes the native
linker executable name to a platform-specific value but such an
executable does not exist in the toolchain being used, thus making the
AOT compiler fail to link the final binary.

The specific use case here is the new Android NDK r22 which not only
deprecates GNU binutils, but also removes architecture-prefixed `ld`
binary (e.g. `aarch64-linux-android-ld` no longer exists). Instead, the
NDK provides a non-prefixed `ld` binary and two prefixed ones:
`$arch-ld.gold` and `$arch-ld.bfd`. However, since the AOT compiler
hardcodes `ld` as the linker name on Linux systems, the AOT compilation
fails when attempting to link the final executable. Which, in turn,
breaks some Xamarin.Android AOT tests.

This commit fixes the issue by adding a new `ld-name` option to the AOT
compiler allowing one to specify just the name of the linker binary to
use. The rest of the toolchain mechanics doesn't change.
man/mono.1
mono/mini/aot-compiler.c