-
Notifications
You must be signed in to change notification settings - Fork 564
[Xamarin.Android.Build.Tasks] Delete inconsistent debug symbols #701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@dellis1972: An alternate -- more correct? -- fix would be to instead delete the One problem with nuking One advantage to nuking is that if an assembly is removed from |
|
One problem with this PR is...no tests. Unfortunately I don't know how to write an automated test for this scenario. :-( |
|
Perhaps unsurprisingly, this patch causes two unit test failures: Both of these fail with the message:
However, as per prior analysis/discussion, the Reading the This thus looks like the test case should be updated...except I'm confused: the BuildBasicApplicationCheckPdb test doesn't appear to have modified between the initial build (line 1676) and the subsequent build (line 1715), so why is For reference, the The quick answer: because Time for a |
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58221 The build scenario: 1. Use Windows. (This doesn't happen on macOS.) 2. Clone: https://github.com/xamarin/xamarin-forms-samples/tree/master/Templates/DataTemplateSelector 3. Edit `Selector\Selector.csproj` and change `$(DebugType)` to Portable. 4. Open `Selector.sln` within VS and restore all packages. 5. Build the `Droid\Selector.Droid.csproj` project: msbuild /p:Configuration=Release /t:SignAndroidPackage Droid\Selector.Droid.csproj 6. Touch (update the timestamp of) `Selector\Selector.csproj`. 7. Build the project `Droid\Selector.Droid.csproj` project again. msbuild /p:Configuration=Release /t:SignAndroidPackage Droid\Selector.Droid.csproj Expected results: No errors. Actual results: Linking fails: error MSB4018: The "LinkAssemblies" task failed unexpectedly.\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: Mono.Linker.MarkException: Error processing method: 'Xamarin.Forms.View Xamarin.Forms.Platform.Android.VisualElementRenderer`1::get_View()' in assembly: 'Xamarin.Forms.Platform.Android.dll' ---> System.ArgumentNullException: Value cannot be null.\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: Parameter name: instruction\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.InstructionOffset..ctor(Instruction instruction)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScopes(Collection`1 scopes)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScopes(Collection`1 scopes)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadDebugInfo()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadMethodBody()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.MetadataReader.ReadMethodBody(MethodDefinition method)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.MethodDefinition.get_Body()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: --- End of inner exception stack trace ---\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.Process()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.Process(LinkContext context)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at MonoDroid.Tuner.Linker.Run(Pipeline pipeline, LinkContext context)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] The cause of the error is in the interaction between the `_CopyIntermediateAssemblies`, `_CopyMdbFiles`, and `_StripEmbeddedLibraries` targets. During the initial build in Step (5), `obj\Release\linksrc` is populated with copies of the original assemblies and debug symbols for those assemblies. The contents of `obj\Release\linksrc` are then updated *in place* by various tasks such as the `<StripEmbeddedLibraries/>` and `<LinkAssemblies/>` tasks. After stripping and linking, the timestamps in `obj\Release\linksrc` are updated and the assemblies and associated debug symbols may be smaller than the original copies. During the rebuild in Step (7), `_CopyIntermediateAssemblies` replaces `obj\Release\linksrc\Xamarin.Forms.Platform.Android.dll` with a copy of the original file in `packages\Xamarin.Forms...\lib\MonoAndroid10`. The `_CopyMdbFiles` task -- which is responsible for copying `.dll.mdb` files into `obj\Release\linksrc` -- does *not* update the `Xamarin.Forms.Platform.Android.dll.mdb` file. The result of this inaction is that when the `<StripEmbeddedLibraries/>` task executes, the assembly and corresponding debug symbols are out-of-sync: `Xamarin.Forms.Platform.Android.dll` is the original+unstripped assembly, while `Xamarin.Forms.Platform.Android.dll.mdb` has been *modified* as part of (both?) the `<StripEmbeddedLibraries/>` and/or `<LinkAssemblies/>` task. When `<StripEmbeddedLibraries/>` executes again as part of the rebuild, it takes these out-of-sync files and then proceeds to *corrupt* the `Xamarin.Forms.Platform.Android.dll.mdb` file. After the `<StripEmbeddedLibraries/>` task completes, we eventually hit the `<LinkAssemblies/>` task, during which Cecil attempts to load the now-corrupt `Xamarin.Forms.Platform.Android.dll.mdb` file, which results in the above `ArgumentNullException`. The fix is in the `_CopyIntermediateAssemblies` target: when we copy assemblies into the `obj\Release\linksrc` directory, ensure that any corresponding `.dll.mdb` files for those asssemblies are *deleted*. This will allow `_CopyMdbFiles` to re-copy the debug symbols, ensuring that everything stays in sync. *Additionally*, update the `_CopyIntermediateAssemblies` target to `<Touch/>` the copied files so that timestamps compare properly. Otherwise, on the 2nd+ build, the target re-executes because the project assembly is newer than e.g. a BCL assembly: Target _CopyIntermediateAssemblies needs to be built as input file '…/xamarin-android/bin/TestDebug/temp/BuildBasicApplicationCheckPdb/bin/Debug/UnnamedProject.dll' is newer than output file 'obj/Debug/linksrc/NetStandard16.dll' Without the `<Touch/>`, the above will *always* be true.
a8ae38a to
c06ec9c
Compare
|
Now it's failing in BuildTest.BuildAMassiveApp:
However, reading the 40MB log file at https://jenkins.mono-project.com/job/xamarin-android-pr-builder/ws/xamarin-android/bin/TestDebug/temp/BuildAMassiveApp/build.log/*view*/ -- subject to invalidation at the next PR build -- I don't see any errors in there. More "interestingly" is that the error message should be coming from Assert.IsTrue(sb.BuildProject(app1, "SignAndroidPackage"), "Build of project should have succeeded");I don't see any mention of Ah! It's not in the top-level ...which shows a mono crash: That sounds like "not my problem." I'll re-build the PR. |
|
build |
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58221 The build scenario: 1. Use Windows. (This doesn't happen on macOS.) 2. Clone: https://github.com/xamarin/xamarin-forms-samples/tree/master/Templates/DataTemplateSelector 3. Edit `Selector\Selector.csproj` and change `$(DebugType)` to Portable. 4. Open `Selector.sln` within VS and restore all packages. 5. Build the `Droid\Selector.Droid.csproj` project: msbuild /p:Configuration=Release /t:SignAndroidPackage Droid\Selector.Droid.csproj 6. Touch (update the timestamp of) `Selector\Selector.csproj`. 7. Build the project `Droid\Selector.Droid.csproj` project again. msbuild /p:Configuration=Release /t:SignAndroidPackage Droid\Selector.Droid.csproj Expected results: No errors. Actual results: Linking fails: error MSB4018: The "LinkAssemblies" task failed unexpectedly.\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: Mono.Linker.MarkException: Error processing method: 'Xamarin.Forms.View Xamarin.Forms.Platform.Android.VisualElementRenderer`1::get_View()' in assembly: 'Xamarin.Forms.Platform.Android.dll' ---> System.ArgumentNullException: Value cannot be null.\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: Parameter name: instruction\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.InstructionOffset..ctor(Instruction instruction)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScopes(Collection`1 scopes)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScopes(Collection`1 scopes)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadScope(ScopeDebugInformation scope)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadDebugInfo()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadMethodBody()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.Cil.CodeReader.ReadMethodBody(MethodDefinition method)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.MetadataReader.ReadMethodBody(MethodDefinition method)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.MethodDefinition.<>c.<get_Body>b__41_0(MethodDefinition method, MetadataReader reader)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.ModuleDefinition.Read[TItem,TRet](TRet& variable, TItem item, Func`3 read)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Cecil.MethodDefinition.get_Body()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessMethod(MethodDefinition method)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: --- End of inner exception stack trace ---\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.ProcessQueue()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.Process()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Steps.MarkStep.Process(LinkContext context)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Mono.Linker.Pipeline.Process(LinkContext context)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at MonoDroid.Tuner.Linker.Run(Pipeline pipeline, LinkContext context)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at MonoDroid.Tuner.Linker.Process(LinkerOptions options, LinkContext& context)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute(DirectoryAssemblyResolver res)\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Xamarin.Android.Tasks.LinkAssemblies.Execute()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()\r [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__26.MoveNext() [C:\Users\jonpr\Dev\xamarin-forms-samples\Templates\DataTemplateSelector\Droid\Selector.Droid.csproj] The cause of the error is in the interaction between the `_CopyIntermediateAssemblies`, `_CopyMdbFiles`, and `_StripEmbeddedLibraries` targets. During the initial build in Step (5), `obj\Release\linksrc` is populated with copies of the original assemblies and debug symbols for those assemblies. The contents of `obj\Release\linksrc` are then updated *in place* by various tasks such as the `<StripEmbeddedLibraries/>` and `<LinkAssemblies/>` tasks. After stripping and linking, the timestamps in `obj\Release\linksrc` are updated and the assemblies and associated debug symbols may be smaller than the original copies. During the rebuild in Step (7), `_CopyIntermediateAssemblies` replaces `obj\Release\linksrc\Xamarin.Forms.Platform.Android.dll` with a copy of the original file in `packages\Xamarin.Forms...\lib\MonoAndroid10`. The `_CopyMdbFiles` task -- which is responsible for copying `.dll.mdb` files into `obj\Release\linksrc` -- does *not* update the `Xamarin.Forms.Platform.Android.dll.mdb` file. The result of this inaction is that when the `<StripEmbeddedLibraries/>` task executes, the assembly and corresponding debug symbols are out-of-sync: `Xamarin.Forms.Platform.Android.dll` is the original+unstripped assembly, while `Xamarin.Forms.Platform.Android.dll.mdb` has been *modified* as part of (both?) the `<StripEmbeddedLibraries/>` and/or `<LinkAssemblies/>` task. When `<StripEmbeddedLibraries/>` executes again as part of the rebuild, it takes these out-of-sync files and then proceeds to *corrupt* the `Xamarin.Forms.Platform.Android.dll.mdb` file. After the `<StripEmbeddedLibraries/>` task completes, we eventually hit the `<LinkAssemblies/>` task, during which Cecil attempts to load the now-corrupt `Xamarin.Forms.Platform.Android.dll.mdb` file, which results in the above `ArgumentNullException`. The fix is in the `_CopyIntermediateAssemblies` target: when we copy assemblies into the `obj\Release\linksrc` directory, ensure that any corresponding `.dll.mdb` files for those asssemblies are *deleted*. This will allow `_CopyMdbFiles` to re-copy the debug symbols, ensuring that everything stays in sync. *Additionally*, update the `_CopyIntermediateAssemblies` target to `<Touch/>` the copied files so that timestamps compare properly. Otherwise, on the 2nd+ build, the target re-executes because the project assembly is newer than e.g. a BCL assembly: Target _CopyIntermediateAssemblies needs to be built as input file '…/xamarin-android/bin/TestDebug/temp/BuildBasicApplicationCheckPdb/bin/Debug/UnnamedProject.dll' is newer than output file 'obj/Debug/linksrc/NetStandard16.dll' Without the `<Touch/>`, the above will *always* be true.
Fixes: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1139590 Context: dotnet/java-interop@afbc5b3 Changes: dotnet/java-interop@dcaf794...afbc5b3 * dotnet/java-interop@afbc5b32: [C++] Get rid of compiler warnings (#703) * dotnet/java-interop@e295b498: [generator] Fix localization error. (#702) * dotnet/java-interop@5a0e37e0: [generator] Support 'managedOverride' metadata (#701) * dotnet/java-interop@f6c12ba3: [Xamarin.Android.Tools.Bytecode] Hide Kotlin synthetic constructors (#700) * dotnet/java-interop@0334f424: [generator] Hide Java.Lang.Object infrastructure (#698) * dotnet/java-interop@c0fcc435: [jcw-gen] Make MSBuild warning/error strings localizable. (#695) Fixes a handful of warnings reported by GCC and clang when building for different platforms. `-Wshadow` warnings: monodroid-glue.cc:1609:8: warning: declaration shadows a static data member of 'xamarin::android::internal::MonodroidRuntime' [-Wshadow] void *api_dso_handle = nullptr; ^ monodroid-glue.cc:102:25: note: previous declaration is here void *MonodroidRuntime::api_dso_handle = nullptr; Fix by renaming the local variable. No functionality changes result from this fix. MinGW builds report: xa-internal-api.cc: In member function ‘virtual mono_bool xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state(const char*, mono_bool*)’: xa-internal-api.cc:24:86: warning: unused parameter ‘ifname’ [-Wunused-parameter] 24 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up) | ~~~~~~~~~~~~^~~~~~ xa-internal-api.cc:24:105: warning: unused parameter ‘is_up’ [-Wunused-parameter] 24 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_up_state (const char *ifname, mono_bool *is_up) | ~~~~~~~~~~~^~~~~ xa-internal-api.cc: In member function ‘virtual mono_bool xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast(const char*, mono_bool*)’: xa-internal-api.cc:34:96: warning: unused parameter ‘ifname’ [-Wunused-parameter] 34 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast) | ~~~~~~~~~~~~^~~~~~ xa-internal-api.cc:34:115: warning: unused parameter ‘supports_multicast’ [-Wunused-parameter] 34 | MonoAndroidInternalCalls_Impl::monodroid_get_network_interface_supports_multicast (const char *ifname, mono_bool *supports_multicast) | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ xa-internal-api.cc: In member function ‘virtual int xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_get_dns_servers(void**)’: xa-internal-api.cc:44:66: warning: unused parameter ‘dns_servers_array’ [-Wunused-parameter] 44 | MonoAndroidInternalCalls_Impl::monodroid_get_dns_servers (void **dns_servers_array) | ~~~~~~~^~~~~~~~~~~~~~~~~ xa-internal-api.cc: In member function ‘virtual int xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_getifaddrs(_monodroid_ifaddrs**)’: xa-internal-api.cc:54:82: warning: unused parameter ‘ifap’ [-Wunused-parameter] 54 | MonoAndroidInternalCalls_Impl::monodroid_getifaddrs (struct _monodroid_ifaddrs **ifap) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~ xa-internal-api.cc: In member function ‘virtual void xamarin::android::internal::MonoAndroidInternalCalls_Impl::monodroid_freeifaddrs(_monodroid_ifaddrs*)’: xa-internal-api.cc:64:82: warning: unused parameter ‘ifa’ [-Wunused-parameter] 64 | MonoAndroidInternalCalls_Impl::monodroid_freeifaddrs (struct _monodroid_ifaddrs *ifa) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ Fix by ignoring the unused parameters only during Windows builds by using the C++17 attribute `[[maybe_unused]]` MinGW also reports: embedded-assemblies.cc: In static member function ‘static ssize_t xamarin::android::internal::EmbeddedAssemblies::do_read(int, void*, size_t)’: embedded-assemblies.cc:663:26: warning: conversion from ‘size_t’ {aka ‘long long unsigned int’} to ‘unsigned int’ may change value [-Wconversion] 663 | ret = ::read (fd, buf, count); | It is caused by **read**(2) declared in MinGW headers with the third parameter using an `unsigned int` type instead of the standard `size_t`. Fixed by casting properly on Windows builds.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=58221
The build scenario:
Use Windows. (This doesn't happen on macOS.)
Clone: https://github.com/xamarin/xamarin-forms-samples/tree/master/Templates/DataTemplateSelector
Edit
Selector\Selector.csprojand change$(DebugType)to Portable.Open
Selector.slnwithin VS and restore all packages.Build the
Droid\Selector.Droid.csprojproject:Touch (update the timestamp of)
Selector\Selector.csproj.Build the project
Droid\Selector.Droid.csprojproject again.Expected results: No errors.
Actual results: Linking fails:
The cause of the error is in the interaction between the
_CopyIntermediateAssemblies,_CopyMdbFiles, and_StripEmbeddedLibrariestargets.During the initial build in Step (5),
obj\Release\linksrcispopulated with copies of the original assemblies and debug symbols for
those assemblies. The contents of
obj\Release\linksrcare thenupdated in place by various tasks such as the
<StripEmbeddedLibraries/>and<LinkAssemblies/>tasks. Afterstripping and linking, the timestamps in
obj\Release\linksrcareupdated and the assemblies and associated debug symbols may be smaller
than the original copies.
During the rebuild in Step (7),
_CopyIntermediateAssembliesreplacesobj\Release\linksrc\Xamarin.Forms.Platform.Android.dllwith a copyof the original file in
packages\Xamarin.Forms...\lib\MonoAndroid10.The
_CopyMdbFilestask -- which is responsible for copying.dll.mdbfiles intoobj\Release\linksrc-- does not update theXamarin.Forms.Platform.Android.dll.mdbfile. The result of thisinaction is that when the
<StripEmbeddedLibraries/>task executes,the assembly and corresponding debug symbols are out-of-sync:
Xamarin.Forms.Platform.Android.dllis the original+unstrippedassembly, while
Xamarin.Forms.Platform.Android.dll.mdbhas beenmodified as part of (both?) the
<StripEmbeddedLibraries/>and/or<LinkAssemblies/>task.When
<StripEmbeddedLibraries/>executes again as part of therebuild, it takes these out-of-sync files and then proceeds to
corrupt the
Xamarin.Forms.Platform.Android.dll.mdbfile. After the<StripEmbeddedLibraries/>task completes, we eventually hit the<LinkAssemblies/>task, during which Cecil attempts to load thenow-corrupt
Xamarin.Forms.Platform.Android.dll.mdbfile, whichresults in the above
ArgumentNullException.The fix is in the
_CopyIntermediateAssembliestarget: when we copyassemblies into the
obj\Release\linksrcdirectory, ensure that anycorresponding
.dll.mdbfiles for those asssemblies are deleted.This will allow
_CopyMdbFilesto re-copy the debug symbols, ensuringthat everything stays in sync.
Additionally, update the
_CopyIntermediateAssembliestarget to<Touch/>the copied files so that timestamps compare properly.Otherwise, on the 2nd+ build, the target re-executes because the
project assembly is newer than e.g. a BCL assembly:
Without the
<Touch/>, the above will always be true.