-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
ifdef out unsupported Enum underlying types for nativeaot #79472
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
ddb4086
to
92158a9
Compare
92158a9
to
d43c9c7
Compare
It looks fine to me. I would make a new #define for it at the top of the file to make it more self-documenting. We may want to enable the define on other targets where we care a lot about size a lot, like wasm. Thank you for looking for ways to fix the size regression! |
19fc751
to
7d8e2ac
Compare
@@ -1,6 +1,11 @@ | |||
// Licensed to the .NET Foundation under one or more agreements. | |||
// The .NET Foundation licenses this file to you under the MIT license. | |||
|
|||
// Rare enums types not expressible in C# are not supported in native AOT | |||
#if !NATIVEAOT | |||
#define RARE_ENUMS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SamMonoRT @kotlarmilos should this also include all mobile/web targets?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if we can include the mobile/web targets to mitigate the app size regressions, we should include those now, till we are able to identify and fix the Mono AOT compiler limitations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have pushed a commit to disable the rare enums support for Mono as well. Please take a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've inspected native symbols of an iOS app and non-integral types except bool
are supported in the Mono AOT engine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I am going to keep the rare enums enabled for Mono. I do not data to make the call on whether to disable it for Mono or not. It can be done later - it is two line change to enable/disable this for given config.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, leave it enabled for now. We can run some measurements and see if it helps in size if we disable it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look to me like breaking change - by doing that we will restrict some theoretical or borderline cases. I would suggest excluding them as they are not expressible in C# and such change could mitigate the size regression. Some edge cases might fail where non-integral enums are created by using reflection, which is not recommended by the documentation.
Let's hear the other opinions as well. If it is a blocker, we can proceed and update it once we align.
@MichalStrehovsky PTLA This fixes some of the size regression by ifdefing out support for rare enums, to match what we used to do in native AOT before the recent Enum changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, although I've always been puzzled by our position on these. We care, but also we don't care.
I'd honestly just delete the reflection support for these and keep things simple, because it's either important and it was a bug that CoreCLR-AOT didn't have this, or it's not important and people won't miss it on CoreCLR-JIT either. (Unless there's something unique for CoreCLR-JIT, like C++/CLI support, that makes it needed there.)
Do we need a breaking change label for Mono?
Yes, C++/CLI support, obfuscated code and compat for niche languages. e.g. this compiles fine in C++/CLI:
|
@SamMonoRT How would like to handle that? |
This example is fine actually. C++/CLI will lower the underlying type to int32/int64. A better example:
|
Adding @lambdageek and @vargaz for their opinion. |
All known errors according to the build analysis. |
@jkotas, worthwhile?
Contributes to #79437