dotnet / dotnet/android

[TrimmableTypeMap] Generate ProGuard for types in type map

Open
#10,790 0 comments 0 reactions 0 assignees View on GitHub
Area: CoreCLR Area: NativeAOT needs-triage trimmable-type-map
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 19h
Merged PRs (30d)
252

Description

Part of https://github.com/dotnet/android/issues/10788

Once the list of types that survived trimming is known, we can generate ProGuard rules to specify which ACW/JCW Java classes we want to keep via the `-keep class jni.class.Name { *; }` rules.

- The build task needs to run _after_ ILLink or ILC and _before_ we run Java trimming (r8).
- This task should run incrementally _only_ when ILLink or ILC produce different typemap.
- This task should not run in Debug at all.

Getting the list of types that are in the typemap might not be trivial at the moment:

- CoreCLR: we can scan the trimmed type map assembly and see which attributes were kept
- Native AOT needs to give us the list of types it kept in the typemap: https://github.com/dotnet/runtime/issues/120204. As a workaround, we can opt into ILC's existing diagnostic outputs (`$(IlcGenerateMetadataLog)` or `$(IlcGenerateDgmlFile)`) but these artifacts are quite large and writing them to disk, reading them from disk, and scanning them will add non-trivial time to the overall build.

Ideally, ILLink and ILC will produce some form of _list_ of types which are included in the typemap, which would allow us to implement a unified build task to generate the proguard rules.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.