* Fix Options Source Gen Trimming Issues
* Make Emitted Attribute Order Deterministic in Options Source Generator (#93260)
* Make Emitted Attribute Order Deterministic in Options Source Generator
* Use ordinal comparison when ordering the list
---------
Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com>
* [DependencyInjection] introduce feature switch to disable S.R.E
When recording a new AOT profile for .NET MAUI apps running on Android,
we noticed that System.Reflection.Emit work was being done on a
background thread. The call seen in `dotnet-trace` output:
11.32ms microsoft.extensions.dependencyinjection!Microsoft.Extensions.DependencyInjection.ServiceLookup.ILEmitResolverBuilder.GenerateMethodBody(Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceCallSite,System.Reflection.Emit.ILGenerator)
.NET Android apps are unique in that there is a JIT,
`RuntimeFeature.IsDynamicCodeCompiled` is true, System.Reflection.Emit
is possible -- S.R.E is however, not great for startup performance.
Starting threads on Android during startup can also be slow, as Android
will commonly put all but a single core to sleep for battery saving
purposes. We try to avoid starting threads on startup for "hello world"
applications on Android.
To solve this for now, introduce a new feature flag:
Microsoft.Extensions.DependencyInjection.DisableDynamicEngine
Which, we will provide a value in either the Android or .NET MAUI
optional workload via an MSBuild property. To test, I put this in my
app's `.csproj` file:
<RuntimeHostConfigurationOption Include="Microsoft.Extensions.DependencyInjection.DisableDynamicEngine"
Condition="'$(DisableDynamicEngine)' != ''"
Value="$(DisableDynamicEngine)"
Trim="true" />
Customers *could* opt to change this flag, but we don't think it will
particularly useful. An example of services realized by .NET MAUI at
startup, via some logging added:
08-25 13:21:55.647 16530 16530 I DOTNET : RealizeService called: System.Collections.Generic.IEnumerable`1[Microsoft.Maui.Hosting.IMauiInitializeService]
08-25 13:21:55.664 16530 16530 I DOTNET : RealizeService called: System.Collections.Generic.IEnumerable`1[Microsoft.Maui.Hosting.IMauiInitializeScopedService]
08-25 13:21:55.665 16530 16530 I DOTNET : RealizeService called: Microsoft.Maui.Dispatching.IDispatcher
08-25 13:21:55.668 16530 16530 I DOTNET : RealizeService called: System.Collections.Generic.IEnumerable`1[Microsoft.Maui.LifecycleEvents.LifecycleEventRegistration]
08-25 13:21:56.057 16530 16530 I DOTNET : RealizeService called: System.Collections.Generic.IEnumerable`1[Microsoft.Maui.Hosting.HandlerMauiAppBuilderExtensions+HandlerRegistration]
08-25 13:21:56.115 16530 16530 I DOTNET : RealizeService called: Microsoft.Extensions.DependencyInjection.IServiceScopeFactory
08-25 13:21:56.670 16530 16530 I DOTNET : RealizeService called: Microsoft.Maui.Controls.HideSoftInputOnTappedChangedManager
08-25 13:21:56.712 16530 16530 I DOTNET : RealizeService called: System.Collections.Generic.IEnumerable`1[Microsoft.Maui.Hosting.ImageSourcesMauiAppBuilderExtensions+ImageSourceRegistration]
08-25 13:21:57.700 16530 16530 I DOTNET : RealizeService using S.R.E: Microsoft.Maui.Controls.HideSoftInputOnTappedChangedManager
`HideSoftInputOnTappedChangedManager` would be realized once per page,
which would not be a huge payoff to use S.R.E for. So the only way the
S.R.E codepath could be useful on Android would be if the customer is
registering lots of services themselves. They might be better off just
using `new()` in that case?
An example of the startup time Android reports with the new flag on/off:
DisableDynamicEngine=false
08-25 14:31:37.462 2090 2330 I ActivityTaskManager: Displayed com.companyname.testmaui/crc643c09abdeec717b83.MainActivity: +733ms
08-25 14:31:39.394 2090 2330 I ActivityTaskManager: Displayed com.companyname.testmaui/crc643c09abdeec717b83.MainActivity: +737ms
08-25 14:31:41.326 2090 2330 I ActivityTaskManager: Displayed com.companyname.testmaui/crc643c09abdeec717b83.MainActivity: +730ms
DisableDynamicEngine=true
08-25 14:32:20.233 2090 2330 I ActivityTaskManager: Displayed com.companyname.testmaui/crc643c09abdeec717b83.MainActivity: +724ms
08-25 14:32:22.137 2090 2330 I ActivityTaskManager: Displayed com.companyname.testmaui/crc643c09abdeec717b83.MainActivity: +727ms
08-25 14:32:24.042 2090 2330 I ActivityTaskManager: Displayed com.companyname.testmaui/crc643c09abdeec717b83.MainActivity: +716ms
This was a `dotnet new maui` project, using dotnet/maui/main on a Pixel
5 device.
* Update docs/workflow/trimming/feature-switches.md
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
---------
Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com>
Co-authored-by: Jonathan Peppers <jonathan.peppers@gmail.com>
Co-authored-by: Eric Erhardt <eric.erhardt@microsoft.com>
* Use Roslyn interceptors feature in binder gen
* Fix polymorphic issue and address feedback
* Fix source build issue
* Revert changes to options gen
* Fix
* Work around source build issue
Co-authored-by: Eric StJohn <ericstj@microsoft.com>
---------
Co-authored-by: Layomi Akinrinade <laakinri@microsoft.com>
Co-authored-by: Eric StJohn <ericstj@microsoft.com>
* Limit language version on Logger and Options source gens
* Exclude test in browser
* Address the feedback
* Fix Json test and apply more feedback
* Remove quotes from language versions in source gen diagnostics. (#90720)
---------
Co-authored-by: Tarek Mahmoud Sayed <tarekms@microsoft.com>
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
* Add ILStrip task to wasm app build process
* Make it work for wasm app building workflow
* Interp: stop inlining stripped methods. ILStrip: set code size to zero for tiny methods
* [mono][aot] Avoid adding some methods to the compiled method file.
* Methods which have 'deopt' set can enter the interpreter during EH.
* Methods which have 'interp_entry_only' set are AOTed, but the AOT
code is only used to enter the interpreter.
* Only trim the methods that interpreter is able to call the aot'ed verion of it
* Add default value and documentation for WASMStripIL
* Move jit_call_can_be_supported to interp.c
* Minor format fix
* Add a test
* For testing
* Fix typo
* Skip TestUtilities Reference
* Address review feedback
* Change it to true
* Change name to trimming eligible
* Remove testing
* Address review feedback
* Address review feedback from Kate
* Add a var for llvm_only
---------
Co-authored-by: Zoltan Varga <vargaz@gmail.com>
This PR separates cleaning up caller allocated resources and callee allocated resources into separate stages in the managed to unmanaged direction. Caller allocated parameters (anything except 'out') will clean up the same way. Callee allocated parameters ('out' parameters) will be cleaned up only if the invocation succeeded.
* Calendar WIP.
* Genitive months.
* Short pattern.
* NativeCalendarName does not exist on WebAPI - use EnglishCalendarName.
* Fix failures in Locales caused by calendars data removal.
* Fix to previous commit.
* Whitespace.
* Implemented Eras.
* Populate NativeName with EnglishName.
* Fix tests.
* Typos + comments removal + block failing test.
* AM/PM designators are not in ICU anymore.
* ShortTimePattern is ready.
* Fix some failing tests.
* LongTimePatterns is ready.
* Ask about all culture info from JS at once.
* Fix remaining tests.
* Calendar Globalization tests fixed.
* Adding test files to projects.
* Build fix.
* Fix the fix.
* .
* Fix tests.
* Load locale info on request + fix Browser scenario tests.
* Fix test on v8.
* Forgotten clean-up.
* Small cleanup in ts.
* V8 11 is behaves more like browser.
* Fixed skipped failing tests.
* Syntax
* V8 returns the same as Browser.
* This API is not affected, no need to test. + Add documentation.
* Revert unintentional change.
* Feedback.
* @radical's feedback + fix after removing unnecessary set.
* Fix.
* Feedback.
* Fix tests.
Adds an 'info' level diagnostic if a GeneratedComInterface method returns int, enum, or a type name "HR" or "HResult" to tell the user that the generated code will put the managed return value as an 'out' parameter on the COM definition.
Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
* Remove `AssemblyMetadata(".NETFrameworkAssembly", "")` attributes
This is likely a .NET Native leftover that is currently (ironically) breaking .NET Native. This attribute indicates to the .NET Native compiler that the assembly can be trimmed.
We're currently setting this on assemblies that no longer carry RD.XML to make this safe. Without this attribute, the assembly will be treated like any other and not trimmed.
Fixes#44697.
* Delete mention of the attribute in docs
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* Set the CORINFO_EH_CLAUSE_SAMETRY on CORINFO_EH_CLAUSE
This change makes setting the `CORINFO_EH_CLAUSE_SAMETRY` on
`CORINFO_EH_CLAUSE` to happen for coreclr to. It is a prerequisity for the
port of exception handling from nativeaot to coreclr and it is a noop on
coreclr with the old exception handling.
* Fix comments
* Add clr-abi note and r2rdump support for the flag
* Fix markdown LINT error
* Update docs/design/coreclr/botr/clr-abi.md
* Update docs/design/coreclr/botr/clr-abi.md
* Update the ABI doc
---------
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
* Enable AddressSanitizer in CoreCLR, Libs, and Host and update runtime-sanitized to run tests with ASAN on Linux and Mac
* Unify on HAS_ADDRESS_SANITIZER define name
Centralize setting up sanitizer flags.
Remove last usage of CLR_CMAKE_ENABLE_ASAN outside of eng/native
Remove unnecessary diffs
Use the cpuid intrinsic and enable ASAN on InitJitHelpers1.
Add comments for the places where we have ASAN disabled
Undo changes to src/coreclr/jit/CMakeLists.txt
Add docs and fix the docs in the build script.
Add docs for the SkipVCEnvInit hook
* Remove CRT runtime changes. We won't need this when we finally onboard to Windows with some changes they have coming down the pipeline, so remove them for now to reduce the diff of this PR.
* Remove suppression now that we've fixed the underlying issue.
* Remove some Windows-only sanitizer CMake that we won't need when ASAN is ready for us to consume on Windows.
* Set schedule for runtime-sanitized pipeline
* Remove workaround in JIT memory set/copy helpers now that the JIT bug has been fixed.
* Add missing helix queues setup template.
* Fix missing command to build nativeaot runtime tests as nativeaot.
* Add a scenario name to trigger the extended timeout in the libraries test helix configuration.
* Remove extraneous whitespace.
* Fix using the cross-targetting ILC when sanitizers are enabled. Also pass through our TargetOS and TargetArchitecture variables to the publish command for our native sanitizers targets to correctly do their extra logic.
* Disable LSAN on the CustomMain test.
* Disable some tests on sanitized runtimes.
* Copy the sanitizer runtime for OSX NativeAOT runtime tests.
* A little cleanup to try to get the build right now that we are always doing cross-builds on Linux.
* Fix crossgen-corelib.proj syntax.
* Fix cross-os dac builds to not include the host architecture in the output path.
* Split the debugger components into a separate component and make the "unsanitized cross components" build into an "unsanitized debugger components" build as it can't be part of the regular cross-components build
* Always write out the host-arch path on Windows and update the cross-dac build script to expect that.
* Change to use the dynamic runtime on Windows, as ASAN in VS is moving to a dynamic-only model.
* Update docker images to include the sanitizer runtimes in the crossrootfs images.
* Fix explicit image tags
* The unsanitized build should be of the target architecture, not the host architecture. As a result, we still need a cross-arch build for the cross-arch use cases when sanitized, as well as an unsanitized target arch build for the debugger tools.
* Turn off using the sigaltstack for NativeAOT tests that don't use the asansupport.cpp default options
* Make sure the shared ASAN runtime is present for the nativeaot/SmokeTests/SharedLibrary test.
* Disable crossgen2 tests with sanitizers as they don't get us interesting coverage.
* Fix custom default options and disable some more crossgen2-based tests.
* Simplify lookup of asan runtime on mac and fix copying the shared runtime for the SharedLibrary NativeAOT test.
* Disable test that's failing for weird reasons.
* Fix one more alloc-dealloc mismatch that only started to show up after test merging increased allocations in the runtime
* Disable the System.Text.Json test suite on sanitized builds as it causes SO failures on Mac
* Fix test exclusion
* PR feedback.
* Fix mac build
* Do review changes
* Add libbootstrapper object files to the platform manifest now that NativeAOT has
* Disable tests that check size on sanitized builds
* Use the built-in `include_guard` option
* Disable use-after-return checking in ASAN. CoreCLR doesn't do well with parallel stacks.
* Only pass the no UAR flag on C and CXX with Clang (not AppleClang).
* Relax JsonIncludeAttribute to also support private or internal members.
* Relax JsonConstructorAttribute to include internal or private constructors (where applicable).
* Let's see what happens :)
* CMake 3.20 works on my machine???
* Upped the llibraries CMake version to 3.20
* Upped native libs CMake version to 3.20, and updated the requirements docs.
* Add CMake Policy to 3.17.0 for native libs because of wasm.
* Downgraded native libs CMake to 3.17.0 temporarily, while we figure out the funny troublemaker wasm.
* Added a couple notes regarding CMake on Linux and Windows, and upped the corehost and libunwind CMake versions to 3.20
* Reverted external native components CMake versions, and upped tests to 3.20. Only Mono remains now.
* Added mono to the 3.20 gang. Also, changed the condition for wasm.
* Had to condition mono's CMake version as well because of wasm.
* DEBUG-ONLY COMMIT: Added some CMake logging to help me figure out what is set for wasm to think of the appropriate conditional.
* DEBUG-ONLY COMMIT: I think I have the answer for wasm now/
* Restored the DEBUG-ONLY changes and set 3.20 as the universal CMake, as the missing machines have now been updated.
* Updated requirements doc with notes for Debian 11 and lower.
* Use analyzers from targeting pack for NetCoreAppCurrent
Fixes that analyzer failures didn't show-up in #74897
Add analyzers to the frameworklist that OOB projects in src/libraries
use, and only auto ProjectReference the analyzers in generators.targets
when not using the analyzers from the targeting pack.
Also move the generator projects related code into a separate file.
Continuation of https://github.com/dotnet/runtime/pull/75093
* Fix project build
* Add missing reference to Regex tests
* Add missing generators for netfx build
* Fix paht in test project
* Fix typo
* Disable runtime marshalling for SharedTypes.csproj
* Disable runtime marshalling for NativeExports.csproj
* CoreCLR and NativeAOT
* Add UnsafeAccessorAttribute API
* Implement IL generation for all accessor paths
* Implement static/instance field lookup - non-generic
* Implement static/instance method lookup - non-generic
* Defined ambiguity logic with respect to
custom modifiers.
- First pass ignore custom modifiers
- If ambiguity detected, rerun algorithm but
require precise matching of custom modifiers.
- If there is no clear match throw AmbiguousImplementationException.
* Cleanup memory management confusion
with ILStubResolver.
* Fix non-standard C++
* Remove CORINFO_MODULE_ALLACCESS scope
* Remove enum METHOD_TYPE.
* Update BOTR on TypeDesc
* Skip type validation by default in ReadyToRun images
- Technically, this is a breaking change, so I've provided a means for disabling the type validation skip
- The model is that the C# compile won't get these details wrong, so disable the checks when run through crossgen2. The idea is that we'll get these things checked during normal, non-R2R usage of the app, and publish won't check these details.
* Replace expensive lookups of generic parameter and nested class data with R2R optimized forms
* Store index of MethodDesc as well as ChunkIndex. Makes MethodDesc::GetTemporaryEntryPoint *much* faster
* Optimize the path for computing if a method is eligible for tiered compilation
* Remove CanShareVtableChunksFrom concept
- it was only needed to support NGen
* Fix up some more issues
* Bring back late virtual propagation in the presence of covariant overrides only
* Check correct flag on EEClass
* Drive by fix for GetRestoredSlot. We don't need the handling of unrestored slots anymore
* Fix composite build with new tables
* Uniquify the mangled names
* Add more __
* Initial pass at type skip verifation checker
* Fix logging and some correctness issues
* Enable the more of type checking
- Notably, the recursive stuff now works
- Also fix a bug in constraint checking involving open types in the type system
* Fix build breaks involving new feature of GenericParameterDesc
* Add documentation for R2R format changes
Fix command line parameter to be more reasonable, and allow logging on command
Fix the rest of issues noted in crossgen2 testing
* Fix implementation of CompareMethodContraints. instead of using IsGeneric map, check to see if the method is generic in the first place. It turns out we have an efficient way to check in every place that matters
* Fix nits noticed by Aaron
* Add some const correctness to the world
* Fix issues noted by Michal, as well as remaining constrain checking issues
* Code review details
* Code review from trylek