Skip to content
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

[Microsoft.Android.Sdk.ILLink] target net7.0 temporarily #7803

Merged
merged 1 commit into from
Feb 17, 2023

Conversation

jonathanpeppers
Copy link
Member

Context: xamarin/xamarin-macios#17560
Context: dotnet/runtime#82241

On macOS, if you have both .NET 7 and .NET 8 Preview 1 installed, and you do:

  • dotnet new android

  • dotnet build -c Release

You get a build error:

Fatal error in IL Linker
Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
    at Microsoft.Android.Sdk.ILLink.PreserveSubStepDispatcher..ctor()
    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
    --- End of inner exception stack trace ---
    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
    at Mono.Linker.Driver.AddCustomStep(Pipeline pipeline, String arg)
    at Mono.Linker.Driver.SetupContext(ILogger customLogger)
    at Mono.Linker.Driver.Run(ILogger customLogger)
    at Mono.Linker.Driver.Main(String[] args)

This happens because the linker is actually trying to run against the .NET 7 runtime! It promptly blows up against net8.0 linker steps.

Trying the same workaround as xamarin-macios, to build our linker steps for net7.0

Context: xamarin/xamarin-macios#17560
Context: dotnet/runtime#82241

On macOS, if you have both .NET 7 and .NET 8 Preview 1 installed, and
you do:

* `dotnet new android`

* `dotnet build -c Release`

You get a build error:

    Fatal error in IL Linker
    Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
    ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
    File name: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
        at Microsoft.Android.Sdk.ILLink.PreserveSubStepDispatcher..ctor()
        at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
        --- End of inner exception stack trace ---
        at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
        at Mono.Linker.Driver.AddCustomStep(Pipeline pipeline, String arg)
        at Mono.Linker.Driver.SetupContext(ILogger customLogger)
        at Mono.Linker.Driver.Run(ILogger customLogger)
        at Mono.Linker.Driver.Main(String[] args)

This happens because the linker is actually trying to run against the
.NET 7 runtime! It promptly blows up against `net8.0` linker steps.

