From d2b1f08f58149ef06c165b97595a575d2078175a Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Wed, 16 Oct 2024 16:04:42 +0200 Subject: [PATCH 1/8] Always use assembly stores when assemblies are to be embedded All the non-fastdev builds will use assembly stores unconditionally now. --- .../Tasks/BuildApk.cs | 54 +------------------ .../Xamarin.Android.Common.targets | 7 +-- 2 files changed, 4 insertions(+), 57 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs b/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs index 024b181fc66..835a6d3d57f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/BuildApk.cs @@ -101,8 +101,6 @@ public class BuildApk : AndroidTask public string RuntimeConfigBinFilePath { get; set; } - public bool UseAssemblyStore { get; set; } - public string ZipFlushFilesLimit { get; set; } public string ZipFlushSizeLimit { get; set; } @@ -423,13 +421,8 @@ void AddRuntimeConfigBlob (DSOWrapperGenerator.Config dsoWrapperConfig, ZipArchi void AddAssemblies (DSOWrapperGenerator.Config dsoWrapperConfig, ZipArchiveEx apk, bool debug, bool compress, IDictionary> compressedAssembliesInfo, string assemblyStoreApkName) { string sourcePath; - AssemblyCompression.AssemblyData compressedAssembly = null; string compressedOutputDir = Path.GetFullPath (Path.Combine (Path.GetDirectoryName (ApkOutputPath), "..", "lz4")); - AssemblyStoreBuilder? storeBuilder = null; - - if (UseAssemblyStore) { - storeBuilder = new AssemblyStoreBuilder (Log); - } + var storeBuilder = new AssemblyStoreBuilder (Log); // Add user assemblies AssemblyPackagingHelper.AddAssembliesFromCollection (Log, SupportedAbis, ResolvedUserAssemblies, DoAddAssembliesFromArchCollection); @@ -437,10 +430,6 @@ void AddAssemblies (DSOWrapperGenerator.Config dsoWrapperConfig, ZipArchiveEx ap // Add framework assemblies AssemblyPackagingHelper.AddAssembliesFromCollection (Log, SupportedAbis, ResolvedFrameworkAssemblies, DoAddAssembliesFromArchCollection); - if (!UseAssemblyStore) { - return; - } - Dictionary assemblyStorePaths = storeBuilder.Generate (AppSharedLibrariesDir); if (assemblyStorePaths.Count == 0) { @@ -467,46 +456,7 @@ void DoAddAssembliesFromArchCollection (TaskLoggingHelper log, AndroidTargetArch // Thus, we no longer just store them in the apk but we call the `GetCompressionMethod` method to find out whether // or not we're supposed to compress .so files. sourcePath = CompressAssembly (assembly); - if (UseAssemblyStore) { - storeBuilder.AddAssembly (sourcePath, assembly, includeDebugSymbols: debug); - return; - } - - // Add assembly - (string assemblyPath, string assemblyDirectory) = GetInArchiveAssemblyPath (assembly); - string wrappedSourcePath = DSOWrapperGenerator.WrapIt (Log, dsoWrapperConfig, arch, sourcePath, Path.GetFileName (assemblyPath)); - AddFileToArchiveIfNewer (apk, wrappedSourcePath, assemblyPath, compressionMethod: GetCompressionMethod (assemblyPath)); - - // Try to add config if exists - var config = Path.ChangeExtension (assembly.ItemSpec, "dll.config"); - AddAssemblyConfigEntry (dsoWrapperConfig, apk, arch, assemblyDirectory, config); - - // Try to add symbols if Debug - if (!debug) { - return; - } - - string symbols = Path.ChangeExtension (assembly.ItemSpec, "pdb"); - if (!File.Exists (symbols)) { - return; - } - - string archiveSymbolsPath = assemblyDirectory + MonoAndroidHelper.MakeDiscreteAssembliesEntryName (Path.GetFileName (symbols)); - string wrappedSymbolsPath = DSOWrapperGenerator.WrapIt (Log, dsoWrapperConfig, arch, symbols, Path.GetFileName (archiveSymbolsPath)); - AddFileToArchiveIfNewer ( - apk, - wrappedSymbolsPath, - archiveSymbolsPath, - compressionMethod: GetCompressionMethod (archiveSymbolsPath) - ); - } - - void EnsureCompressedAssemblyData (string sourcePath, uint descriptorIndex) - { - if (compressedAssembly == null) - compressedAssembly = new AssemblyCompression.AssemblyData (sourcePath, descriptorIndex); - else - compressedAssembly.SetData (sourcePath, descriptorIndex); + storeBuilder.AddAssembly (sourcePath, assembly, includeDebugSymbols: debug); } string CompressAssembly (ITaskItem assembly) diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index e4deccf9ab0..6459bf2c27b 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -320,8 +320,8 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. <_AndroidAotStripLibraries Condition=" '$(_AndroidAotStripLibraries)' == '' And '$(AndroidIncludeDebugSymbols)' != 'true' ">True - false - true + false + true True False False @@ -1588,7 +1588,6 @@ because xbuild doesn't support framework reference assemblies. .so;$(AndroidStoreUncompressedFileExtensions) .dex;$(AndroidStoreUncompressedFileExtensions) - .blob;$(AndroidStoreUncompressedFileExtensions) @@ -2108,7 +2107,6 @@ because xbuild doesn't support framework reference assemblies. ZipFlushFilesLimit="$(_ZipFlushFilesLimit)" ZipFlushSizeLimit="$(_ZipFlushSizeLimit)" ZipAlignmentPages="$(AndroidZipAlignment)" - UseAssemblyStore="$(AndroidUseAssemblyStore)" AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)" IntermediateOutputPath="$(IntermediateOutputPath)"> @@ -2148,7 +2146,6 @@ because xbuild doesn't support framework reference assemblies. ZipFlushFilesLimit="$(_ZipFlushFilesLimit)" ZipFlushSizeLimit="$(_ZipFlushSizeLimit)" ZipAlignmentPages="$(AndroidZipAlignment)" - UseAssemblyStore="$(AndroidUseAssemblyStore)" AndroidBinUtilsDirectory="$(AndroidBinUtilsDirectory)" IntermediateOutputPath="$(IntermediateOutputPath)"> From 6f7419fdd6d3e7d9bc2a7b134b13c4fefc3af721 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Thu, 24 Oct 2024 17:06:19 +0200 Subject: [PATCH 2/8] Remove a lot of code to handle packaging of individual assemblies --- .../Tasks/GeneratePackageManagerJava.cs | 31 -- .../Utilities/EnvironmentHelper.cs | 48 ++-- .../Utilities/ApplicationConfig.cs | 2 - ...pplicationConfigNativeAssemblyGenerator.cs | 30 +- .../Xamarin.Android.Common.targets | 3 - .../monodroid/embedded-assemblies-zip.cc | 137 +-------- src/native/monodroid/embedded-assemblies.cc | 270 +----------------- src/native/monodroid/embedded-assemblies.hh | 44 +-- src/native/monodroid/monodroid-glue.cc | 3 - .../xamarin-app-stub/application_dso_stub.cc | 29 -- src/native/xamarin-app-stub/xamarin-app.hh | 14 - 11 files changed, 23 insertions(+), 588 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs index c0f7f0432ce..49a9b58ca2e 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs @@ -35,8 +35,6 @@ public class GeneratePackageManagerJava : AndroidTask public ITaskItem[] SatelliteAssemblies { get; set; } - public bool UseAssemblyStore { get; set; } - [Required] public string OutputDirectory { get; set; } @@ -204,21 +202,7 @@ void AddEnvironment () throw new InvalidOperationException ($"Unsupported BoundExceptionType value '{BoundExceptionType}'"); } - int assemblyNameWidth = 0; Encoding assemblyNameEncoding = Encoding.UTF8; - - Action updateNameWidth = (ITaskItem assembly) => { - if (UseAssemblyStore) { - return; - } - - string assemblyName = Path.GetFileName (assembly.ItemSpec); - int nameBytes = assemblyNameEncoding.GetBytes (assemblyName).Length; - if (nameBytes > assemblyNameWidth) { - assemblyNameWidth = nameBytes; - } - }; - int assemblyCount = 0; bool enableMarshalMethods = EnableMarshalMethods; HashSet archAssemblyNames = null; @@ -249,7 +233,6 @@ void AddEnvironment () if (SatelliteAssemblies != null) { foreach (ITaskItem assembly in SatelliteAssemblies) { - updateNameWidth (assembly); updateAssemblyCount (assembly); } } @@ -258,7 +241,6 @@ void AddEnvironment () int jnienv_initialize_method_token = -1; int jnienv_registerjninatives_method_token = -1; foreach (var assembly in ResolvedAssemblies) { - updateNameWidth (assembly); updateAssemblyCount (assembly); if (android_runtime_jnienv_class_token != -1) { @@ -272,17 +254,6 @@ void AddEnvironment () GetRequiredTokens (assembly.ItemSpec, out android_runtime_jnienv_class_token, out jnienv_initialize_method_token, out jnienv_registerjninatives_method_token); } - if (!UseAssemblyStore) { - int abiNameLength = 0; - foreach (string abi in SupportedAbis) { - if (abi.Length <= abiNameLength) { - continue; - } - abiNameLength = abi.Length; - } - assemblyNameWidth += abiNameLength + 2; // room for '/' and the terminating NUL - } - MonoComponent monoComponents = MonoComponent.None; if (MonoComponents != null && MonoComponents.Length > 0) { foreach (ITaskItem item in MonoComponents) { @@ -334,10 +305,8 @@ void AddEnvironment () JniAddNativeMethodRegistrationAttributePresent = NativeCodeGenState.TemplateJniAddNativeMethodRegistrationAttributePresent, HaveRuntimeConfigBlob = haveRuntimeConfigBlob, NumberOfAssembliesInApk = assemblyCount, - BundledAssemblyNameWidth = assemblyNameWidth, MonoComponents = (MonoComponent)monoComponents, NativeLibraries = uniqueNativeLibraries, - HaveAssemblyStore = UseAssemblyStore, AndroidRuntimeJNIEnvToken = android_runtime_jnienv_class_token, JNIEnvInitializeToken = jnienv_initialize_method_token, JNIEnvRegisterJniNativesToken = jnienv_registerjninatives_method_token, diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs index 075f0154f98..77af45f9e6f 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs @@ -46,7 +46,6 @@ public sealed class ApplicationConfig public bool broken_exception_transitions; public bool jni_add_native_method_registration_attribute_present; public bool have_runtime_config_blob; - public bool have_assemblies_blob; public bool marshal_methods_enabled; public bool ignore_split_configs; public byte bound_stream_io_exception_type; @@ -54,7 +53,6 @@ public sealed class ApplicationConfig public uint environment_variable_count; public uint system_property_count; public uint number_of_assemblies_in_apk; - public uint bundled_assembly_name_width; public uint number_of_assembly_store_files; public uint number_of_dso_cache_entries; public uint number_of_aot_cache_entries; @@ -67,7 +65,7 @@ public sealed class ApplicationConfig public string android_package_name = String.Empty; } - const uint ApplicationConfigFieldCount = 26; + const uint ApplicationConfigFieldCount = 24; const string ApplicationConfigSymbolName = "application_config"; const string AppEnvironmentVariablesSymbolName = "app_environment_variables"; @@ -241,97 +239,87 @@ static ApplicationConfig ReadApplicationConfig (EnvironmentFile envFile) ret.have_runtime_config_blob = ConvertFieldToBool ("have_runtime_config_blob", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 7: // have_assemblies_blob: bool / .byte - AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber); - ret.have_assemblies_blob = ConvertFieldToBool ("have_assemblies_blob", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); - break; - - case 8: // marshal_methods_enabled: bool / .byte + case 7: // marshal_methods_enabled: bool / .byte AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber); ret.marshal_methods_enabled = ConvertFieldToBool ("marshal_methods_enabled", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 9: // ignore_split_configs: bool / .byte + case 8: // ignore_split_configs: bool / .byte AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber); ret.ignore_split_configs = ConvertFieldToBool ("ignore_split_configs", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 10: // bound_stream_io_exception_type: byte / .byte + case 9: // bound_stream_io_exception_type: byte / .byte AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber); ret.bound_stream_io_exception_type = ConvertFieldToByte ("bound_stream_io_exception_type", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 11: // package_naming_policy: uint32_t / .word | .long + case 10: // package_naming_policy: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.package_naming_policy = ConvertFieldToUInt32 ("package_naming_policy", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 12: // environment_variable_count: uint32_t / .word | .long + case 11: // environment_variable_count: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.environment_variable_count = ConvertFieldToUInt32 ("environment_variable_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 13: // system_property_count: uint32_t / .word | .long + case 12: // system_property_count: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.system_property_count = ConvertFieldToUInt32 ("system_property_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 14: // number_of_assemblies_in_apk: uint32_t / .word | .long + case 13: // number_of_assemblies_in_apk: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.number_of_assemblies_in_apk = ConvertFieldToUInt32 ("number_of_assemblies_in_apk", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 15: // bundled_assembly_name_width: uint32_t / .word | .long - Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); - ret.bundled_assembly_name_width = ConvertFieldToUInt32 ("bundled_assembly_name_width", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); - break; - - case 16: // number_of_assembly_store_files: uint32_t / .word | .long + case 14: // number_of_assembly_store_files: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.number_of_assembly_store_files = ConvertFieldToUInt32 ("number_of_assembly_store_files", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 17: // number_of_dso_cache_entries: uint32_t / .word | .long + case 15: // number_of_dso_cache_entries: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.number_of_dso_cache_entries = ConvertFieldToUInt32 ("number_of_dso_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 18: // number_of_aot_cache_entries: uint32_t / .word | .long + case 16: // number_of_aot_cache_entries: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.number_of_aot_cache_entries = ConvertFieldToUInt32 ("number_of_aot_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 19: // android_runtime_jnienv_class_token: uint32_t / .word | .long + case 17: // android_runtime_jnienv_class_token: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.android_runtime_jnienv_class_token = ConvertFieldToUInt32 ("android_runtime_jnienv_class_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 20: // jnienv_initialize_method_token: uint32_t / .word | .long + case 18: // jnienv_initialize_method_token: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.jnienv_initialize_method_token = ConvertFieldToUInt32 ("jnienv_initialize_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 21: // jnienv_registerjninatives_method_token: uint32_t / .word | .long + case 19: // jnienv_registerjninatives_method_token: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.jnienv_registerjninatives_method_token = ConvertFieldToUInt32 ("jnienv_registerjninatives_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 22: // jni_remapping_replacement_type_count: uint32_t / .word | .long + case 20: // jni_remapping_replacement_type_count: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.jni_remapping_replacement_type_count = ConvertFieldToUInt32 ("jni_remapping_replacement_type_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 23: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long + case 21: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.jni_remapping_replacement_method_index_entry_count = ConvertFieldToUInt32 ("jni_remapping_replacement_method_index_entry_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 24: // mono_components_mask: uint32_t / .word | .long + case 22: // mono_components_mask: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.mono_components_mask = ConvertFieldToUInt32 ("mono_components_mask", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 25: // android_package_name: string / [pointer type] + case 23: // android_package_name: string / [pointer type] Assert.IsTrue (expectedPointerTypes.Contains (field [0]), $"Unexpected pointer field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); pointers.Add (field [1].Trim ()); break; diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs index 9a2335f9e75..d8bea68deb1 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs @@ -31,7 +31,6 @@ sealed class ApplicationConfig public bool broken_exception_transitions; public bool jni_add_native_method_registration_attribute_present; public bool have_runtime_config_blob; - public bool have_assemblies_blob; public bool marshal_methods_enabled; public bool ignore_split_configs; public byte bound_stream_io_exception_type; @@ -39,7 +38,6 @@ sealed class ApplicationConfig public uint environment_variable_count; public uint system_property_count; public uint number_of_assemblies_in_apk; - public uint bundled_assembly_name_width; public uint number_of_dso_cache_entries; public uint number_of_aot_cache_entries; public uint number_of_shared_libraries; diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs index 9a0bc213d6c..7f080d926d1 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs @@ -175,9 +175,7 @@ sealed class XamarinAndroidBundledAssembly public global::Android.Runtime.BoundExceptionType BoundExceptionType { get; set; } public bool JniAddNativeMethodRegistrationAttributePresent { get; set; } public bool HaveRuntimeConfigBlob { get; set; } - public bool HaveAssemblyStore { get; set; } public int NumberOfAssembliesInApk { get; set; } - public int BundledAssemblyNameWidth { get; set; } // including the trailing NUL public int AndroidRuntimeJNIEnvToken { get; set; } public int JNIEnvInitializeToken { get; set; } public int JNIEnvRegisterJniNativesToken { get; set; } @@ -227,7 +225,6 @@ protected override void Construct (LlvmIrModule module) broken_exception_transitions = BrokenExceptionTransitions, jni_add_native_method_registration_attribute_present = JniAddNativeMethodRegistrationAttributePresent, have_runtime_config_blob = HaveRuntimeConfigBlob, - have_assemblies_blob = HaveAssemblyStore, marshal_methods_enabled = MarshalMethodsEnabled, ignore_split_configs = IgnoreSplitConfigs, bound_stream_io_exception_type = (byte)BoundExceptionType, @@ -236,7 +233,6 @@ protected override void Construct (LlvmIrModule module) system_property_count = (uint)(systemProperties == null ? 0 : systemProperties.Count * 2), number_of_assemblies_in_apk = (uint)NumberOfAssembliesInApk, number_of_shared_libraries = (uint)NativeLibraries.Count, - bundled_assembly_name_width = (uint)BundledAssemblyNameWidth, number_of_dso_cache_entries = (uint)dsoCache.Count, number_of_aot_cache_entries = (uint)aotDsoCache.Count, android_runtime_jnienv_class_token = (uint)AndroidRuntimeJNIEnvToken, @@ -269,36 +265,12 @@ protected override void Construct (LlvmIrModule module) }; module.Add (dso_apk_entries); - if (!HaveAssemblyStore) { - xamarinAndroidBundledAssemblies = new List> (NumberOfAssembliesInApk); - - var emptyBundledAssemblyData = new XamarinAndroidBundledAssembly { - file_fd = -1, - data_offset = 0, - data_size = 0, - data = 0, - name_length = (uint)BundledAssemblyNameWidth, - name = null, - }; - - for (int i = 0; i < NumberOfAssembliesInApk; i++) { - xamarinAndroidBundledAssemblies.Add (new StructureInstance (xamarinAndroidBundledAssemblyStructureInfo, emptyBundledAssemblyData)); - } - } - - string bundledBuffersSize = xamarinAndroidBundledAssemblies == null ? "empty (unused when assembly stores are enabled)" : $"{BundledAssemblyNameWidth} bytes long"; - var bundled_assemblies = new LlvmIrGlobalVariable (typeof(List>), "bundled_assemblies", LlvmIrVariableOptions.GlobalWritable) { - Value = xamarinAndroidBundledAssemblies, - Comment = $" Bundled assembly name buffers, all {bundledBuffersSize}", - }; - module.Add (bundled_assemblies); - AddAssemblyStores (module); } void AddAssemblyStores (LlvmIrModule module) { - ulong itemCount = (ulong)(HaveAssemblyStore ? NumberOfAssembliesInApk : 0); + ulong itemCount = (ulong)NumberOfAssembliesInApk; var assembly_store_bundled_assemblies = new LlvmIrGlobalVariable (typeof(List>), "assembly_store_bundled_assemblies", LlvmIrVariableOptions.GlobalWritable) { ZeroInitializeArray = true, ArrayItemCount = itemCount, diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 6459bf2c27b..b1b26a82048 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -320,8 +320,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. <_AndroidAotStripLibraries Condition=" '$(_AndroidAotStripLibraries)' == '' And '$(AndroidIncludeDebugSymbols)' != 'true' ">True - false - true True False False @@ -1742,7 +1740,6 @@ because xbuild doesn't support framework reference assemblies. PackageNamingPolicy="$(AndroidPackageNamingPolicy)" BoundExceptionType="$(AndroidBoundExceptionType)" RuntimeConfigBinFilePath="$(_BinaryRuntimeConfigPath)" - UseAssemblyStore="$(AndroidUseAssemblyStore)" EnableMarshalMethods="$(_AndroidUseMarshalMethods)" CustomBundleConfigFile="$(AndroidBundleConfigurationFile)" > diff --git a/src/native/monodroid/embedded-assemblies-zip.cc b/src/native/monodroid/embedded-assemblies-zip.cc index 3f91b71dc9a..0db1208ef3f 100644 --- a/src/native/monodroid/embedded-assemblies-zip.cc +++ b/src/native/monodroid/embedded-assemblies-zip.cc @@ -85,94 +85,6 @@ EmbeddedAssemblies::zip_load_entry_common (size_t entry_index, std::vector const& entry_name, ZipEntryLoadState const& state, [[maybe_unused]] monodroid_should_register should_register) noexcept -{ -#if defined (DEBUG) - const char *last_slash = Util::find_last (entry_name, '/'); - bool entry_is_overridden = last_slash == nullptr ? false : !should_register (last_slash + 1); -#else - constexpr bool entry_is_overridden = false; -#endif - - if (register_debug_symbols && !entry_is_overridden && Util::ends_with (entry_name, SharedConstants::PDB_EXTENSION)) { - if (bundled_debug_data == nullptr) { - bundled_debug_data = new std::vector (); - bundled_debug_data->reserve (application_config.number_of_assemblies_in_apk); - } - - bundled_debug_data->emplace_back (); - set_debug_entry_data (bundled_debug_data->back (), state, entry_name); - return; - } - - if (!Util::ends_with (entry_name, SharedConstants::DLL_EXTENSION)) { - return; - } - -#if defined (DEBUG) - if (entry_is_overridden) { - return; - } -#endif - - if (bundled_assembly_index >= application_config.number_of_assemblies_in_apk || state.bundled_assemblies_slow_path) [[unlikely]] { - if (!state.bundled_assemblies_slow_path && bundled_assembly_index == application_config.number_of_assemblies_in_apk) { - log_warn (LOG_ASSEMBLY, "Number of assemblies stored at build time (%u) was incorrect, switching to slow bundling path.", application_config.number_of_assemblies_in_apk); - } - - if (extra_bundled_assemblies == nullptr) { - extra_bundled_assemblies = new std::vector (); - } - - extra_bundled_assemblies->emplace_back (); - // means we need to allocate memory to store the entry name, only the entries pre-allocated during - // build have valid pointer to the name storage area - set_entry_data (extra_bundled_assemblies->back (), state, entry_name); - return; - } - - log_debug (LOG_ASSEMBLY, "Setting bundled assembly entry data at index %zu", bundled_assembly_index); - set_assembly_entry_data (bundled_assemblies [bundled_assembly_index], state, entry_name); - log_debug (LOG_ASSEMBLY, "[%zu] data set: name == '%s'; file_name == '%s'", bundled_assembly_index, bundled_assemblies [bundled_assembly_index].name, bundled_assemblies [bundled_assembly_index].file_name); - bundled_assembly_index++; - number_of_found_assemblies = bundled_assembly_index; - have_and_want_debug_symbols = register_debug_symbols && bundled_debug_data != nullptr; -} - -force_inline void -EmbeddedAssemblies::zip_load_individual_assembly_entries (std::vector const& buf, uint32_t num_entries, [[maybe_unused]] monodroid_should_register should_register, ZipEntryLoadState &state) noexcept -{ - // TODO: do away with all the string manipulation here. Replace it with generating xxhash for the entry name - dynamic_local_string entry_name; - configure_state_for_individual_assembly_load (state); - - // clang-tidy claims we have a leak in the loop: - // - // Potential leak of memory pointed to by 'assembly_name' - // - // This is because we allocate `assembly_name` for a `.config` file, pass it to Mono and we don't free the value. - // However, clang-tidy can't know that the value is owned by Mono and we must not free it, thus the suppression. - // - // NOLINTNEXTLINE(clang-analyzer-unix.Malloc) - for (size_t i = 0uz; i < num_entries; i++) { - bool interesting_entry = zip_load_entry_common (i, buf, entry_name, state); - if (!interesting_entry) { - continue; - } - - if (entry_name[state.prefix_len + SharedConstants::REGULAR_ASSEMBLY_MARKER_INDEX] == SharedConstants::REGULAR_ASSEMBLY_MARKER_CHAR) { - unmangle_name (entry_name, state.prefix_len); - } else if (entry_name[state.prefix_len + SharedConstants::SATELLITE_ASSEMBLY_MARKER_INDEX] == SharedConstants::SATELLITE_ASSEMBLY_MARKER_CHAR) { - unmangle_name (entry_name, state.prefix_len); - } else { - continue; // Can't be an assembly, the name's not mangled - } - - store_individual_assembly_data (entry_name, state, should_register); - } -} - inline void EmbeddedAssemblies::map_assembly_store (dynamic_local_string const& entry_name, ZipEntryLoadState &state) noexcept { @@ -345,8 +257,6 @@ EmbeddedAssemblies::zip_load_entries (int fd, const char *apk_name, [[maybe_unus .data_offset = 0u, .file_size = 0u, .bundled_assemblies_slow_path = false, - .max_assembly_name_size = 0u, - .max_assembly_file_name_size = 0u, }; ssize_t nread = read (fd, buf.data (), buf.size ()); @@ -363,52 +273,7 @@ EmbeddedAssemblies::zip_load_entries (int fd, const char *apk_name, [[maybe_unus ); } - if (application_config.have_assembly_store) { - zip_load_assembly_store_entries (buf, cd_entries, state); - } else { - zip_load_individual_assembly_entries (buf, cd_entries, should_register, state); - } -} - -template -force_inline void -EmbeddedAssemblies::set_entry_data (XamarinAndroidBundledAssembly &entry, ZipEntryLoadState const& state, dynamic_local_string const& entry_name) noexcept -{ - entry.file_fd = state.file_fd; - if constexpr (NeedsNameAlloc) { - entry.name = Util::strdup_new (entry_name.get () + state.prefix_len); - if (!AndroidSystem::is_embedded_dso_mode_enabled () && state.file_name != nullptr) { - entry.file_name = Util::strdup_new (state.file_name); - } - } else { - // entry.name is preallocated at build time here and is max_name_size + 1 bytes long, filled with 0s, thus we - // don't need to append the terminating NUL even for strings of `max_name_size` characters - strncpy (entry.name, entry_name.get () + state.prefix_len, state.max_assembly_name_size); - if (!AndroidSystem::is_embedded_dso_mode_enabled () && state.file_name != nullptr) { - strncpy (entry.file_name, state.file_name, state.max_assembly_file_name_size); - } - } - entry.name_length = std::min (static_cast(entry_name.length ()) - state.prefix_len, state.max_assembly_name_size); - entry.data_offset = state.data_offset; - entry.data_size = state.file_size; - - log_debug ( - LOG_ASSEMBLY, - "Set bundled assembly entry data. file name: '%s'; entry name: '%s'; data size: %u", - entry.file_name, entry.name, entry.data_size - ); -} - -force_inline void -EmbeddedAssemblies::set_assembly_entry_data (XamarinAndroidBundledAssembly &entry, ZipEntryLoadState const& state, dynamic_local_string const& entry_name) noexcept -{ - set_entry_data (entry, state, entry_name); -} - -force_inline void -EmbeddedAssemblies::set_debug_entry_data (XamarinAndroidBundledAssembly &entry, ZipEntryLoadState const& state, dynamic_local_string const& entry_name) noexcept -{ - set_entry_data (entry, state, entry_name); + zip_load_assembly_store_entries (buf, cd_entries, state); } bool diff --git a/src/native/monodroid/embedded-assemblies.cc b/src/native/monodroid/embedded-assemblies.cc index 6a20df0bc59..d64921af348 100644 --- a/src/native/monodroid/embedded-assemblies.cc +++ b/src/native/monodroid/embedded-assemblies.cc @@ -171,203 +171,12 @@ EmbeddedAssemblies::get_assembly_data (uint8_t *data, uint32_t data_size, [[mayb } } -force_inline void -EmbeddedAssemblies::get_assembly_data (XamarinAndroidBundledAssembly const& e, uint8_t*& assembly_data, uint32_t& assembly_data_size) noexcept -{ - get_assembly_data (e.data, e.data_size, e.name, assembly_data, assembly_data_size); -} - force_inline void EmbeddedAssemblies::get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData const& e, uint8_t*& assembly_data, uint32_t& assembly_data_size) noexcept { get_assembly_data (e.image_data, e.descriptor->data_size, "", assembly_data, assembly_data_size); } -template -force_inline void -EmbeddedAssemblies::map_runtime_file (XamarinAndroidBundledAssembly& file) noexcept -{ - int fd; - bool close_fd; - if (!AndroidSystem::is_embedded_dso_mode_enabled ()) { - log_debug (LOG_ASSEMBLY, "Mapping a runtime file from filesystem"); - close_fd = true; - - // file.file_fd refers to the directory where our files live - auto temp_fd = Util::open_file_ro_at (file.file_fd, file.file_name); - if (!temp_fd) { - return; - } - fd = temp_fd.value (); - } else { - fd = file.file_fd; - close_fd = false; - } - - md_mmap_info map_info = md_mmap_apk_file (fd, file.data_offset, file.data_size, file.name); - if (close_fd) { - close (fd); - } - - auto [payload_data, payload_size] = get_wrapper_dso_payload_pointer_and_size (map_info, file.name); - - // `data_size` might have been ELF wrapper file size, we must store payload size here (the actual DLL size) - file.data_size = static_cast(payload_size); - - if (MonodroidState::is_startup_in_progress ()) { - file.data = static_cast(payload_data); - } else { - uint8_t *expected_null = nullptr; - bool already_mapped = !__atomic_compare_exchange ( - /* ptr */ &file.data, - /* expected */ &expected_null, - /* desired */ reinterpret_cast(&payload_data), - /* weak */ false, - /* success_memorder */ __ATOMIC_ACQUIRE, - /* failure_memorder */ __ATOMIC_RELAXED - ); - - if (already_mapped) { - log_debug (LOG_ASSEMBLY, "Assembly %s already mmapped by another thread, unmapping our copy", file.name); - munmap (map_info.area, file.data_size); - map_info.area = nullptr; - } - } - - if constexpr (LogMapping) { - if (Util::should_log (LOG_ASSEMBLY) && map_info.area != nullptr) [[unlikely]] { - const char *p = (const char*) file.data; - - std::array header; - for (size_t j = 0uz; j < header.size () - 1uz; ++j) - header[j] = isprint (p [j]) ? p [j] : '.'; - header [header.size () - 1] = '\0'; - - log_info_nocheck (LOG_ASSEMBLY, "file-offset: % 8x start: %08p end: %08p len: % 12i zip-entry: %s name: %s [%s]", - (int) file.data_offset, file.data, file.data + file.data_size, (int) file.data_size, file.name, file.name, header.data ()); - } - } -} - -force_inline void -EmbeddedAssemblies::map_assembly (XamarinAndroidBundledAssembly& file) noexcept -{ - map_runtime_file (file); -} - -force_inline void -EmbeddedAssemblies::map_debug_data (XamarinAndroidBundledAssembly& file) noexcept -{ - map_runtime_file (file); -} - -template -force_inline MonoAssembly* -EmbeddedAssemblies::load_bundled_assembly ( - XamarinAndroidBundledAssembly& assembly, - dynamic_local_string const& name, - dynamic_local_string const& abi_name, - TLoaderData loader_data, - bool ref_only) noexcept -{ - if (assembly.name == nullptr || assembly.name[0] == '\0') { - return nullptr; - } - - if (strcmp (assembly.name, name.get ()) != 0) { - if (strcmp (assembly.name, abi_name.get ()) != 0) { - return nullptr; - } else { - log_debug (LOG_ASSEMBLY, "open_from_bundles: found architecture-specific: '%s'", abi_name.get ()); - } - } - - if (assembly.data == nullptr) { - map_assembly (assembly); - } - - uint8_t *assembly_data; - uint32_t assembly_data_size; - - get_assembly_data (assembly, assembly_data, assembly_data_size); - MonoImage *image = MonoImageLoader::load (name, loader_data, assembly_data, assembly_data_size); - if (image == nullptr) { - return nullptr; - } - - if (have_and_want_debug_symbols) { - uint32_t base_name_length = assembly.name_length - 3; // we need the trailing dot - for (XamarinAndroidBundledAssembly& debug_file : *bundled_debug_data) { - if (debug_file.name_length != assembly.name_length) { - continue; - } - - if (strncmp (debug_file.name, assembly.name, base_name_length) != 0) { - continue; - } - - if (debug_file.data == nullptr) { - map_debug_data (debug_file); - } - - if (debug_file.data != nullptr) { - if (debug_file.data_size > std::numeric_limits::max ()) { - log_warn (LOG_ASSEMBLY, "Debug info file '%s' is too big for Mono to consume", debug_file.name); - } else { - mono_debug_open_image_from_memory (image, reinterpret_cast(debug_file.data), static_cast(debug_file.data_size)); - } - } - break; - } - } - - MonoImageOpenStatus status; - MonoAssembly *a = mono_assembly_load_from_full (image, name.get (), &status, ref_only); - if (a == nullptr || status != MonoImageOpenStatus::MONO_IMAGE_OK) { - log_warn (LOG_ASSEMBLY, "Failed to load managed assembly '%s'. %s", name.get (), mono_image_strerror (status)); - return nullptr; - } - - return a; -} - -template -force_inline MonoAssembly* -EmbeddedAssemblies::individual_assemblies_open_from_bundles (dynamic_local_string& name, TLoaderData loader_data, bool ref_only) noexcept -{ - if (!Util::ends_with (name, SharedConstants::DLL_EXTENSION)) { - name.append (SharedConstants::DLL_EXTENSION); - } - - log_debug (LOG_ASSEMBLY, "individual_assemblies_open_from_bundles: looking for bundled name: '%s'", name.get ()); - - dynamic_local_string abi_name; - abi_name - .assign (SharedConstants::android_lib_abi) - .append (zip_path_separator) - .append (name); - - MonoAssembly *a = nullptr; - - for (size_t i = 0uz; i < application_config.number_of_assemblies_in_apk; i++) { - a = load_bundled_assembly (bundled_assemblies [i], name, abi_name, loader_data, ref_only); - if (a != nullptr) { - return a; - } - } - - if (extra_bundled_assemblies != nullptr) { - for (XamarinAndroidBundledAssembly& assembly : *extra_bundled_assemblies) { - a = load_bundled_assembly (assembly, name, abi_name, loader_data, ref_only); - if (a != nullptr) { - return a; - } - } - } - - return nullptr; -} - force_inline const AssemblyStoreIndexEntry* EmbeddedAssemblies::find_assembly_store_entry (hash_t hash, const AssemblyStoreIndexEntry *entries, size_t entry_count) noexcept { @@ -472,13 +281,7 @@ EmbeddedAssemblies::open_from_bundles (MonoAssemblyName* aname, TLoaderData load } name.append_c (asmname); - MonoAssembly *a; - if (application_config.have_assembly_store) { - a = assembly_store_open_from_bundles (name, loader_data, ref_only); - } else { - a = individual_assemblies_open_from_bundles (name, loader_data, ref_only); - } - + MonoAssembly *a = assembly_store_open_from_bundles (name, loader_data, ref_only); if (a == nullptr) { log_warn (LOG_ASSEMBLY, "open_from_bundles: failed to load bundled assembly %s", name.get ()); #if defined(DEBUG) @@ -1160,69 +963,6 @@ EmbeddedAssemblies::register_from_apk (const char *apk_file, monodroid_should_re return number_of_found_assemblies; } -template -force_inline bool -EmbeddedAssemblies::maybe_register_assembly_from_filesystem ( - [[maybe_unused]] monodroid_should_register should_register, - size_t &assembly_count, - const dirent* dir_entry, - ZipEntryLoadState& state) noexcept -{ - dynamic_local_string entry_name; - auto copy_dentry_and_update_state = [] (dynamic_local_string &name, ZipEntryLoadState& state, const dirent* dir_entry) - { - name.assign_c (dir_entry->d_name); - - // We don't need to duplicate the name here, it will be done farther on - state.file_name = dir_entry->d_name; - }; - - // We check whether dir_entry->d_name is an array with a fixed size and whether it's - // big enough so that we can index the array below without having to worry about buffer - // overflows. These are compile-time checks and the status of the field won't change at - // runtime unless Android breaks compatibility (unlikely). - // - // Currently (Jan 2024), dir_try->d_name is declared as `char[256]` by Bionic - static_assert (std::is_bounded_array_vd_name)>); - static_assert (sizeof(dir_entry->d_name) > SharedConstants::MANGLED_ASSEMBLY_REGULAR_ASSEMBLY_MARKER.size()); - static_assert (sizeof(dir_entry->d_name) > SharedConstants::MANGLED_ASSEMBLY_SATELLITE_ASSEMBLY_MARKER.size()); - - if constexpr (MangledNamesMode) { - // We're only interested in "mangled" file names, namely those starting with either the `lib_` or `lib-` prefixes - if (dir_entry->d_name[SharedConstants::REGULAR_ASSEMBLY_MARKER_INDEX] == SharedConstants::REGULAR_ASSEMBLY_MARKER_CHAR) { - assembly_count++; - copy_dentry_and_update_state (entry_name, state, dir_entry); - unmangle_name (entry_name); - } else if (dir_entry->d_name[SharedConstants::SATELLITE_ASSEMBLY_MARKER_INDEX] == SharedConstants::SATELLITE_ASSEMBLY_MARKER_CHAR) { - assembly_count++; - copy_dentry_and_update_state (entry_name, state, dir_entry); - unmangle_name (entry_name); - } else { - return false; - } - } else { - if (Util::ends_with (dir_entry->d_name, SharedConstants::DLL_EXTENSION) || - Util::ends_with (dir_entry->d_name, SharedConstants::PDB_EXTENSION)) { - assembly_count++; - copy_dentry_and_update_state (entry_name, state, dir_entry); - } else { - return false; - } - - } - state.data_offset = 0; - - auto file_size = Util::get_file_size_at (state.file_fd, state.file_name); - if (!file_size) { - return false; // don't terminate, keep going - } - - state.file_size = static_cast(file_size.value ()); - store_individual_assembly_data (entry_name, state, should_register); - - return false; -} - force_inline bool EmbeddedAssemblies::maybe_register_blob_from_filesystem ( [[maybe_unused]] monodroid_should_register should_register, @@ -1283,13 +1023,7 @@ EmbeddedAssemblies::register_from_filesystem (const char *lib_dir_path,bool look return 0; } - auto register_fn = - application_config.have_assembly_store ? std::mem_fn (&EmbeddedAssemblies::maybe_register_blob_from_filesystem) : - (look_for_mangled_names ? - std::mem_fn (&EmbeddedAssemblies::maybe_register_assembly_from_filesystem) : - std::mem_fn (&EmbeddedAssemblies::maybe_register_assembly_from_filesystem - ) - ); + auto register_fn = std::mem_fn (&EmbeddedAssemblies::maybe_register_blob_from_filesystem); size_t assembly_count = 0uz; do { diff --git a/src/native/monodroid/embedded-assemblies.hh b/src/native/monodroid/embedded-assemblies.hh index 1bf6b358705..99ca0f03b6d 100644 --- a/src/native/monodroid/embedded-assemblies.hh +++ b/src/native/monodroid/embedded-assemblies.hh @@ -73,8 +73,6 @@ namespace xamarin::android::internal { uint32_t data_offset; uint32_t file_size; bool bundled_assemblies_slow_path; - uint32_t max_assembly_name_size; - uint32_t max_assembly_file_name_size; }; private: @@ -185,10 +183,6 @@ namespace xamarin::android::internal { void ensure_valid_assembly_stores () const noexcept { - if (!application_config.have_assembly_store) { - return; - } - abort_unless (assembly_store_hashes != nullptr, "Invalid or incomplete assembly store data"); } @@ -199,34 +193,16 @@ namespace xamarin::android::internal { size_t register_from_filesystem (monodroid_should_register should_register) noexcept; size_t register_from_filesystem (const char *dir, bool look_for_mangled_names, monodroid_should_register should_register) noexcept; - template - bool maybe_register_assembly_from_filesystem (monodroid_should_register should_register, size_t& assembly_count, const dirent* dir_entry, ZipEntryLoadState& state) noexcept; bool maybe_register_blob_from_filesystem (monodroid_should_register should_register, size_t& assembly_count, const dirent* dir_entry, ZipEntryLoadState& state) noexcept; void gather_bundled_assemblies_from_apk (const char* apk, monodroid_should_register should_register); - template - MonoAssembly* individual_assemblies_open_from_bundles (dynamic_local_string& name, TLoaderData loader_data, bool ref_only) noexcept; - template MonoAssembly* assembly_store_open_from_bundles (dynamic_local_string& name, TLoaderData loader_data, bool ref_only) noexcept; template MonoAssembly* open_from_bundles (MonoAssemblyName* aname, TLoaderData loader_data, MonoError *error, bool ref_only) noexcept; - template - void map_runtime_file (XamarinAndroidBundledAssembly& file) noexcept; - void map_assembly (XamarinAndroidBundledAssembly& file) noexcept; - void map_debug_data (XamarinAndroidBundledAssembly& file) noexcept; - - template - MonoAssembly* load_bundled_assembly ( - XamarinAndroidBundledAssembly& assembly, - dynamic_local_string const& name, - dynamic_local_string const& abi_name, - TLoaderData loader_data, - bool ref_only) noexcept; - #if defined (DEBUG) template bool typemap_read_header (int dir_fd, const char *file_type, const char *dir_path, const char *file_path, uint32_t expected_magic, H &header, size_t &file_size, int &fd); @@ -244,11 +220,9 @@ namespace xamarin::android::internal { void set_assembly_data_and_size (uint8_t* source_assembly_data, uint32_t source_assembly_data_size, uint8_t*& dest_assembly_data, uint32_t& dest_assembly_data_size) noexcept; void get_assembly_data (uint8_t *data, uint32_t data_size, const char *name, uint8_t*& assembly_data, uint32_t& assembly_data_size) noexcept; - void get_assembly_data (XamarinAndroidBundledAssembly const& e, uint8_t*& assembly_data, uint32_t& assembly_data_size) noexcept; void get_assembly_data (AssemblyStoreSingleAssemblyRuntimeData const& e, uint8_t*& assembly_data, uint32_t& assembly_data_size) noexcept; void zip_load_entries (int fd, const char *apk_name, monodroid_should_register should_register); - void zip_load_individual_assembly_entries (std::vector const& buf, uint32_t num_entries, monodroid_should_register should_register, ZipEntryLoadState &state) noexcept; void zip_load_assembly_store_entries (std::vector const& buf, uint32_t num_entries, ZipEntryLoadState &state) noexcept; bool zip_load_entry_common (size_t entry_index, std::vector const& buf, dynamic_local_string &entry_name, ZipEntryLoadState &state) noexcept; bool zip_read_cd_info (int fd, uint32_t& cd_offset, uint32_t& cd_size, uint16_t& cd_entries); @@ -321,11 +295,7 @@ namespace xamarin::android::internal { return { assemblies_prefix_override, static_cast(strlen (assemblies_prefix_override)) }; } - if (application_config.have_assembly_store) { - return { apk_lib_prefix.data (), apk_lib_prefix.size () - 1 }; - } - - return {assemblies_prefix.data (), assemblies_prefix.size () - 1}; + return { apk_lib_prefix.data (), apk_lib_prefix.size () - 1 }; } bool all_required_zip_entries_found () const noexcept @@ -349,13 +319,8 @@ namespace xamarin::android::internal { static int compare_mvid (const uint8_t *mvid, const TypeMapModule *module) noexcept; static const TypeMapModuleEntry* binary_search (uint32_t key, const TypeMapModuleEntry *arr, uint32_t n) noexcept; #endif - template - void set_entry_data (XamarinAndroidBundledAssembly &entry, ZipEntryLoadState const& state, dynamic_local_string const& entry_name) noexcept; - void set_assembly_entry_data (XamarinAndroidBundledAssembly &entry, ZipEntryLoadState const& state, dynamic_local_string const& entry_name) noexcept; - void set_debug_entry_data (XamarinAndroidBundledAssembly &entry, ZipEntryLoadState const& state, dynamic_local_string const& entry_name) noexcept; void map_assembly_store (dynamic_local_string const& entry_name, ZipEntryLoadState &state) noexcept; const AssemblyStoreIndexEntry* find_assembly_store_entry (hash_t hash, const AssemblyStoreIndexEntry *entries, size_t entry_count) noexcept; - void store_individual_assembly_data (dynamic_local_string const& entry_name, ZipEntryLoadState const& state, monodroid_should_register should_register) noexcept; constexpr size_t get_mangled_name_max_size_overhead () { @@ -367,10 +332,6 @@ namespace xamarin::android::internal { void configure_state_for_individual_assembly_load (ZipEntryLoadState& state) noexcept { state.bundled_assemblies_slow_path = bundled_assembly_index >= application_config.number_of_assemblies_in_apk; - state.max_assembly_name_size = application_config.bundled_assembly_name_width - 1; - - // Enough room for the mangle character at the start, plus the extra extension - state.max_assembly_file_name_size = static_cast(state.max_assembly_name_size + get_mangled_name_max_size_overhead ()); } template @@ -418,9 +379,6 @@ namespace xamarin::android::internal { static inline constexpr bool UnmangleSatelliteAssembly = true; static inline constexpr bool UnmangleRegularAssembly = false; - std::vector *bundled_debug_data = nullptr; - std::vector *extra_bundled_assemblies = nullptr; - bool register_debug_symbols; bool have_and_want_debug_symbols; size_t bundled_assembly_index = 0uz; diff --git a/src/native/monodroid/monodroid-glue.cc b/src/native/monodroid/monodroid-glue.cc index cd8d899a35d..eeb5daf7a9b 100644 --- a/src/native/monodroid/monodroid-glue.cc +++ b/src/native/monodroid/monodroid-glue.cc @@ -235,7 +235,6 @@ MonodroidRuntime::gather_bundled_assemblies (jstring_array_wrapper &runtimeApks, int64_t apk_count = static_cast(runtimeApks.get_length ()); size_t prev_num_assemblies = 0uz; bool got_split_config_abi_apk = false; - bool got_base_apk = false; for (int64_t i = 0; i < apk_count; i++) { jstring_wrapper &apk_file = runtimeApks [static_cast(i)]; @@ -247,8 +246,6 @@ MonodroidRuntime::gather_bundled_assemblies (jstring_array_wrapper &runtimeApks, // configuration blob are in `lib/{ARCH}`, which in turn lives in the split config APK if (!got_split_config_abi_apk && Util::ends_with (apk_file.get_cstr (), SharedConstants::split_config_abi_apk_name)) { got_split_config_abi_apk = scan_apk = true; - } else if (!application_config.have_assembly_store && !got_base_apk && Util::ends_with (apk_file.get_cstr (), base_apk_name)) { - got_base_apk = scan_apk = true; } if (!scan_apk) { diff --git a/src/native/xamarin-app-stub/application_dso_stub.cc b/src/native/xamarin-app-stub/application_dso_stub.cc index f840005c204..81dd738b96f 100644 --- a/src/native/xamarin-app-stub/application_dso_stub.cc +++ b/src/native/xamarin-app-stub/application_dso_stub.cc @@ -49,7 +49,6 @@ const ApplicationConfig application_config = { .broken_exception_transitions = false, .jni_add_native_method_registration_attribute_present = false, .have_runtime_config_blob = false, - .have_assembly_store = false, .marshal_methods_enabled = false, .ignore_split_configs = false, .bound_exception_type = 0, // System @@ -57,7 +56,6 @@ const ApplicationConfig application_config = { .environment_variable_count = 0, .system_property_count = 0, .number_of_assemblies_in_apk = 2, - .bundled_assembly_name_width = 0, .number_of_dso_cache_entries = 2, .number_of_shared_libraries = 2, .android_runtime_jnienv_class_token = 1, @@ -73,33 +71,6 @@ const char* const mono_aot_mode_name = "normal"; const char* const app_environment_variables[] = {}; const char* const app_system_properties[] = {}; -static constexpr size_t AssemblyNameWidth = 128uz; - -static char first_assembly_name[AssemblyNameWidth]; -static char second_assembly_name[AssemblyNameWidth]; - -XamarinAndroidBundledAssembly bundled_assemblies[] = { - { - .file_fd = -1, - .file_name = nullptr, - .data_offset = 0, - .data_size = 0, - .data = nullptr, - .name_length = 0, - .name = first_assembly_name, - }, - - { - .file_fd = -1, - .file_name = nullptr, - .data_offset = 0, - .data_size = 0, - .data = nullptr, - .name_length = 0, - .name = second_assembly_name, - }, -}; - AssemblyStoreSingleAssemblyRuntimeData assembly_store_bundled_assemblies[] = { { .image_data = nullptr, diff --git a/src/native/xamarin-app-stub/xamarin-app.hh b/src/native/xamarin-app-stub/xamarin-app.hh index 426b4913e55..f54aa062ef8 100644 --- a/src/native/xamarin-app-stub/xamarin-app.hh +++ b/src/native/xamarin-app-stub/xamarin-app.hh @@ -122,17 +122,6 @@ struct CompressedAssemblies CompressedAssemblyDescriptor *descriptors; }; -struct XamarinAndroidBundledAssembly -{ - int32_t file_fd; - char *file_name; - uint32_t data_offset; - uint32_t data_size; - uint8_t *data; - uint32_t name_length; - char *name; -}; - // // Assembly store format // @@ -239,7 +228,6 @@ struct ApplicationConfig bool broken_exception_transitions; bool jni_add_native_method_registration_attribute_present; bool have_runtime_config_blob; - bool have_assembly_store; bool marshal_methods_enabled; bool ignore_split_configs; uint8_t bound_exception_type; @@ -247,7 +235,6 @@ struct ApplicationConfig uint32_t environment_variable_count; uint32_t system_property_count; uint32_t number_of_assemblies_in_apk; - uint32_t bundled_assembly_name_width; uint32_t number_of_dso_cache_entries; uint32_t number_of_aot_cache_entries; uint32_t number_of_shared_libraries; @@ -334,7 +321,6 @@ MONO_API MONO_API_EXPORT const char* const app_system_properties[]; MONO_API MONO_API_EXPORT const char* const mono_aot_mode_name; -MONO_API MONO_API_EXPORT XamarinAndroidBundledAssembly bundled_assemblies[]; MONO_API MONO_API_EXPORT AssemblyStoreSingleAssemblyRuntimeData assembly_store_bundled_assemblies[]; MONO_API MONO_API_EXPORT AssemblyStoreRuntimeData assembly_store; From 912b44c76f5575f703cbf89d89c7e9e157a02237 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Mon, 28 Oct 2024 14:14:25 +0100 Subject: [PATCH 3/8] Assembly stores are the only way to embed assemblies in the apk now --- .../Xamarin.Android.Build.Tests/AotTests.cs | 18 ++-- .../BuildTest.TestCaseSource.cs | 16 ---- .../Xamarin.Android.Build.Tests/BuildTest.cs | 8 +- .../Xamarin.Android.Build.Tests/BuildTest2.cs | 5 +- .../PackagingTest.cs | 5 +- .../Tasks/LinkerTests.cs | 10 +-- .../Utilities/ArchiveAssemblyHelper.cs | 46 +--------- .../Tests/BundleToolTests.cs | 85 +++++-------------- ...Forms.Performance.Integration.Droid.csproj | 1 - 9 files changed, 42 insertions(+), 152 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs index 5a135444ca7..ca698cf584a 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/AotTests.cs @@ -137,34 +137,30 @@ public void BuildAotApplicationWithSpecialCharactersInProject (string testName, new object[] { /* supportedAbis */ "arm64-v8a", /* enableLLVM */ false, - /* usesAssemblyBlobs */ false, }, new object[] { /* supportedAbis */ "armeabi-v7a;x86", /* enableLLVM */ true, - /* usesAssemblyBlobs */ true, }, new object[] { /* supportedAbis */ "armeabi-v7a;arm64-v8a;x86;x86_64", /* enableLLVM */ false, - /* usesAssemblyBlobs */ true, }, new object[] { /* supportedAbis */ "armeabi-v7a;arm64-v8a;x86;x86_64", /* enableLLVM */ true, - /* usesAssemblyBlobs */ false, }, }; [Test] [TestCaseSource (nameof (AotChecks))] - public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAbis, bool enableLLVM, bool usesAssemblyBlobs) + public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAbis, bool enableLLVM) { if (IsWindows) Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); var abisSanitized = supportedAbis.Replace (";", "").Replace ("-", "").Replace ("_", ""); - var path = Path.Combine ("temp", string.Format ("BuildAotNdk AndÜmläüts_{0}_{1}_{2}", abisSanitized, enableLLVM, usesAssemblyBlobs)); + var path = Path.Combine ("temp", string.Format ("BuildAotNdk AndÜmläüts_{0}_{1}", abisSanitized, enableLLVM)); var proj = new XamarinAndroidApplicationProject () { IsRelease = true, AotAssemblies = true, @@ -174,7 +170,6 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb proj.SetProperty ("AndroidNdkDirectory", AndroidNdkPath); proj.SetRuntimeIdentifiers (supportedAbis.Split (';')); proj.SetProperty ("EnableLLVM", enableLLVM.ToString ()); - proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ()); bool checkMinLlvmPath = enableLLVM && (supportedAbis == "armeabi-v7a" || supportedAbis == "x86"); if (checkMinLlvmPath) { // Set //uses-sdk/@android:minSdkVersion so that LLVM uses the right libc.so @@ -195,7 +190,7 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - var helper = new ArchiveAssemblyHelper (apk, usesAssemblyBlobs); + var helper = new ArchiveAssemblyHelper (apk); Assert.IsTrue (helper.Exists ($"assemblies/{abi}/UnnamedProject.dll"), $"{abi}/UnnamedProject.dll should be in {proj.PackageName}-Signed.apk"); using (var zipFile = ZipHelper.OpenZip (apk)) { Assert.IsNotNull (ZipHelper.ReadFileFromZip (zipFile, @@ -215,13 +210,13 @@ public void BuildAotApplicationWithNdkAndBundleAndÜmläüts (string supportedAb [Test] [TestCaseSource (nameof (AotChecks))] - public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableLLVM, bool usesAssemblyBlobs) + public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableLLVM) { if (IsWindows) Assert.Ignore ("https://github.com/dotnet/runtime/issues/88625"); var abisSanitized = supportedAbis.Replace (";", "").Replace ("-", "").Replace ("_", ""); - var path = Path.Combine ("temp", string.Format ("BuildAot AndÜmläüts_{0}_{1}_{2}", abisSanitized, enableLLVM, usesAssemblyBlobs)); + var path = Path.Combine ("temp", string.Format ("BuildAot AndÜmläüts_{0}_{1}", abisSanitized, enableLLVM)); var proj = new XamarinAndroidApplicationProject () { IsRelease = true, AotAssemblies = true, @@ -229,7 +224,6 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL }; proj.SetRuntimeIdentifiers (supportedAbis.Split (';')); proj.SetProperty ("EnableLLVM", enableLLVM.ToString ()); - proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ()); using (var b = CreateApkBuilder (path)) { b.ThrowOnBuildFailure = false; Assert.IsTrue (b.Build (proj), "Build should have succeeded."); @@ -240,7 +234,7 @@ public void BuildAotApplicationAndÜmläüts (string supportedAbis, bool enableL var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - var helper = new ArchiveAssemblyHelper (apk, usesAssemblyBlobs); + var helper = new ArchiveAssemblyHelper (apk); Assert.IsTrue (helper.Exists ($"assemblies/{abi}/UnnamedProject.dll"), $"{abi}/UnnamedProject.dll should be in {proj.PackageName}-Signed.apk"); using (var zipFile = ZipHelper.OpenZip (apk)) { Assert.IsNotNull (ZipHelper.ReadFileFromZip (zipFile, diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs index f30f2f2388d..40b233b3a59 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.TestCaseSource.cs @@ -16,97 +16,81 @@ public partial class BuildTest : BaseTest /* runtimeIdentifiers */ "android-arm", /* isRelease */ false, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-arm", /* isRelease */ false, /* aot */ false, - /* usesAssemblyStore */ true, }, new object [] { /* runtimeIdentifiers */ "android-arm64", /* isRelease */ false, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-x86", /* isRelease */ false, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-x64", /* isRelease */ false, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-arm", /* isRelease */ true, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-arm", /* isRelease */ true, /* aot */ false, - /* usesAssemblyStore */ true, }, new object [] { /* runtimeIdentifiers */ "android-arm", /* isRelease */ true, /* aot */ true, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-arm", /* isRelease */ true, /* aot */ true, - /* usesAssemblyStore */ true, }, new object [] { /* runtimeIdentifiers */ "android-arm64", /* isRelease */ true, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", /* isRelease */ false, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", /* isRelease */ false, /* aot */ false, - /* usesAssemblyStore */ true, }, new object [] { /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86", /* isRelease */ true, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", /* isRelease */ true, /* aot */ false, - /* usesAssemblyStore */ false, }, new object [] { /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", /* isRelease */ true, /* aot */ false, - /* usesAssemblyStore */ true, }, new object [] { /* runtimeIdentifiers */ "android-arm;android-arm64;android-x86;android-x64", /* isRelease */ true, /* aot */ true, - /* usesAssemblyStore */ false, }, }; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs index 8cc76792220..d324c02f5e3 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs @@ -26,7 +26,7 @@ public partial class BuildTest : BaseTest [Category ("SmokeTests")] [TestCaseSource (nameof (DotNetBuildSource))] [NonParallelizable] // On MacOS, parallel /restore causes issues - public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bool usesAssemblyStore) + public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot) { var proj = new XamarinAndroidApplicationProject { IsRelease = isRelease, @@ -66,7 +66,6 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo }; proj.MainActivity = proj.DefaultMainActivity.Replace (": Activity", ": AndroidX.AppCompat.App.AppCompatActivity") .Replace ("//${AFTER_ONCREATE}", @"button.Text = Resource.CancelButton;"); - proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyStore.ToString ()); proj.SetProperty ("RunAOTCompilation", aot.ToString ()); proj.OtherBuildItems.Add (new AndroidItem.InputJar ("javaclasses.jar") { BinaryContent = () => ResourceData.JavaSourceJarTestJar, @@ -162,7 +161,7 @@ public void DotNetBuild (string runtimeIdentifiers, bool isRelease, bool aot, bo bool expectEmbeddedAssembies = !(TestEnvironment.CommercialBuildAvailable && !isRelease); var apkPath = Path.Combine (outputPath, $"{proj.PackageName}-Signed.apk"); FileAssert.Exists (apkPath); - var helper = new ArchiveAssemblyHelper (apkPath, usesAssemblyStore, rids); + var helper = new ArchiveAssemblyHelper (apkPath, rids); helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.dll", shouldContainEntry: expectEmbeddedAssembies); helper.AssertContainsEntry ($"assemblies/{proj.ProjectName}.pdb", shouldContainEntry: !TestEnvironment.CommercialBuildAvailable && !isRelease); helper.AssertContainsEntry ($"assemblies/Mono.Android.dll", shouldContainEntry: expectEmbeddedAssembies); @@ -267,7 +266,6 @@ public void CheckAssemblyCounts (bool isRelease, bool aot) var abis = new [] { "armeabi-v7a", "x86" }; proj.SetRuntimeIdentifiers (abis); - proj.SetProperty (proj.ActiveConfigurationProperties, "AndroidUseAssemblyStore", "True"); using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); @@ -284,7 +282,7 @@ public void CheckAssemblyCounts (bool isRelease, bool aot) } string apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - var helper = new ArchiveAssemblyHelper (apk, useAssemblyStores: true); + var helper = new ArchiveAssemblyHelper (apk); foreach (string abi in abis) { AndroidTargetArch arch = MonoAndroidHelper.AbiToTargetArch (abi); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs index 058269ceaa4..b11f4e11da7 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest2.cs @@ -154,7 +154,6 @@ public void BuildReleaseArm64 ([Values (false, true)] bool forms) proj.AotAssemblies = false; // Release defaults to Profiled AOT for .NET 6 proj.SetAndroidSupportedAbis ("arm64-v8a"); proj.SetProperty ("LinkerDumpDependencies", "True"); - proj.SetProperty ("AndroidUseAssemblyStore", "False"); var flavor = (forms ? "XForms" : "Simple") + "DotNet"; var apkDescFilename = $"BuildReleaseArm64{flavor}.apkdesc"; @@ -319,7 +318,7 @@ public void XA1037PropertyDeprecatedWarning (string property, string value, bool XamarinAndroidProject proj = isBindingProject ? new XamarinAndroidBindingProject () : new XamarinAndroidApplicationProject (); proj.IsRelease = isRelease; proj.SetProperty (property, value); - + using (ProjectBuilder b = isBindingProject ? CreateDllBuilder (Path.Combine ("temp", TestName)) : CreateApkBuilder (Path.Combine ("temp", TestName))) { Assert.IsTrue (b.Build (proj), "Build should have succeeded."); Assert.IsTrue (StringAssertEx.ContainsText (b.LastBuildOutput, $"The '{property}' MSBuild property is deprecated and will be removed"), @@ -1369,7 +1368,7 @@ public Class2 () }; string apkPath = Path.Combine (outputPath, proj.PackageName + "-Signed.apk"); - var helper = new ArchiveAssemblyHelper (apkPath, useAssemblyStores: false, proj.GetRuntimeIdentifiers ().ToArray ()); + var helper = new ArchiveAssemblyHelper (apkPath, proj.GetRuntimeIdentifiers ().ToArray ()); foreach (string abi in proj.GetRuntimeIdentifiersAsAbis ()) { foreach ((string fileName, bool existsInBin) in fileNames) { EnsureFilesAreTheSame (intermediate, existsInBin ? outputPath : null, fileName, abi, helper, uncompressIfNecessary: fileName.EndsWith (".dll", StringComparison.Ordinal)); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs index f9394a98ca1..100695f6669 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/PackagingTest.cs @@ -83,7 +83,7 @@ public void CheckDebugModeWithTrimming () [Test] [NonParallelizable] // Commonly fails NuGet restore - public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblyStores) + public void CheckIncludedAssemblies () { var proj = new XamarinAndroidApplicationProject { IsRelease = true @@ -93,7 +93,6 @@ public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblySto AndroidTargetArch.Arm, }; - proj.SetProperty ("AndroidUseAssemblyStore", usesAssemblyStores.ToString ()); proj.SetRuntimeIdentifiers (supportedArches); proj.PackageReferences.Add (new Package { Id = "Humanizer.Core", @@ -136,7 +135,7 @@ public void CheckIncludedAssemblies ([Values (false, true)] bool usesAssemblySto Assert.IsTrue (b.Build (proj), "build should have succeeded."); var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); - var helper = new ArchiveAssemblyHelper (apk, usesAssemblyStores); + var helper = new ArchiveAssemblyHelper (apk); List existingFiles; List missingFiles; List additionalFiles; diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs index 17af700809a..82ba16d8661 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/LinkerTests.cs @@ -261,21 +261,20 @@ public void WarnAboutAppDomains ([Values (true, false)] bool isRelease) } [Test] - public void RemoveDesigner ([Values (true, false)] bool useAssemblyStore) + public void RemoveDesigner () { var proj = new XamarinAndroidApplicationProject { IsRelease = true, }; proj.SetProperty ("AndroidEnableAssemblyCompression", "False"); proj.SetProperty ("AndroidLinkResources", "True"); - proj.SetProperty ("AndroidUseAssemblyStore", useAssemblyStore.ToString ()); string assemblyName = proj.ProjectName; using var b = CreateApkBuilder (); Assert.IsTrue (b.Build (proj), "build should have succeeded."); var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); FileAssert.Exists (apk); - var helper = new ArchiveAssemblyHelper (apk, useAssemblyStore); + var helper = new ArchiveAssemblyHelper (apk); foreach (string abi in proj.GetRuntimeIdentifiersAsAbis ()) { Assert.IsTrue (helper.Exists ($"assemblies/{abi}/{assemblyName}.dll"), $"{assemblyName}.dll should exist in apk!"); @@ -297,7 +296,7 @@ public void RemoveDesigner ([Values (true, false)] bool useAssemblyStore) } [Test] - public void LinkDescription ([Values (true, false)] bool useAssemblyStore) + public void LinkDescription () { string assembly_name = "System.Console"; string linker_xml = ""; @@ -312,7 +311,6 @@ public void LinkDescription ([Values (true, false)] bool useAssemblyStore) }; // So we can use Mono.Cecil to open assemblies directly proj.SetProperty ("AndroidEnableAssemblyCompression", "False"); - proj.SetProperty ("AndroidUseAssemblyStore", useAssemblyStore.ToString ()); using (var b = CreateApkBuilder ()) { Assert.IsTrue (b.Build (proj), "first build should have succeeded."); @@ -331,7 +329,7 @@ public void LinkDescription ([Values (true, false)] bool useAssemblyStore) var apk = Path.Combine (Root, b.ProjectDirectory, proj.OutputPath, $"{proj.PackageName}-Signed.apk"); FileAssert.Exists (apk); - var helper = new ArchiveAssemblyHelper (apk, useAssemblyStore); + var helper = new ArchiveAssemblyHelper (apk); foreach (string abi in proj.GetRuntimeIdentifiersAsAbis ()) { Assert.IsTrue (helper.Exists ($"assemblies/{abi}/{assembly_name}.dll"), $"{assembly_name}.dll should exist in apk!"); } diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ArchiveAssemblyHelper.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ArchiveAssemblyHelper.cs index 59b2b4e6fca..245979d3965 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ArchiveAssemblyHelper.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/ArchiveAssemblyHelper.cs @@ -27,20 +27,18 @@ public class ArchiveAssemblyHelper readonly string archivePath; readonly string assembliesRootDir; - bool useAssemblyStores; bool haveMultipleRids; List archiveContents; public string ArchivePath => archivePath; - public ArchiveAssemblyHelper (string archivePath, bool useAssemblyStores = true, string[] rids = null) + public ArchiveAssemblyHelper (string archivePath, string[] rids = null) { if (String.IsNullOrEmpty (archivePath)) { throw new ArgumentException ("must not be null or empty", nameof (archivePath)); } this.archivePath = archivePath; - this.useAssemblyStores = useAssemblyStores; haveMultipleRids = rids != null && rids.Length > 1; string extension = Path.GetExtension (archivePath) ?? String.Empty; @@ -57,13 +55,7 @@ public ArchiveAssemblyHelper (string archivePath, bool useAssemblyStores = true, public Stream? ReadEntry (string path, AndroidTargetArch arch = AndroidTargetArch.None, bool uncompressIfNecessary = false) { - Stream? ret; - if (useAssemblyStores) { - ret = ReadStoreEntry (path, arch, uncompressIfNecessary); - } else { - ret = ReadZipEntry (path, arch, uncompressIfNecessary); - } - + Stream? ret = ReadStoreEntry (path, arch, uncompressIfNecessary); if (ret == null) { return null; } @@ -117,29 +109,6 @@ public ArchiveAssemblyHelper (string archivePath, bool useAssemblyStores = true, return payload; } - Stream? ReadZipEntry (string path, AndroidTargetArch arch, bool uncompressIfNecessary) - { - List? potentialEntries = TransformArchiveAssemblyPath (path, arch); - if (potentialEntries == null || potentialEntries.Count == 0) { - return null; - } - - using var zip = ZipHelper.OpenZip (archivePath); - foreach (string assemblyPath in potentialEntries) { - if (!zip.ContainsEntry (assemblyPath)) { - continue; - } - - ZipEntry entry = zip.ReadEntry (assemblyPath); - var ret = new MemoryStream (); - entry.Extract (ret); - ret.Flush (); - return ret; - } - - return null; - } - Stream? ReadStoreEntry (string path, AndroidTargetArch arch, bool uncompressIfNecessary) { string name = Path.GetFileNameWithoutExtension (path); @@ -199,11 +168,6 @@ public List ListArchiveContents (string storeEntryPrefix = DefaultAssemb } archiveContents = entries; - if (!useAssemblyStores) { - Console.WriteLine ("Not using assembly stores"); - return entries; - } - Console.WriteLine ($"Creating AssemblyStoreExplorer for archive '{archivePath}'"); (IList? explorers, string? errorMessage) = AssemblyStoreExplorer.Open (archivePath); @@ -448,11 +412,7 @@ public void Contains (ICollection fileNames, out List existingFi throw new ArgumentException ("must not be empty", nameof (fileNames)); } - if (useAssemblyStores) { - StoreContains (fileNames, out existingFiles, out missingFiles, out additionalFiles, targetArches); - } else { - ArchiveContains (fileNames, out existingFiles, out missingFiles, out additionalFiles, targetArches); - } + StoreContains (fileNames, out existingFiles, out missingFiles, out additionalFiles, targetArches); } List GetSupportedArches (IEnumerable? runtimeIdentifiers) diff --git a/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs b/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs index 6c61f9fbe70..1dd5ba4b16d 100644 --- a/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs +++ b/tests/MSBuildDeviceIntegration/Tests/BundleToolTests.cs @@ -10,22 +10,15 @@ namespace Xamarin.Android.Build.Tests { [TestFixture] - [TestFixtureSource(nameof(FixtureArgs))] [Category ("XamarinBuildDownload")] public class BundleToolTests : DeviceTest { - static readonly object[] FixtureArgs = { - new object[] { false }, - new object[] { true }, - }; - static readonly string [] Abis = new [] { "armeabi-v7a", "arm64-v8a", "x86", "x86_64" }; XamarinAndroidLibraryProject lib; XamarinAndroidApplicationProject app; ProjectBuilder libBuilder, appBuilder; string intermediate; string bin; - bool usesAssemblyBlobs; // Disable split by language const string BuildConfig = @"{ @@ -46,11 +39,6 @@ public class BundleToolTests : DeviceTest } }"; - public BundleToolTests (bool usesAssemblyBlobs) - { - this.usesAssemblyBlobs = usesAssemblyBlobs; - } - [OneTimeSetUp] public void OneTimeSetUp () { @@ -68,8 +56,6 @@ public void OneTimeSetUp () } }; - lib.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ()); - var bytes = new byte [1024]; app = new XamarinFormsMapsApplicationProject { IsRelease = true, @@ -96,7 +82,6 @@ public void OneTimeSetUp () app.SetProperty (app.ReleaseProperties, "AndroidPackageFormat", "aab"); app.SetAndroidSupportedAbis (Abis); app.SetProperty ("AndroidBundleConfigurationFile", "buildConfig.json"); - app.SetProperty ("AndroidUseAssemblyStore", usesAssemblyBlobs.ToString ()); libBuilder = CreateDllBuilder (Path.Combine (path, lib.ProjectName), cleanupOnDispose: true); Assert.IsTrue (libBuilder.Build (lib), "Library build should have succeeded."); @@ -127,9 +112,9 @@ public void OneTimeTearDown () appBuilder?.Dispose (); } - string [] ListArchiveContents (string archive, bool usesAssembliesBlob) + string [] ListArchiveContents (string archive) { - var helper = new ArchiveAssemblyHelper (archive, usesAssembliesBlob); + var helper = new ArchiveAssemblyHelper (archive); List entries = helper.ListArchiveContents (); entries.Sort (); return entries.ToArray (); @@ -139,7 +124,7 @@ string [] ListArchiveContents (string archive, bool usesAssembliesBlob) public void BaseZip () { var baseZip = Path.Combine (intermediate, "android", "bin", "base.zip"); - var contents = ListArchiveContents (baseZip, usesAssemblyBlobs); + var contents = ListArchiveContents (baseZip); var expectedFiles = new List { "dex/classes.dex", "manifest/AndroidManifest.xml", @@ -162,28 +147,17 @@ public void BaseZip () foreach (var abi in Abis) { // All assemblies are in per-abi directories now - if (usesAssemblyBlobs) { - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Java.Interop.dll.so"); - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Mono.Android.dll.so"); - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Localization.dll.so"); - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib-es{MonoAndroidHelper.SATELLITE_CULTURE_END_MARKER_CHAR}Localization.resources.dll.so"); - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_UnnamedProject.dll.so"); - } else { - expectedFiles.Add ($"lib/{abi}/lib_Java.Interop.dll.so"); - expectedFiles.Add ($"lib/{abi}/lib_Mono.Android.dll.so"); - expectedFiles.Add ($"lib/{abi}/lib_Localization.dll.so"); - expectedFiles.Add ($"lib/{abi}/lib-es{MonoAndroidHelper.SATELLITE_CULTURE_END_MARKER_CHAR}Localization.resources.dll.so"); - expectedFiles.Add ($"lib/{abi}/lib_UnnamedProject.dll.so"); - } + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Java.Interop.dll.so"); + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Mono.Android.dll.so"); + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Localization.dll.so"); + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib-es{MonoAndroidHelper.SATELLITE_CULTURE_END_MARKER_CHAR}Localization.resources.dll.so"); + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_UnnamedProject.dll.so"); expectedFiles.Add ($"lib/{abi}/libmonodroid.so"); expectedFiles.Add ($"lib/{abi}/libmonosgen-2.0.so"); expectedFiles.Add ($"lib/{abi}/libxamarin-app.so"); - if (usesAssemblyBlobs) { - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_System.Private.CoreLib.dll.so"); - } else { - expectedFiles.Add ($"lib/{abi}/lib_System.Private.CoreLib.dll.so"); - } + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_System.Private.CoreLib.dll.so"); + expectedFiles.Add ($"lib/{abi}/libSystem.IO.Compression.Native.so"); expectedFiles.Add ($"lib/{abi}/libSystem.Native.so"); } @@ -197,7 +171,7 @@ public void AppBundle () { var aab = Path.Combine (intermediate, "android", "bin", $"{app.PackageName}.aab"); FileAssert.Exists (aab); - var contents = ListArchiveContents (aab, usesAssemblyBlobs); + var contents = ListArchiveContents (aab); var expectedFiles = new List { "base/dex/classes.dex", "base/manifest/AndroidManifest.xml", @@ -222,28 +196,17 @@ public void AppBundle () foreach (var abi in Abis) { // All assemblies are in per-abi directories now - if (usesAssemblyBlobs) { - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Java.Interop.dll.so"); - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Mono.Android.dll.so"); - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Localization.dll.so"); - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib-es{MonoAndroidHelper.SATELLITE_CULTURE_END_MARKER_CHAR}Localization.resources.dll.so"); - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_UnnamedProject.dll.so"); - } else { - expectedFiles.Add ($"base/lib/{abi}/lib_Java.Interop.dll.so"); - expectedFiles.Add ($"base/lib/{abi}/lib_Mono.Android.dll.so"); - expectedFiles.Add ($"base/lib/{abi}/lib_Localization.dll.so"); - expectedFiles.Add ($"base/lib/{abi}/lib-es{MonoAndroidHelper.SATELLITE_CULTURE_END_MARKER_CHAR}Localization.resources.dll.so"); - expectedFiles.Add ($"base/lib/{abi}/lib_UnnamedProject.dll.so"); - } + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Java.Interop.dll.so"); + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Mono.Android.dll.so"); + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_Localization.dll.so"); + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib-es{MonoAndroidHelper.SATELLITE_CULTURE_END_MARKER_CHAR}Localization.resources.dll.so"); + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_UnnamedProject.dll.so"); expectedFiles.Add ($"base/lib/{abi}/libmonodroid.so"); expectedFiles.Add ($"base/lib/{abi}/libmonosgen-2.0.so"); expectedFiles.Add ($"base/lib/{abi}/libxamarin-app.so"); - if (usesAssemblyBlobs) { - expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_System.Private.CoreLib.dll.so"); - } else { - expectedFiles.Add ($"base/lib/{abi}/lib_System.Private.CoreLib.dll.so"); - } + expectedFiles.Add ($"{blobEntryPrefix}{abi}/lib_System.Private.CoreLib.dll.so"); + expectedFiles.Add ($"base/lib/{abi}/libSystem.IO.Compression.Native.so"); expectedFiles.Add ($"base/lib/{abi}/libSystem.Native.so"); } @@ -257,7 +220,7 @@ public void AppBundleSigned () { var aab = Path.Combine (bin, $"{app.PackageName}-Signed.aab"); FileAssert.Exists (aab); - var contents = ListArchiveContents (aab, usesAssembliesBlob: false); + var contents = ListArchiveContents (aab); Assert.IsTrue (StringAssertEx.ContainsText (contents, "META-INF/MANIFEST.MF"), $"{aab} is not signed!"); } @@ -271,11 +234,11 @@ public void ApkSet () FileAssert.Exists (aab); // Expecting: splits/base-arm64_v8a.apk, splits/base-master.apk, splits/base-xxxhdpi.apk // This are split up based on: abi, base, and dpi - var contents = ListArchiveContents (aab, usesAssembliesBlob: false).Where (a => a.EndsWith (".apk", StringComparison.OrdinalIgnoreCase)).ToArray (); + var contents = ListArchiveContents (aab).Where (a => a.EndsWith (".apk", StringComparison.OrdinalIgnoreCase)).ToArray (); Assert.AreEqual (3, contents.Length, "Expecting three APKs!"); // Language split has been removed by the bundle configuration file, and therefore shouldn't be present - var languageSplitContent = ListArchiveContents (aab, usesAssemblyBlobs).Where (a => a.EndsWith ("-en.apk", StringComparison.OrdinalIgnoreCase)).ToArray (); + var languageSplitContent = ListArchiveContents (aab).Where (a => a.EndsWith ("-en.apk", StringComparison.OrdinalIgnoreCase)).ToArray (); Assert.AreEqual (0, languageSplitContent.Length, "Found language split apk in bundle, but disabled by bundle configuration file!"); using (var stream = new MemoryStream ()) @@ -289,13 +252,9 @@ public void ApkSet () ".bar", ".wav", ".data", + ".blob", }; - if (usesAssemblyBlobs) { - uncompressed.Add (".blob"); - } else { - uncompressed.Add (".dll"); - } using (var baseApk = ZipArchive.Open (stream)) { foreach (var file in baseApk) { foreach (var ext in uncompressed) { diff --git a/tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj b/tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj index 6d3fbc7f627..5be74cdf706 100644 --- a/tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj +++ b/tests/Xamarin.Forms-Performance-Integration/Droid/Xamarin.Forms.Performance.Integration.Droid.csproj @@ -19,7 +19,6 @@ armeabi-v7a;x86 arm64-v8a;x86 True - False true <_AndroidCheckedBuild Condition=" '$(UseASAN)' != '' ">asan <_AndroidCheckedBuild Condition=" '$(UseUBSAN)' != '' ">ubsan From 5d031eeb4078e90f458f4a67c69d1136eb439c67 Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Tue, 29 Oct 2024 17:24:51 +0100 Subject: [PATCH 4/8] Don't segfault when fastdev is used --- src/native/monodroid/embedded-assemblies.cc | 49 +++++++++------------ src/native/monodroid/embedded-assemblies.hh | 3 -- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/src/native/monodroid/embedded-assemblies.cc b/src/native/monodroid/embedded-assemblies.cc index d64921af348..2f0bb887fc4 100644 --- a/src/native/monodroid/embedded-assemblies.cc +++ b/src/native/monodroid/embedded-assemblies.cc @@ -190,12 +190,32 @@ EmbeddedAssemblies::find_assembly_store_entry (hash_t hash, const AssemblyStoreI return nullptr; } +// TODO: need to forbid loading assemblies into non-default ALC if they contain marshal method callbacks. +// The best way is probably to store the information in the assembly `MonoImage*` cache. We should +// abort() if the assembly contains marshal callbacks. template force_inline MonoAssembly* -EmbeddedAssemblies::assembly_store_open_from_bundles (dynamic_local_string& name, TLoaderData loader_data, bool ref_only) noexcept +EmbeddedAssemblies::open_from_bundles (MonoAssemblyName* aname, TLoaderData loader_data, [[maybe_unused]] MonoError *error, bool ref_only) noexcept { +#if defined (DEBUG) + if (assembly_store_hashes == nullptr) { + // With FastDev we might not have any assembly stores present + return nullptr; + } +#endif + + const char *culture = mono_assembly_name_get_culture (aname); + const char *asmname = mono_assembly_name_get_name (aname); + + dynamic_local_string name; + if (culture != nullptr && *culture != '\0') { + name.append_c (culture); + name.append (zip_path_separator); + } + name.append_c (asmname); + hash_t name_hash = xxhash::hash (name.get (), name.length ()); - log_debug (LOG_ASSEMBLY, "assembly_store_open_from_bundles: looking for bundled name: '%s' (hash 0x%zx)", name.get (), name_hash); + log_debug (LOG_ASSEMBLY, "open_from_bundles: looking for bundled assembly '%s' (hash 0x%zx)", name.get (), name_hash); const AssemblyStoreIndexEntry *hash_entry = find_assembly_store_entry (name_hash, assembly_store_hashes, assembly_store.index_entry_count); if (hash_entry == nullptr) { @@ -256,32 +276,7 @@ EmbeddedAssemblies::assembly_store_open_from_bundles (dynamic_local_string -force_inline MonoAssembly* -EmbeddedAssemblies::open_from_bundles (MonoAssemblyName* aname, TLoaderData loader_data, [[maybe_unused]] MonoError *error, bool ref_only) noexcept -{ - const char *culture = mono_assembly_name_get_culture (aname); - const char *asmname = mono_assembly_name_get_name (aname); - - dynamic_local_string name; - if (culture != nullptr && *culture != '\0') { - name.append_c (culture); - name.append (zip_path_separator); - } - name.append_c (asmname); - MonoAssembly *a = assembly_store_open_from_bundles (name, loader_data, ref_only); if (a == nullptr) { log_warn (LOG_ASSEMBLY, "open_from_bundles: failed to load bundled assembly %s", name.get ()); #if defined(DEBUG) diff --git a/src/native/monodroid/embedded-assemblies.hh b/src/native/monodroid/embedded-assemblies.hh index 99ca0f03b6d..3bdc4ea752a 100644 --- a/src/native/monodroid/embedded-assemblies.hh +++ b/src/native/monodroid/embedded-assemblies.hh @@ -197,9 +197,6 @@ namespace xamarin::android::internal { void gather_bundled_assemblies_from_apk (const char* apk, monodroid_should_register should_register); - template - MonoAssembly* assembly_store_open_from_bundles (dynamic_local_string& name, TLoaderData loader_data, bool ref_only) noexcept; - template MonoAssembly* open_from_bundles (MonoAssemblyName* aname, TLoaderData loader_data, MonoError *error, bool ref_only) noexcept; From 4c52fb38d1bd94bc137bd3e5d6ac679b16de6d8d Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Wed, 30 Oct 2024 09:26:34 +0100 Subject: [PATCH 5/8] Update apkdesc files --- .../BuildReleaseArm64SimpleDotNet.apkdesc | 47 +--- .../BuildReleaseArm64XFormsDotNet.apkdesc | 227 +----------------- 2 files changed, 20 insertions(+), 254 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc index 7245c6f39a5..6adb8681167 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64SimpleDotNet.apkdesc @@ -5,49 +5,22 @@ "Size": 3036 }, "classes.dex": { - "Size": 389672 - }, - "lib/arm64-v8a/lib__Microsoft.Android.Resource.Designer.dll.so": { - "Size": 18208 - }, - "lib/arm64-v8a/lib_Java.Interop.dll.so": { - "Size": 86256 - }, - "lib/arm64-v8a/lib_Mono.Android.dll.so": { - "Size": 115344 - }, - "lib/arm64-v8a/lib_Mono.Android.Runtime.dll.so": { - "Size": 22400 - }, - "lib/arm64-v8a/lib_System.Console.dll.so": { - "Size": 24384 - }, - "lib/arm64-v8a/lib_System.Linq.dll.so": { - "Size": 26480 - }, - "lib/arm64-v8a/lib_System.Private.CoreLib.dll.so": { - "Size": 633920 - }, - "lib/arm64-v8a/lib_System.Runtime.dll.so": { - "Size": 20048 - }, - "lib/arm64-v8a/lib_System.Runtime.InteropServices.dll.so": { - "Size": 21592 - }, - "lib/arm64-v8a/lib_UnnamedProject.dll.so": { - "Size": 20024 + "Size": 389636 }, "lib/arm64-v8a/libarc.bin.so": { "Size": 18776 }, + "lib/arm64-v8a/libassemblies.arm64-v8a.blob.so": { + "Size": 836792 + }, "lib/arm64-v8a/libmono-component-marshal-ilgen.so": { "Size": 87432 }, "lib/arm64-v8a/libmonodroid.so": { - "Size": 485400 + "Size": 456888 }, "lib/arm64-v8a/libmonosgen-2.0.so": { - "Size": 3196336 + "Size": 3196512 }, "lib/arm64-v8a/libSystem.Globalization.Native.so": { "Size": 67248 @@ -62,16 +35,16 @@ "Size": 160232 }, "lib/arm64-v8a/libxamarin-app.so": { - "Size": 12648 + "Size": 11984 }, "META-INF/BNDLTOOL.RSA": { "Size": 1223 }, "META-INF/BNDLTOOL.SF": { - "Size": 3266 + "Size": 2228 }, "META-INF/MANIFEST.MF": { - "Size": 3139 + "Size": 2101 }, "res/drawable-hdpi-v4/icon.png": { "Size": 2178 @@ -98,5 +71,5 @@ "Size": 1904 } }, - "PackageSize": 2865685 + "PackageSize": 2840305 } \ No newline at end of file diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc index 3fdac7611d2..26c6761af39 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.ProjectTools/Resources/Base/BuildReleaseArm64XFormsDotNet.apkdesc @@ -5,7 +5,7 @@ "Size": 6652 }, "classes.dex": { - "Size": 9448924 + "Size": 9448884 }, "classes2.dex": { "Size": 154180 @@ -31,227 +31,20 @@ "kotlin/reflect/reflect.kotlin_builtins": { "Size": 2396 }, - "lib/arm64-v8a/lib__Microsoft.Android.Resource.Designer.dll.so": { - "Size": 19456 - }, - "lib/arm64-v8a/lib_FormsViewGroup.dll.so": { - "Size": 25184 - }, - "lib/arm64-v8a/lib_Java.Interop.dll.so": { - "Size": 94640 - }, - "lib/arm64-v8a/lib_Mono.Android.dll.so": { - "Size": 521824 - }, - "lib/arm64-v8a/lib_Mono.Android.Runtime.dll.so": { - "Size": 22400 - }, - "lib/arm64-v8a/lib_mscorlib.dll.so": { - "Size": 21440 - }, - "lib/arm64-v8a/lib_netstandard.dll.so": { - "Size": 23080 - }, - "lib/arm64-v8a/lib_System.Collections.Concurrent.dll.so": { - "Size": 29800 - }, - "lib/arm64-v8a/lib_System.Collections.dll.so": { - "Size": 36288 - }, - "lib/arm64-v8a/lib_System.Collections.NonGeneric.dll.so": { - "Size": 25760 - }, - "lib/arm64-v8a/lib_System.Collections.Specialized.dll.so": { - "Size": 23848 - }, - "lib/arm64-v8a/lib_System.ComponentModel.dll.so": { - "Size": 19584 - }, - "lib/arm64-v8a/lib_System.ComponentModel.Primitives.dll.so": { - "Size": 21296 - }, - "lib/arm64-v8a/lib_System.ComponentModel.TypeConverter.dll.so": { - "Size": 42448 - }, - "lib/arm64-v8a/lib_System.Console.dll.so": { - "Size": 24416 - }, - "lib/arm64-v8a/lib_System.Core.dll.so": { - "Size": 19456 - }, - "lib/arm64-v8a/lib_System.Diagnostics.DiagnosticSource.dll.so": { - "Size": 28440 - }, - "lib/arm64-v8a/lib_System.Diagnostics.TraceSource.dll.so": { - "Size": 24688 - }, - "lib/arm64-v8a/lib_System.dll.so": { - "Size": 19856 - }, - "lib/arm64-v8a/lib_System.Drawing.dll.so": { - "Size": 19432 - }, - "lib/arm64-v8a/lib_System.Drawing.Primitives.dll.so": { - "Size": 30048 - }, - "lib/arm64-v8a/lib_System.Formats.Asn1.dll.so": { - "Size": 49936 - }, - "lib/arm64-v8a/lib_System.IO.Compression.Brotli.dll.so": { - "Size": 29480 - }, - "lib/arm64-v8a/lib_System.IO.Compression.dll.so": { - "Size": 33784 - }, - "lib/arm64-v8a/lib_System.IO.IsolatedStorage.dll.so": { - "Size": 28288 - }, - "lib/arm64-v8a/lib_System.Linq.dll.so": { - "Size": 38736 - }, - "lib/arm64-v8a/lib_System.Linq.Expressions.dll.so": { - "Size": 185808 - }, - "lib/arm64-v8a/lib_System.Net.Http.dll.so": { - "Size": 89496 - }, - "lib/arm64-v8a/lib_System.Net.Primitives.dll.so": { - "Size": 41120 - }, - "lib/arm64-v8a/lib_System.Net.Requests.dll.so": { - "Size": 21552 - }, - "lib/arm64-v8a/lib_System.ObjectModel.dll.so": { - "Size": 27072 - }, - "lib/arm64-v8a/lib_System.Private.CoreLib.dll.so": { - "Size": 956408 - }, - "lib/arm64-v8a/lib_System.Private.DataContractSerialization.dll.so": { - "Size": 216688 - }, - "lib/arm64-v8a/lib_System.Private.Uri.dll.so": { - "Size": 62192 - }, - "lib/arm64-v8a/lib_System.Private.Xml.dll.so": { - "Size": 237104 - }, - "lib/arm64-v8a/lib_System.Private.Xml.Linq.dll.so": { - "Size": 35584 - }, - "lib/arm64-v8a/lib_System.Runtime.dll.so": { - "Size": 20200 - }, - "lib/arm64-v8a/lib_System.Runtime.InteropServices.dll.so": { - "Size": 21592 - }, - "lib/arm64-v8a/lib_System.Runtime.Numerics.dll.so": { - "Size": 54408 - }, - "lib/arm64-v8a/lib_System.Runtime.Serialization.dll.so": { - "Size": 19352 - }, - "lib/arm64-v8a/lib_System.Runtime.Serialization.Formatters.dll.so": { - "Size": 20336 - }, - "lib/arm64-v8a/lib_System.Runtime.Serialization.Primitives.dll.so": { - "Size": 21448 - }, - "lib/arm64-v8a/lib_System.Security.Cryptography.dll.so": { - "Size": 80504 - }, - "lib/arm64-v8a/lib_System.Text.RegularExpressions.dll.so": { - "Size": 183592 - }, - "lib/arm64-v8a/lib_System.Xml.dll.so": { - "Size": 19256 - }, - "lib/arm64-v8a/lib_System.Xml.Linq.dll.so": { - "Size": 19272 - }, - "lib/arm64-v8a/lib_UnnamedProject.dll.so": { - "Size": 22096 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.Activity.dll.so": { - "Size": 34760 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.AppCompat.AppCompatResources.dll.so": { - "Size": 24296 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.AppCompat.dll.so": { - "Size": 163072 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.CardView.dll.so": { - "Size": 24560 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.CoordinatorLayout.dll.so": { - "Size": 35680 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.Core.dll.so": { - "Size": 151216 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.CursorAdapter.dll.so": { - "Size": 27168 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.DrawerLayout.dll.so": { - "Size": 33760 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.Fragment.dll.so": { - "Size": 72224 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.Legacy.Support.Core.UI.dll.so": { - "Size": 23896 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.Lifecycle.Common.dll.so": { - "Size": 25072 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.Lifecycle.LiveData.Core.dll.so": { - "Size": 24864 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.Lifecycle.ViewModel.dll.so": { - "Size": 25208 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.Loader.dll.so": { - "Size": 31592 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.RecyclerView.dll.so": { - "Size": 111896 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.SavedState.dll.so": { - "Size": 23144 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.SwipeRefreshLayout.dll.so": { - "Size": 31672 - }, - "lib/arm64-v8a/lib_Xamarin.AndroidX.ViewPager.dll.so": { - "Size": 37752 - }, - "lib/arm64-v8a/lib_Xamarin.Forms.Core.dll.so": { - "Size": 581000 - }, - "lib/arm64-v8a/lib_Xamarin.Forms.Platform.Android.dll.so": { - "Size": 390464 - }, - "lib/arm64-v8a/lib_Xamarin.Forms.Platform.dll.so": { - "Size": 35848 - }, - "lib/arm64-v8a/lib_Xamarin.Forms.Xaml.dll.so": { - "Size": 80632 - }, - "lib/arm64-v8a/lib_Xamarin.Google.Android.Material.dll.so": { - "Size": 84400 - }, "lib/arm64-v8a/libarc.bin.so": { "Size": 18776 }, + "lib/arm64-v8a/libassemblies.arm64-v8a.blob.so": { + "Size": 4529760 + }, "lib/arm64-v8a/libmono-component-marshal-ilgen.so": { "Size": 87432 }, "lib/arm64-v8a/libmonodroid.so": { - "Size": 485400 + "Size": 456888 }, "lib/arm64-v8a/libmonosgen-2.0.so": { - "Size": 3196336 + "Size": 3196512 }, "lib/arm64-v8a/libSystem.Globalization.Native.so": { "Size": 67248 @@ -266,7 +59,7 @@ "Size": 160232 }, "lib/arm64-v8a/libxamarin-app.so": { - "Size": 119928 + "Size": 113240 }, "META-INF/androidx.activity_activity.version": { "Size": 6 @@ -422,7 +215,7 @@ "Size": 1221 }, "META-INF/BNDLTOOL.SF": { - "Size": 98661 + "Size": 90279 }, "META-INF/com.android.tools/proguard/coroutines.pro": { "Size": 1345 @@ -449,7 +242,7 @@ "Size": 5 }, "META-INF/MANIFEST.MF": { - "Size": 98534 + "Size": 90152 }, "META-INF/maven/com.google.guava/listenablefuture/pom.properties": { "Size": 96 @@ -2489,5 +2282,5 @@ "Size": 812848 } }, - "PackageSize": 10673477 + "PackageSize": 10556306 } \ No newline at end of file From 0fd503c05cdd8ce72f4b2e3ebea0cbe7520e6efe Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Wed, 30 Oct 2024 11:52:42 +0100 Subject: [PATCH 6/8] Better `abort_unless` location reporting --- src/native/shared/cpp-util.hh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/native/shared/cpp-util.hh b/src/native/shared/cpp-util.hh index 160fa844e36..241e1b81776 100644 --- a/src/native/shared/cpp-util.hh +++ b/src/native/shared/cpp-util.hh @@ -15,7 +15,7 @@ #include "helpers.hh" static inline void -do_abort_unless (const char* fmt, ...) +do_abort_unless (std::source_location sloc, const char* fmt, ...) { va_list ap; @@ -24,12 +24,12 @@ do_abort_unless (const char* fmt, ...) int n = vasprintf (&message, fmt, ap); va_end (ap); - xamarin::android::Helpers::abort_application (n == -1 ? "Unable to allocate memory for abort message" : message); + xamarin::android::Helpers::abort_application (n == -1 ? "Unable to allocate memory for abort message" : message, true /* log_location */, sloc); } #define abort_unless(_condition_, _fmt_, ...) \ if (!(_condition_)) [[unlikely]] { \ - do_abort_unless ("%s:%d (%s): " _fmt_, __FILE__, __LINE__, __FUNCTION__, ## __VA_ARGS__); \ + do_abort_unless (std::source_location::current (), _fmt_, ## __VA_ARGS__); \ } #define abort_if_invalid_pointer_argument(_ptr_) abort_unless ((_ptr_) != nullptr, "Parameter '%s' must be a valid pointer", #_ptr_) From cf19401bb5be6514167386486be8d2fae719725a Mon Sep 17 00:00:00 2001 From: Marek Habersack Date: Wed, 30 Oct 2024 11:52:57 +0100 Subject: [PATCH 7/8] Better FastDev handling --- .../Tasks/GeneratePackageManagerJava.cs | 2 + .../Utilities/EnvironmentHelper.cs | 42 +++++++++++-------- .../Utilities/ApplicationConfig.cs | 1 + ...pplicationConfigNativeAssemblyGenerator.cs | 2 + .../Xamarin.Android.Common.targets | 5 ++- src/native/monodroid/embedded-assemblies.cc | 10 ++--- src/native/monodroid/embedded-assemblies.hh | 6 +++ .../xamarin-app-stub/application_dso_stub.cc | 1 + src/native/xamarin-app-stub/xamarin-app.hh | 1 + 9 files changed, 46 insertions(+), 24 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs b/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs index 49a9b58ca2e..0d5c098a6fd 100644 --- a/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs +++ b/src/Xamarin.Android.Build.Tasks/Tasks/GeneratePackageManagerJava.cs @@ -74,6 +74,7 @@ public class GeneratePackageManagerJava : AndroidTask public string AndroidSequencePointsMode { get; set; } public bool EnableSGenConcurrent { get; set; } public string? CustomBundleConfigFile { get; set; } + public bool FastDevEnabled { get; set; } bool _Debug { get { @@ -314,6 +315,7 @@ void AddEnvironment () JniRemappingReplacementMethodIndexEntryCount = jniRemappingNativeCodeInfo == null ? 0 : jniRemappingNativeCodeInfo.ReplacementMethodIndexEntryCount, MarshalMethodsEnabled = EnableMarshalMethods, IgnoreSplitConfigs = ShouldIgnoreSplitConfigs (), + FastDevEnabled = FastDevEnabled, }; LLVMIR.LlvmIrModule appConfigModule = appConfigAsmGen.Construct (); diff --git a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs index 77af45f9e6f..7069d8f60e2 100644 --- a/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs +++ b/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/EnvironmentHelper.cs @@ -46,6 +46,7 @@ public sealed class ApplicationConfig public bool broken_exception_transitions; public bool jni_add_native_method_registration_attribute_present; public bool have_runtime_config_blob; + public bool fastdev_enabled; public bool marshal_methods_enabled; public bool ignore_split_configs; public byte bound_stream_io_exception_type; @@ -65,7 +66,7 @@ public sealed class ApplicationConfig public string android_package_name = String.Empty; } - const uint ApplicationConfigFieldCount = 24; + const uint ApplicationConfigFieldCount = 25; const string ApplicationConfigSymbolName = "application_config"; const string AppEnvironmentVariablesSymbolName = "app_environment_variables"; @@ -239,87 +240,92 @@ static ApplicationConfig ReadApplicationConfig (EnvironmentFile envFile) ret.have_runtime_config_blob = ConvertFieldToBool ("have_runtime_config_blob", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 7: // marshal_methods_enabled: bool / .byte + case 7: // fastdev_enabled: bool / .byte + AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber); + ret.fastdev_enabled = ConvertFieldToBool ("fastdev_enabled", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); + break; + + case 8: // marshal_methods_enabled: bool / .byte AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber); ret.marshal_methods_enabled = ConvertFieldToBool ("marshal_methods_enabled", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 8: // ignore_split_configs: bool / .byte + case 9: // ignore_split_configs: bool / .byte AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber); ret.ignore_split_configs = ConvertFieldToBool ("ignore_split_configs", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 9: // bound_stream_io_exception_type: byte / .byte + case 10: // bound_stream_io_exception_type: byte / .byte AssertFieldType (envFile.Path, parser.SourceFilePath, ".byte", field [0], item.LineNumber); ret.bound_stream_io_exception_type = ConvertFieldToByte ("bound_stream_io_exception_type", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 10: // package_naming_policy: uint32_t / .word | .long + case 11: // package_naming_policy: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.package_naming_policy = ConvertFieldToUInt32 ("package_naming_policy", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 11: // environment_variable_count: uint32_t / .word | .long + case 12: // environment_variable_count: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.environment_variable_count = ConvertFieldToUInt32 ("environment_variable_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 12: // system_property_count: uint32_t / .word | .long + case 13: // system_property_count: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.system_property_count = ConvertFieldToUInt32 ("system_property_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 13: // number_of_assemblies_in_apk: uint32_t / .word | .long + case 14: // number_of_assemblies_in_apk: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.number_of_assemblies_in_apk = ConvertFieldToUInt32 ("number_of_assemblies_in_apk", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 14: // number_of_assembly_store_files: uint32_t / .word | .long + case 15: // number_of_assembly_store_files: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.number_of_assembly_store_files = ConvertFieldToUInt32 ("number_of_assembly_store_files", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 15: // number_of_dso_cache_entries: uint32_t / .word | .long + case 16: // number_of_dso_cache_entries: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.number_of_dso_cache_entries = ConvertFieldToUInt32 ("number_of_dso_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 16: // number_of_aot_cache_entries: uint32_t / .word | .long + case 17: // number_of_aot_cache_entries: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.number_of_aot_cache_entries = ConvertFieldToUInt32 ("number_of_aot_cache_entries", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 17: // android_runtime_jnienv_class_token: uint32_t / .word | .long + case 18: // android_runtime_jnienv_class_token: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.android_runtime_jnienv_class_token = ConvertFieldToUInt32 ("android_runtime_jnienv_class_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 18: // jnienv_initialize_method_token: uint32_t / .word | .long + case 19: // jnienv_initialize_method_token: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.jnienv_initialize_method_token = ConvertFieldToUInt32 ("jnienv_initialize_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 19: // jnienv_registerjninatives_method_token: uint32_t / .word | .long + case 20: // jnienv_registerjninatives_method_token: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.jnienv_registerjninatives_method_token = ConvertFieldToUInt32 ("jnienv_registerjninatives_method_token", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 20: // jni_remapping_replacement_type_count: uint32_t / .word | .long + case 21: // jni_remapping_replacement_type_count: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.jni_remapping_replacement_type_count = ConvertFieldToUInt32 ("jni_remapping_replacement_type_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 21: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long + case 22: // jni_remapping_replacement_method_index_entry_count: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.jni_remapping_replacement_method_index_entry_count = ConvertFieldToUInt32 ("jni_remapping_replacement_method_index_entry_count", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 22: // mono_components_mask: uint32_t / .word | .long + case 23: // mono_components_mask: uint32_t / .word | .long Assert.IsTrue (expectedUInt32Types.Contains (field [0]), $"Unexpected uint32_t field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); ret.mono_components_mask = ConvertFieldToUInt32 ("mono_components_mask", envFile.Path, parser.SourceFilePath, item.LineNumber, field [1]); break; - case 23: // android_package_name: string / [pointer type] + case 24: // android_package_name: string / [pointer type] Assert.IsTrue (expectedPointerTypes.Contains (field [0]), $"Unexpected pointer field type in '{envFile.Path}:{item.LineNumber}': {field [0]}"); pointers.Add (field [1].Trim ()); break; diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs index d8bea68deb1..b792d1d3eb7 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfig.cs @@ -31,6 +31,7 @@ sealed class ApplicationConfig public bool broken_exception_transitions; public bool jni_add_native_method_registration_attribute_present; public bool have_runtime_config_blob; + public bool fastdev_enabled; public bool marshal_methods_enabled; public bool ignore_split_configs; public byte bound_stream_io_exception_type; diff --git a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs index 7f080d926d1..7c6511457c7 100644 --- a/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs +++ b/src/Xamarin.Android.Build.Tasks/Utilities/ApplicationConfigNativeAssemblyGenerator.cs @@ -186,6 +186,7 @@ sealed class XamarinAndroidBundledAssembly public List NativeLibraries { get; set; } public bool MarshalMethodsEnabled { get; set; } public bool IgnoreSplitConfigs { get; set; } + public bool FastDevEnabled { get; set; } public ApplicationConfigNativeAssemblyGenerator (IDictionary environmentVariables, IDictionary systemProperties, TaskLoggingHelper log) : base (log) @@ -225,6 +226,7 @@ protected override void Construct (LlvmIrModule module) broken_exception_transitions = BrokenExceptionTransitions, jni_add_native_method_registration_attribute_present = JniAddNativeMethodRegistrationAttributePresent, have_runtime_config_blob = HaveRuntimeConfigBlob, + fastdev_enabled = FastDevEnabled, marshal_methods_enabled = MarshalMethodsEnabled, ignore_split_configs = IgnoreSplitConfigs, bound_stream_io_exception_type = (byte)BoundExceptionType, diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index b1b26a82048..d32b742e5f5 100644 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -1,4 +1,4 @@ -