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

[linker] Add metadata to linked assemblies indicating the RID for which they were created #8183

Closed
wants to merge 8 commits into from

Conversation

grendello
Copy link
Contributor

As a preparation for future effort to properly support per-RID assemblies, this PR
adds a linker step which appends the AssemblyMetadata custom attribute to each
assembly, with the key XamarinAndroidAbi and its value set to the RID for which
the assembly was linked.

Right now this metadata is not used, but in the future we plan to put all the
assemblies in per-architecture shared libraries, without any exceptions. This will
be done to ensure that unknown changes made to assemblies by the linker will not
break the application at runtime (since the runtime will not verify and complain
about "platform incompatible" assemblies, it doesn't have any notion of such
assemblies)

@grendello grendello marked this pull request as draft July 12, 2023 14:07
@grendello
Copy link
Contributor Author

Converted to draft, because the test failures cannot be fixed without the planned changes to package all assemblies for all RIDs in shared libraries, work that hasn't been started yet.

I'm going to keep this PR open and updated as draft, until the other changes are implemented.

TypeDefinition systemString = GetSystemString (corlib);

var attr = new CustomAttribute (assembly.MainModule.ImportReference (assemblyMetadataAttributeCtor));
attr.ConstructorArguments.Add (new CustomAttributeArgument (systemString, "XamarinAndroidAbi")); // key
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we avoid naming things with an XA or Xamarin prefix? Can this just be RuntimeIdentifier?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RuntimeIdentifier is too generic IMO. XA or XamarinAndroid makes it less likely to clash with other people's metadata

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or AndroidRuntimeIdentifier? I don't think they want us to introduce new things that say Xamarin.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who would know? :)

…Microsoft.Android.Sdk.ILLink.targets

Co-authored-by: Jonathan Peppers <[email protected]>
@grendello grendello marked this pull request as ready for review July 12, 2023 14:20
@grendello
Copy link
Contributor Author

With the change from @jonathanpeppers it can actually go in

* main:
  LLVM IR code generator refactoring and updates (dotnet#8140)
  [ci] XA.PublishAllLogs publishes all build logs to build artifacts (dotnet#8189)
  Bump to xamarin/Java.Interop/main@151b03e (dotnet#8188)
  [Mono.Android] Use PublicApiAnalyzers to ensure we do not break API. (dotnet#8171)
  [Xamarin.Android.Build.Tasks] per-RID assemblies & typemaps (dotnet#8164)
  [AndroidDependenciesTests] Test both manifest types (dotnet#8186)
  [AndroidDependenciesTests] Use platform-tools 34.0.4 (dotnet#8184)
* main: (68 commits)
  Bump to dotnet/installer@2809943e7a 8.0.100-rc.2.23431.5 (dotnet#8317)
  [build] Use Microsoft OpenJDK 17.0.8 (dotnet#8309)
  [Mono.Android] Add missing `[Flags]` attribute for generated enums. (dotnet#8310)
  Bump to dotnet/installer@c5e45fd659 8.0.100-rc.2.23427.4 (dotnet#8305)
  [xaprepare] Improve dotnet-install script logging (dotnet#8312)
  [xaprepare] Fix dotnet-install script size check (dotnet#8311)
  [Xamarin.Android.Build.Tasks] improve net6.0 "out of support" message (dotnet#8307)
  [monodroid] Fix the EnableNativeAnalyzers build (dotnet#8293)
  Bump to dotnet/installer@56d8c6497c 8.0.100-rc.2.23422.31 (dotnet#8291)
  [Xamarin.Android.Build.Tasks] Fix APT2264 error on Windows. (dotnet#8289)
  [Mono.Android] Marshal .NET stack trace to Throwable.getStackTrace() (dotnet#8185)
  [tests] Skip sign check when installing MAUI (dotnet#8288)
  Bump to xamarin/monodroid@057b17fe (dotnet#8286)
  [Xamarin.Android.Build.Tasks] add $(AndroidStripILAfterAOT) (dotnet#8172)
  Bump to dotnet/installer@ec2c1ec1b1 8.0.100-rc.2.23420.6 (dotnet#8281)
  Bump to dotnet/installer@001d8e4465 8.0.100-rc.2.23417.14 (dotnet#8276)
  [Mono.Android] [IntentFilter] pathSuffix & pathAdvancedPattern  (dotnet#8261)
  $(AndroidPackVersionSuffix)=rc.2; net8 is 34.0.0-rc.2 (dotnet#8278)
  Bump to xamarin/xamarin-android-tools/main@52f0866 (dotnet#8241)
  [build] set file extension for common `ToolExe` values (dotnet#8267)
  ...
@grendello grendello closed this Nov 7, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 22, 2024
@grendello grendello deleted the rid-attribute branch March 27, 2024 11:07
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