From 927988d41c1b0508a30284b3b14a0ce5b8320268 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 10 Sep 2024 17:39:59 +0200 Subject: [PATCH] Temporarily include `libunwind.a` from the NDK toolchain MonoVM requires `libunwind.a` on x86_64. Until the requirement is removed, we'll include the archive. https://github.com/dotnet/runtime/pull/107615 --- .../create-packs/Microsoft.Android.Runtime.proj | 4 ++++ .../xaprepare/xaprepare/Steps/Step_Android_SDK_NDK.cs | 11 ++++++++++- .../Utilities/NativeRuntimeComponents.cs | 5 +++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/build-tools/create-packs/Microsoft.Android.Runtime.proj b/build-tools/create-packs/Microsoft.Android.Runtime.proj index 22521333a8d..a0a99e844c2 100644 --- a/build-tools/create-packs/Microsoft.Android.Runtime.proj +++ b/build-tools/create-packs/Microsoft.Android.Runtime.proj @@ -52,6 +52,10 @@ projects that use the Microsoft.Android framework in .NET 6+. <_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\crtbegin_so.o" /> <_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\crtend_so.o" /> <_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libclang_rt.builtins-*-android.a" /> + + + <_AndroidRuntimePackAssets Include="$(MicrosoftAndroidSdkOutDir)lib\$(AndroidRID)\libunwind.a" /> + diff --git a/build-tools/xaprepare/xaprepare/Steps/Step_Android_SDK_NDK.cs b/build-tools/xaprepare/xaprepare/Steps/Step_Android_SDK_NDK.cs index 832127fdb85..0ec32b455f9 100644 --- a/build-tools/xaprepare/xaprepare/Steps/Step_Android_SDK_NDK.cs +++ b/build-tools/xaprepare/xaprepare/Steps/Step_Android_SDK_NDK.cs @@ -197,9 +197,18 @@ bool CopyRedistributableFiles (Context context) BuildAndroidPlatforms.NdkMinimumAPI.ToString (CultureInfo.InvariantCulture) ); + string clangArch = Configurables.Defaults.AbiToClangArch[abi]; CopyFile (abi, crtFilesPath, "crtbegin_so.o"); CopyFile (abi, crtFilesPath, "crtend_so.o"); - CopyFile (abi, clangLibPath, $"libclang_rt.builtins-{Configurables.Defaults.AbiToClangArch[abi]}-android.a"); + CopyFile (abi, clangLibPath, $"libclang_rt.builtins-{clangArch}-android.a"); + + // Yay, consistency + if (String.Compare (clangArch, "i686", StringComparison.Ordinal) == 0) { + clangArch = "i386"; + } + + // Remove once https://github.com/dotnet/runtime/pull/107615 is merged and released + CopyFile (abi, Path.Combine (clangLibPath, clangArch), "libunwind.a"); } return true; diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs b/src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs index 8c29c38069c..7374c92e776 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/NativeRuntimeComponents.cs @@ -102,6 +102,11 @@ public NativeRuntimeComponents (ITaskItem[] monoComponents) new ClangBuiltinsArchive ("arm"), new ClangBuiltinsArchive ("i686"), new ClangBuiltinsArchive ("x86_64"), + + // Remove once https://github.com/dotnet/runtime/pull/107615 is merged and released + new Archive ("libunwind.a") { + DontExportSymbols = true, + }, }; // Just the base names of libraries to link into the unified runtime. Must have all the dependencies of all the static archives we