Skip to content

Commit

Permalink
Don't apply optimization on non-AOT builds, e.g. simulators, since some
Browse files Browse the repository at this point in the history
features (like XML serialization) checks for
`RuntimeFeature.IsDynamicCodeSupported` and that requires some types
to be subclassed thru SRE
  • Loading branch information
Sebastien Pouliot committed Aug 9, 2021
1 parent f72f113 commit 1a560c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@
<_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --disable-opt unusedtypechecks</_ExtraTrimmerArgs>

<!-- If a release build and the app is not extensible (no interpreter or JIT/code-loading for macOS) then the sealer optimization can be used -->
<_ExtraTrimmerArgs Condition="'$(_BundlerDebug)' != 'true' And '$(MtouchInterpreter)' == '' And '$(_PlatformName)' != 'macOS'">$(_ExtraTrimmerArgs) --enable-opt sealer</_ExtraTrimmerArgs>
<_ExtraTrimmerArgs Condition="'$(_BundlerDebug)' != 'true' And '$(MtouchInterpreter)' == '' And '$(_RunAotCompiler)' == 'true' And '$(_PlatformName)' != 'macOS'">$(_ExtraTrimmerArgs) --enable-opt sealer</_ExtraTrimmerArgs>

<!-- We always want the linker to process debug symbols, even when building in Release mode, because the AOT compiler uses the managed debug symbols to output DWARF debugging symbols -->
<TrimmerRemoveSymbols Condition="'$(TrimmerRemoveSymbols)' == ''">false</TrimmerRemoveSymbols>
Expand Down
11 changes: 11 additions & 0 deletions tests/linker/ios/link all/SealerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,17 @@ public class Subclass : Base, Interface {
[Preserve (AllMembers = true)]
public class SealerTest {

#if NET
[SetUp]
public void SetUp ()
{
// XML serialization mechanism is controlled by RuntimeFeature.IsDynamicCodeSupported
// which will be true for simulator / JIT builds
// so the optimization is disabled unless AOT is used
TestRuntime.AssertDevice ();
}
#endif

[Test]
public void Sealed ()
{
Expand Down

0 comments on commit 1a560c7

Please sign in to comment.