Trying the same workaround as xamarin-macios, to build our linker steps
for `net7.0`
@jonpryor jonpryor merged commit 7ba7dd4 into dotnet:main Feb 17, 2023
grendello added a commit to grendello/xamarin-android that referenced this pull request Feb 17, 2023
* main:
  [tests] Bump NUnit versions to latest (dotnet#7802)
  [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803)
  [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800)
  Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797)
  [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780)
  Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)
  [lgtm] Fix LGTM-reported issues (dotnet#1074)
  [ci] Report issues in the API docs build log (dotnet#7784)
jonathanpeppers added a commit that referenced this pull request Feb 17, 2023
Context: xamarin/xamarin-macios#17560
Context: dotnet/runtime#82241

On macOS, if you have both .NET 7 and .NET 8 Preview 1 installed, and
you do:

	dotnet new android
	dotnet build -c Release

You get a build error:

	Fatal error in IL Linker
	Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
	---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
	File name: 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
	    at Microsoft.Android.Sdk.ILLink.PreserveSubStepDispatcher..ctor()
	    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
	    --- End of inner exception stack trace ---
	    at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
	    at Mono.Linker.Driver.AddCustomStep(Pipeline pipeline, String arg)
	    at Mono.Linker.Driver.SetupContext(ILogger customLogger)
	    at Mono.Linker.Driver.Run(ILogger customLogger)
	    at Mono.Linker.Driver.Main(String[] args)

This happens because the .NET 8 linker is actually trying to run
against the .NET 7 runtime!  It promptly blows up against `net8.0`
linker steps.

Trying [the same workaround as xamarin-macios][0], to build our
linker steps for `net7.0`.

[0]: xamarin/xamarin-macios@c61e327
grendello added a commit to grendello/xamarin-android that referenced this pull request Feb 20, 2023
* main:
  [tests] Bump NUnit versions to latest (dotnet#7802)
  [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803)
grendello added a commit to grendello/xamarin-android that referenced this pull request Feb 20, 2023
* main:
  [tests] Bump NUnit versions to latest (dotnet#7802)
  [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803)
jonathanpeppers added a commit that referenced this pull request Feb 21, 2023
grendello added a commit to grendello/xamarin-android that referenced this pull request Feb 22, 2023
* main:
  [tests] Bump NUnit versions to latest (dotnet#7802)
  [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803)
  [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800)
  Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797)
  [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780)
  Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)
grendello added a commit to grendello/xamarin-android that referenced this pull request Feb 22, 2023
* main:
  Add Unit Test for testOnly apps (dotnet#7637)
  [build] Only build the latest API level (dotnet#7786)
  [Xamarin.Android.Build.Tasks] Improve aapt2+file not found handling (dotnet#7644)
  [MSBuildDeviceIntegration] Fix duplicated test parameter (dotnet#7809)
  [tests] Bump NUnit versions to latest (dotnet#7802)
  [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803)
  [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800)
  Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797)
  [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780)
  Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)
grendello added a commit to grendello/xamarin-android that referenced this pull request Feb 22, 2023
* main:
  Add Unit Test for testOnly apps (dotnet#7637)
  [build] Only build the latest API level (dotnet#7786)
  [Xamarin.Android.Build.Tasks] Improve aapt2+file not found handling (dotnet#7644)
  [MSBuildDeviceIntegration] Fix duplicated test parameter (dotnet#7809)
  [tests] Bump NUnit versions to latest (dotnet#7802)
  [Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (dotnet#7803)
  [tests] `InstallAndroidDependenciesTest` can use `platform-tools` 34.0.0 (dotnet#7800)
  Bump to xamarin/Java.Interop/main@9e0a469 (dotnet#7797)
  [Xamarin.Android.Build.Tasks] FileWrites&libraryprojectimports.cache (dotnet#7780)
  Bump to dotnet/installer@d25a3bb 8.0.100-preview.2.23105.6 (dotnet#7769)
  [lgtm] Fix LGTM-reported issues (dotnet#1074)
  [ci] Report issues in the API docs build log (dotnet#7784)
jonathanpeppers added a commit that referenced this pull request Feb 27, 2023
Changes: dotnet/installer@f05478b...e3ab0b5
Changes: dotnet/runtime@fe4760c...ff7c19f
Changes: dotnet/emsdk@fd5a0d1...d7ff0aa

Updates:

* Microsoft.Dotnet.Sdk.Internal: from 8.0.100-preview.2.23107.13 to 8.0.100-preview.2.23123.10
* Microsoft.NET.ILLink.Tasks: from 8.0.0-preview.2.23106.6 to 8.0.0-preview.2.23123.4
* Microsoft.NETCore.App.Ref: from 8.0.0-preview.2.23106.6 to 8.0.0-preview.2.23123.4
* Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100-preview.2: from 8.0.0-preview.2.23081.1 to 8.0.0-preview.2.23113.1

~~ Other changes ~~

* Revert "[Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (#7803)"

This reverts commit 7ba7dd4.

We should be able to build ILLink steps for `net8.0` going forward.

* Add `@(PackageReference)` to `Mono.Cecil`

Context: https://github.com/dotnet/runtime/blob/fb13c2cf6eaf69b53773e94674772f217fa39416/src/coreclr/tools/aot/Mono.Linker.Tests/Mono.Linker.Tests.csproj#L22

`Microsoft.NET.ILLink` no longer has an implicit dependency on `Mono.Cecil`.

* Update BuildReleaseArm64XFormsDotNet.apkdesc

Fixes the failure:

    apkdiff: File 'assemblies/System.Collections.Concurrent.dll' has changed by 1,032 bytes (8.93 %). This exceeds the threshold of 5.00 %

Co-authored-by: Jonathan Peppers <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants