Граф коммитов

894 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 15e437aad3
[net8.0] Merge main into net8.0. (#19023) 2023-09-14 12:35:47 +02:00
Rolf Bjarne Kvinge 65f275b842
[dotnet] Load the current, not latest, sdk for the error logic in WorkloadManifest.targets. (#19011)
We might actually support a newer OS version than the one we're building for,
if we're supporting a preview version in a stable release. In this case, we
need to make sure to load the correct sdk when we run into errors, so that we
show the correct error messages.

Fixes this test failure:

    Xamarin.Tests.DotNetProjectTest.InvalidTargetPlatformVersion(MacCatalyst): Error message
    Expected string length 92 but was 87. Strings differ at index 84.
    Expected: "...ormVersion for MacCatalyst. Valid versions include:\n16.4\n17.0"
    But was: "...ormVersion for MacCatalyst. Valid versions include:\n17.0"
2023-09-14 10:15:02 +02:00
Rolf Bjarne Kvinge be6c348cfd [net8.0-xcode15] Merge net8.0 into net8.0-xcode15. 2023-09-14 07:25:58 +02:00
Rolf Bjarne Kvinge f88dc4406d [net8.0] Merge main into net8.0. 2023-09-14 07:23:52 +02:00
Rolf Bjarne Kvinge c901665f34
[net8.0] [devops] Fix boolean logic + update .NET files to sign (#18988)
* Fix boolean logic to determine whether .NET is enabled or not
* Update mlaunch to get a fix where we trim the project.
* Update the list of files that need to be signed from mlaunch.
2023-09-11 18:56:47 +02:00
Rolf Bjarne Kvinge ea8ad15db0
[dotnet] Copy the pdb for our platform assemblies to the app bundle. Fixes #11879. (#18970)
Copy the pdb for our platform assembly to the app bundle if we're in
Debug mode.

Fixes https://github.com/xamarin/xamarin-macios/issues/11879.
2023-09-11 18:36:59 +02:00
Rolf Bjarne Kvinge 9d8962c06c [net8.0] Merge main into net8.0. 2023-09-11 10:31:07 +02:00
Rolf Bjarne Kvinge de762d67cc
[dotnet] Point app extensions to any frameworks in the root app bundle. Fixes #17876. (#18913)
Put any frameworks in app extensions in the Frameworks directory in the
containing app bundle. This saves a lot of space if the same framework is used
in both an app extension and the containing project (or multiple app
extensions).

Fixes https://github.com/xamarin/xamarin-macios/issues/17876.
Fixes https://github.com/xamarin/xamarin-macios/issues/17679.
2023-09-11 09:52:54 +02:00
Rolf Bjarne Kvinge b44b57e59d
[dotnet] Make bundling the 'createdump' utility opt-in. Fixes #16189. (#18960)
Make bundling the 'createdump' utility opt-in by setting BundleCreateDump=true.

Fixes: https://github.com/xamarin/xamarin-macios/issues/16189
2023-09-11 09:52:14 +02:00
Ivan Povazan bf77022512
Simplify icudat file lookup by specifying ICU_DAT_FILE_PATH as a RuntimeHostConfigurationOption (#18914)
Fixes https://github.com/xamarin/xamarin-macios/issues/18471
2023-09-08 16:46:32 +02:00
Rolf Bjarne Kvinge 673dd5782b [net8.0-xcode15] Merge net8.0 into net8.0-xcode15. 2023-09-08 10:31:44 +02:00
Šimon Rozsíval aef2c916e9
[NativeAOT] Do not root platform assembly (#18885)
Closes #18779

Based on testing several MAUI samples, there doesn't seem to be a reason
to root the whole platform assembly anymore.
2023-09-07 08:13:02 +02:00
Rolf Bjarne Kvinge 42f523812f [dotnet] Add support for multi-targeting. 2023-09-06 11:32:54 +02:00
Rolf Bjarne Kvinge 19f30a1f06 [dotnet] Rename packs to contain target framework. 2023-09-06 11:29:16 +02:00
Rolf Bjarne Kvinge b3c869080e
Merge branch 'net8.0' into new-find-icu-data 2023-09-05 08:48:37 +02:00
Rolf Bjarne Kvinge 50071c37c9
[NativeAOT] Don't publish any *.o files that comes from NativeAOT. (#18904)
If anything we're supposed to link with *.o files, not publish them, but
since we're currently not handling any *.o files, just explicitly remove them
from the build. This avoids a warning where ComputeBundleLocation would issue
a warning about not knowing what to do with them.

Contributes towards https://github.com/xamarin/xamarin-macios/issues/18629.

---------

Co-authored-by: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com>
2023-09-05 08:07:19 +02:00
Ivan Povazan ed26faa94f Simplify icudat file lookup by specifying ICU_DAT_FILE_PATH as a RuntimeHostConfigurationOption 2023-09-01 18:50:55 +02:00
Rolf Bjarne Kvinge 4f26004591
[dotnet] Pass path to native swift libraries when linking NativeAOT apps for macOS. (#18894)
Fixes this linker failure when compiling monotouch-test:

    clang: error: linker command failed with exit code 1 (use -v to see invocation)
        Errors
            xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.2.23428.11/packs/Microsoft.macOS.Sdk/13.3.8852-net8-rc2/targets/Xamarin.Shared.Sdk.targets(1527,3): clang++ exited with code 1:
    ld: library not found for -lswiftCore
    clang: error: linker command failed with exit code 1 (use -v to see invocation) [/Users/rolf/work/maccore/net8.0/xamarin-macios/tests/dotnet/MySimpleApp/macOS/MySimpleApp.csproj]
2023-09-01 10:55:59 +02:00
Rolf Bjarne Kvinge ef408d24a9 [net8.0-xcode15] Merge net8.0 into net8.0-xcode15. 2023-08-29 11:53:41 +02:00
Rolf Bjarne Kvinge 78b649c4e1 [net8.0] Merge main into net8.0. 2023-08-29 11:24:40 +02:00
Rolf Bjarne Kvinge 45225dc88d
[dotnet] Parameterize the pack names. (#18732)
We're going to change the pack names to support multi-targeting, so ahead
of the pack name change I'm changing the existing logic to use a variable
for the pack name in most places (this will make the rename much easier and
simpler).

These changes should have no effect by themselves.
2023-08-29 10:06:46 +02:00
Rolf Bjarne Kvinge ed4d4ff028
[dotnet] Always pass -lobjc to the native linker. (#18845)
In some cases ld will crash otherwise:

    0  0x102a1871c  __assert_rtn + 140
    1  0x102a21688  ld::tool::SymbolTableAtom<arm64>::classicOrdinalForProxy(ld::Atom const*) (.cold.3) + 0
    2  0x10291daf8  ld::tool::SymbolTableAtom<arm64>::classicOrdinalForProxy(ld::Atom const*) + 248
    3  0x10291d15c  ld::tool::SymbolTableAtom<arm64>::addImport(ld::Atom const*, ld::tool::StringPoolAtom*) + 204
    4  0x10291c824  ld::tool::SymbolTableAtom<arm64>::encode() + 416
    5  0x102907b6c  ___ZN2ld4tool10OutputFile20buildLINKEDITContentERNS_8InternalE_block_invoke.387 + 36
    6  0x185df2874  _dispatch_call_block_and_release + 32
    7  0x185df4400  _dispatch_client_callout + 20
    8  0x185e060c8  _dispatch_root_queue_drain + 956
    9  0x185e066c0  _dispatch_worker_thread2 + 164
    10  0x185fa0038  _pthread_wqthread + 228
    A linker snapshot was created at:
    	/tmp/tesrt-2023-08-28-143541.ld-snapshot
    ld: Assertion failed: (it != _dylibToOrdinal.end()), function dylibToOrdinal, file OutputFile.cpp, line 5133.
2023-08-29 07:28:47 +02:00
Rolf Bjarne Kvinge 645ce96798 [net8.0] Merge main into net8.0. 2023-08-28 18:16:00 +02:00
dustin-wojciechowski 1b016fa072
[MacCatalyst] Added Default Entitlements for MacCatalyst projects (#18669)
Added default entitlements for MacCatalyst templates.
For Debug, the com.apple.security.get-task-allow entitlement that allows for using developer tools when developing MAUI Blazor apps.
For release, com.apple.security.app-sandbox is required to publish MacCatalyst apps to the Mac App Store.

Also added unit test to check for entitlements when project is created.

Fixes #18344

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-08-28 09:14:25 -07:00
Filip Navara 88b009288d
Improve consumption of NativeAOT linker flags (#18835)
Fixes #18819
2023-08-28 12:17:09 +02:00
Rolf Bjarne Kvinge 7d5e1a4e7e [net8.0-xcode15] Merge net8.0 into net8.0-xcode15. 2023-08-23 17:35:17 +02:00
Rolf Bjarne Kvinge 640ff3fa71 [net8.0] Merge main into net8.0. 2023-08-22 15:22:11 +02:00
Rolf Bjarne Kvinge 2091e09592
[net8.0] Merge main into net8.0 (#18770) 2023-08-22 15:19:06 +02:00
Rolf Bjarne Kvinge c024223ca9
[dotnet] Make 'Full' the default link mode for NativeAOT. (#18734)
Make 'Full' the default link mode for all platforms for NativeAOT because:

* It will achieve the best app size.
* NativeAOT is not a drop-in replacement that's guaranteed to work - there are
  already known features NativeAOT don't support (and may never support), so
  this may be an opportunity for app developers (and component vendors) to
  make their products trimmer safe.
* NativeAOT will be in preview in .NET 8, so we can change our mind later if
  it turns out to cause too many problems.
* In some cases NativeAOT might require trimming, because we may
  optimize/rewrite assemblies to be NativeAOT-compatible to support existing
  libraries.

This requires #18666 to be merged first, so that ests aren't linked away.
2023-08-22 12:46:53 +02:00
Ivan Povazan fa06001335
Use RuntimeHostConfigurationOption for ObjCRuntime features (#18763)
This PR unifies the way `ObjCRuntime` features are passed to trimming
tools by using `RuntimeHostConfigurationOption`.

---
Fixes: https://github.com/xamarin/xamarin-macios/issues/18483
2023-08-21 10:57:52 +02:00
Rolf Bjarne Kvinge 19b2b3744f
[NativeAOT] Add support for [Preserve] attributes (#18666)
Add partial support for the `[Preserve]` attribute for NativeAOT. This
is done by injecting an equivalent `[DynamicDependency]` attribute. The
partial support comes from the fact that there's no way to map a
conditional preserve attribute (`[Preserve (Conditional = true)]`) to a
`[DynamicDependency]` attribute, so we report a warning instead.

For non-conditional `[Preserve]` attributes, we'll now add a
`[DynamicDependency]` attribute to the assembly's module constructor for
the type/member in question, effectively rooting it.

This makes it possible to fully link all our test suites when NativeAOT
(otherwise NativeAOT would just link out all the tests, leaving the test
suites empty - and unfortunately green, so this was a rather accidental
discovery).
2023-08-18 16:49:47 +02:00
Rolf Bjarne Kvinge 067e32a289
[dotnet] Update the Mac Catalyst VB template to match the C# template. (#18754) 2023-08-18 16:49:18 +02:00
Rolf Bjarne Kvinge d64f3d5e30
[dotnet] Fix typo when loading support for App Extensions on Mac Catalyst. (#18755)
Ref: https://github.com/xamarin/xamarin-macios/issues/17408
2023-08-18 16:48:51 +02:00
Ivan Povazan 90cc165def
NativeAOT: Do not suppress trim warnings by default with NativeAOT (#18759)
This PR enables trim warnings with NativeAOT by default.

In our current ILLink+ILC setup, we first need to suppress the warnings for ILLink, after which we need to enable them for ILC. 
For this reason, setting up `SuppressTrimAnalysisWarnings` properly needs to happen very early as it will get overwritten by 45acd380b3/src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets (L54-L59) 

Verified with building an iOS application that the trim warnings are displayed only during ILC trimming (after `Generating native code` message below):
```                 
../dotnet publish -c Release -r ios-arm64 -bl /p:PublishAot=true /p:PublishAotUsingRuntimePack=true
MSBuild version 17.7.0+5785ed5c2 for .NET
  Determining projects to restore...
  Restored /Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj (in 127 ms).
/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/sdk/8.0.100-rc.1.23415.19/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.RuntimeIdentifierInference.targets(311,5): message NETSDK1057: You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
  Detected signing identity:
          
    Code Signing Key: "Apple Development: Ivan Povazan (53PXX466YZ)" (3CC7B9372E3BB19DEBECBA95A6AF3E0EB26C5B29)
    Provisioning Profile: "iOS Team Provisioning Profile: *" (6e598984-dd21-4632-b707-72cfa247991d)
    Bundle Id: com.companyname.TrimTest
    App Id: SGGM6D27TK.com.companyname.TrimTest
  TrimTest -> /Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/bin/Release/net8.0-ios/ios-arm64/TrimTest.dll
/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/packs/Microsoft.iOS.Sdk/16.4.8777-ci.trim-warn/targets/Xamarin.Shared.Sdk.targets(1826,3): warning : The file '/Users/ivan/repos/xamarin/xamarin-macios/packages/microsoft.netcore.app.runtime.nativeaot.ios-arm64/8.0.0-rc.1.23414.4/runtimes/ios-arm64/native/libbootstrapper.o' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/packs/Microsoft.iOS.Sdk/16.4.8777-ci.trim-warn/targets/Xamarin.Shared.Sdk.targets(1826,3): warning : The file '/Users/ivan/repos/xamarin/xamarin-macios/packages/microsoft.netcore.app.runtime.nativeaot.ios-arm64/8.0.0-rc.1.23414.4/runtimes/ios-arm64/native/libbootstrapperdll.o' does not specify a 'PublishFolderType' metadata, and a default value could not be calculated. The file will not be copied to the app bundle. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/packs/Microsoft.iOS.Sdk/16.4.8777-ci.trim-warn/targets/Xamarin.Shared.Sdk.targets(536,3): warning : All assemblies must be processed by the linker when using NativeAOT. Please don't set neither the 'MtouchLink' nor the 'TrimMode' property, so that the build can default to linking all assemblies. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
  Optimizing assemblies for size may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
  Optimizing assemblies for size. This process might take a while.
  Generating native code
resource ILLink.LinkAttributes.xml in System.Private.CoreLib(335,8): warning IL2049: System.Private.CoreLib: The internal attribute name 'RemoveAttributeInstances' being used in the xml is not supported by ILLink, check the spelling and the supported internal attributes. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
resource ILLink.LinkAttributes.xml in System.Private.CoreLib(342,8): warning IL2049: System.Private.CoreLib: The internal attribute name 'RemoveAttributeInstances' being used in the xml is not supported by ILLink, check the spelling and the supported internal attributes. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
resource ILLink.LinkAttributes.xml in System.Private.CoreLib(349,8): warning IL2049: System.Private.CoreLib: The internal attribute name 'RemoveAttributeInstances' being used in the xml is not supported by ILLink, check the spelling and the supported internal attributes. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
resource ILLink.LinkAttributes.xml in System.Private.CoreLib(356,8): warning IL2049: System.Private.CoreLib: The internal attribute name 'RemoveAttributeInstances' being used in the xml is not supported by ILLink, check the spelling and the supported internal attributes. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
resource ILLink.LinkAttributes.xml in System.Private.CoreLib(363,8): warning IL2049: System.Private.CoreLib: The internal attribute name 'RemoveAttributeInstances' being used in the xml is not supported by ILLink, check the spelling and the supported internal attributes. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
resource ILLink.LinkAttributes.xml in System.Private.CoreLib(370,8): warning IL2049: System.Private.CoreLib: The internal attribute name 'RemoveAttributeInstances' being used in the xml is not supported by ILLink, check the spelling and the supported internal attributes. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
/Users/ivan/repos/xamarin/xamarin-macios/src/ObjCRuntime/Runtime.CoreCLR.cs(171): Trim analysis warning IL2026: ObjCRuntime.Runtime.ResolvingEventHandler(AssemblyLoadContext,AssemblyName): Using member 'System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
/Users/ivan/repos/xamarin/xamarin-macios/src/ObjCRuntime/Runtime.CoreCLR.cs(267): Trim analysis warning IL2026: ObjCRuntime.Runtime.FindAssembly(IntPtr): Using member 'System.Reflection.Assembly.LoadFrom(String)' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/obj/Release/net8.0-ios/ios-arm64/linked/Microsoft.iOS.dll : warning IL3053: Assembly 'Microsoft.iOS' produced AOT analysis warnings. [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/obj/Release/net8.0-ios/ios-arm64/linked/Microsoft.iOS.dll : warning IL2104: Assembly 'Microsoft.iOS' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries [/Users/ivan/repos/xamarin/xamarin-macios/builds/downloads/dotnet-sdk-8.0.100-rc.1.23415.19/TrimTest/TrimTest.csproj]
  Created the package: bin/Release/net8.0-ios/ios-arm64/publish//TrimTest.ipa
```

---
Fixes: https://github.com/xamarin/xamarin-macios/issues/18571

---------

Co-authored-by: Ivan Povazan <ivan.povazan@gmail.com>
2023-08-18 16:04:00 +02:00
Ivan Povazan 51786a2253 Use RuntimeHostConfigurationOption for ObjCRuntime features 2023-08-18 12:14:33 +02:00
Ivan Povazan 1f7de4ab29 Revert "[dotnet] Use a different min OS version when building with NativeAOT."
This reverts commit 6b3d62b84d78ea2a94b3de578fa78318a9524421.
2023-08-17 17:43:09 +02:00
Rolf Bjarne Kvinge aa8d2a962e
[dotnet] Fix assembly stripping of resource assemblies. Fixes #17262. (#18749)
* Don't strip resource assemblies, there's no code in them to strip anyways.
* Use the relative path inside the app bundle when computing the intermediate
  location for stripped assemblies, so that if we were to find two identically
  named assemblies in different directories, they're handled correctly (by
  putting them in different intermediate locations, instead of overwriting
  eachother).

Fixes https://github.com/xamarin/xamarin-macios/issues/17262.
2023-08-17 07:34:14 +02:00
Rolf Bjarne Kvinge 8bb54d360f [net8.0-xcode15] Merge net8.0 into net8.0-xcode15. 2023-08-16 11:21:06 +02:00
Rolf Bjarne Kvinge c8ae3dc072 [net8.0] Merge main into net8.0. 2023-08-16 11:19:56 +02:00
Filip Navara b4975e2493
Fix non-NativeAOT builds with PublishAot=true in the project file (#18727)
The gist is:
- If you enable `<PublishAot>true</PublishAot>` then the NativeAOT build targets get included.
- Unless `NativeCompilationDuringPublish` is disabled, the NativeAOT targets are chained through `BeforeTargets` attribute to some publish targets (computing the resolved publish paths). Xamarin runs those publish targets even for non-publish builds, so it brings the whole ILC compilation along. That's undesirable.
- The `RunILLink` property is set unconditionally by the NativeAOT build integration. If we don't fix it then ILLink never runs, and neither do all the custom steps to generate registrars and `main()`.

Update: Apparently, we still need to fix runtime pack resolution for iOS-like platforms with `PublishAotUsingRuntimePack=true`.

---------

Co-authored-by: Filip Navara <navara@emclient.com>
2023-08-16 11:04:33 +02:00
Mauro Agnoletti b313a59fbe
[remote] Explicitly import .mobile.props file (#18718)
The .mobile.props file is a file created and written by the mobile VS
extension to store property values that needs to be read early enough in
the build chain, as in design time builds, and that can't be set by CPS
because of a limitation in the project system. See more information
here: https://github.com/xamarin/XamarinVS/pull/13606

Initially it was named .user.env file and then was renamed in another PR
as part of a feedback from the project system team. See more information
here: https://github.com/xamarin/XamarinVS/pull/13628

Because this file was saved in the intermediate output path, it was
meant to be imported automatically by MSBuild, however we recently
detected that this was not happening reliably. Because of this, some
things like C# Hot Reload for iOS stopped working because Roslyn was
reading incorrect values from the Design Time Builds.

For that reason and to avoid relying on the project system, I'm
importing this file explicitly (and removing old .user.env import), so
the values in the file are always available and the dependent properties
are calculated correctly and available for all the consumers (including
Roslyn).

This should fix the following bugs:

https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1822041
https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1851677
2023-08-15 08:33:53 +02:00
Rolf Bjarne Kvinge b7a7b4d1d2 Merge remote-tracking branch 'origin/net8.0' into bump-main-in-net8.0-2023-08-14 2023-08-15 08:27:14 +02:00
Rolf Bjarne Kvinge f8b7b5326c
[dotnet] Enable the reflection-based json serializer by default. Fixes #18057. (#18710)
Fixes https://github.com/xamarin/xamarin-macios/issues/18057.
2023-08-15 08:19:50 +02:00
Rolf Bjarne Kvinge 7988d051ee
[net8.0-xcode15] [tools] Improve enforcement of the classic linker. (#18719)
* Only ask for the classic linker if we're using Xcode 15+.
* Implement a way out of the enforcing the classic linker.
2023-08-15 08:19:20 +02:00
Rolf Bjarne Kvinge ac90c511d1 [net8.0] Merge main into net8.0. 2023-08-14 15:36:54 +02:00
Rolf Bjarne Kvinge 24895406b2
[dotnet] Link Mono and Xamarin statically in Mac Catalyst by default. Fixes #14686. (#18619)
It's possible to create a provisioning profile for Mac Catalyst that
doesn't allow dylibs in the app. It seems a significant number of people run
into this problem when publishing their apps, so avoid it by linking Mono and
Xamarin statically by default instead.

The downside is that build time might increase a little bit.

An upside however is that the app size might decrease somewhat.

Fixes https://github.com/xamarin/xamarin-macios/issues/14686.
2023-08-11 15:08:27 +02:00
Rolf Bjarne Kvinge b17626ff1c
[msbuild] Re-aot referencing assemblies. Fixes #17708. (#18509)
If an assembly changes, then we must AOT compile that assembly again (which we already
did), in addition to any assembly that references the modified assembly (which we
didn't do).

So rework the AOTCompile target: remove the Inputs and Outputs (because the dependency
tracking is too complicated for MSBuild to resolve), and instead move the logic to
detect if an assembly must be AOT-compiled again into the AOTCompile task.

Note that this PR has a custom port to .NET 8: #18518.

Fixes https://github.com/xamarin/xamarin-macios/issues/17708.

---------

Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-08-07 20:19:30 +02:00
Rolf Bjarne Kvinge 64077229cb
[net8.0] [msbuild] Re-aot referencing assemblies. Fixes #17708. (#18518)
If an assembly changes, then we must AOT compile that assembly again (which we already
did), in addition to any assembly that references the modified assembly (which we
didn't do).

So rework the AOTCompile target: remove the Inputs and Outputs (because the dependency
tracking is too complicated for MSBuild to resolve), and instead move the logic to
detect if an assembly must be AOT-compiled again into the AOTCompile task.

This is a port of the [original fix for main][1] to .NET 8, where we have to
take the dedup assembly into account too: if any assembly has changed, then we
must re-aot the dedup assembly as well.

Fixes https://github.com/xamarin/xamarin-macios/issues/17708.

[1]: https://github.com/xamarin/xamarin-macios/pull/18509

---------

Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-08-07 20:19:08 +02:00
Rolf Bjarne Kvinge a33c80d6c7
[net8.0] Change the default RuntimeIdentifier. (#18495)
* When publishing a mobile app, choose a device architecture (as opposed
  to showing an error if none was specified by the developer)
* When building for the simulator, choose the arm64 runtime identifier
  if we're running on an arm64 machine.
* When building a Debug build for desktop, choose the arm64 runtime
  identifier if we're running on an arm64 machine.

Fixes https://github.com/xamarin/xamarin-macios/issues/18455.
Fixes https://github.com/xamarin/xamarin-macios/issues/16152.
Fixes https://github.com/xamarin/xamarin-macios/issues/17841.

Section in the release notes: https://github.com/xamarin/xamarin-macios/wiki/.NET-8-release-notes#default-runtimeidentifiers

---------

Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-08-07 17:51:37 +02:00
Ivan Povazan 2918781812 Merge remote-tracking branch 'upstream/net8.0' into feature-switch-disable-dynamic-code 2023-08-04 10:20:55 +02:00
Ivan Povazan 15c35b4366
Inlcude maccatalyst when specifying DynamicCodeSupport=false, exclude watchOS as it is not supported on dotnet
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-08-03 10:55:44 +02:00
Peter Collins 72811eb753
[ci] Run Codesign Verification after MSI creation (#18603)
The `MicroBuildCodesignVerify@3` task has been added to validate the
signing status of the MSI files required for VS insertions. This will
allow us to identify any potential signing issues earlier.
2023-08-01 23:53:20 -04:00
Filip Navara 53ff85f67c
[NativeAOT] Remove IlcKeepManagedDebuggerSupport workaround (#18515)
Fixes #18478

Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-08-01 16:05:35 +02:00
Ivan Povazan 6abece9c94 Set DynamicCodeSupport=false to enable trimming for platforms which do not support dynamic code 2023-07-26 17:40:05 +02:00
Peter Collins 44001edebb
[vs-workload] Set EnableSideBySideManifests=true (#18554)
Context: https://github.com/xamarin/yaml-templates/pull/274

Enables side by side workload manifest support when generating workload
MSIs.

This should only be enabled for builds shipping with .NET 8 Preview 7 or
later.

Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-07-25 13:47:20 -04:00
Filip Navara d635e6d597
Fix _DefaultLinkMode for NativeAOT. (#18560)
Alternative to #18530, see
https://github.com/xamarin/xamarin-macios/pull/18530#discussion_r1258565808
Contributes to #18482
2023-07-20 11:11:29 -04:00
Ivan Povazan b68efbed4a
NativeAOT: Disable AggressiveAttributeTrimming with ILLink (#18545)
In the current setup with NativeAOT, during app build we run both ILLink
and ILCompiler in cascade.
When `_AggressiveAttributeTrimming` feature switch is set to `true`
ILLink removes `IsTrimmable` attribute from assemblies, which means that
when we are also running in `TrimMode=partial` (which translates to
`--defaultrooting` ILC command-line arguments) ILC trimming is disabled
completely.

This PR disables `_AggressiveAttributeTrimming` in the first pass ie
during trimming by ILLink and enables it in the second trimming pass
performed by ILCompiler.

Additionally, to workaround ILCompiler incompatibility with
`Microsoft.iOS` (and friends) this platform assembly is explicitly
rooted when passed to ILCompiler for trimming (this will be fixed once
https://github.com/dotnet/runtime/issues/86649 is resolved).

Estimated savings: This change reduces the size of the application
bundle by `0,58Mb` (or ~4,3% compared to the baseline)

| MAUI ios app | Base | This PR | diff (%) |
|--------------|-----------|-----------|----------|
| SOD (Mb)     | 41,93 | 40,5      | -3,4% |
| .ipa (Mb)    | 13,43  | 12,85    | -4,3% |


Fixes: https://github.com/xamarin/xamarin-macios/issues/18479

---------

Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-07-17 09:26:01 -04:00
Ivan Povazan bcb8e5cfd3
Exclude assemblies from NativeAOT app bundles (#18532)
Since NativeAOT generates native libraries and executables that do not
rely on assemblies they were compiled from, all managed assemblies can
be excluded from the application bundle.

This reduces the size of the application bundle by `3,17Mb` (or ~19%
compared to the baseline)

| MAUI ios app | Base | This PR | diff (%) |
|--------------|-----------|-----------|----------|
| SOD (Mb)     | 50,13 | 41,93 | -16,3%      |
| .ipa (Mb)    | 16,59  | 13,43  | -19%      |

Fixes: https://github.com/xamarin/xamarin-macios/issues/18472
2023-07-06 12:52:28 -04:00
Rolf Bjarne Kvinge 7ed8c08ab0
[net8.0] Merge main into net8.0. (#18520) 2023-06-30 13:19:43 +02:00
Filip Navara 29f8bd7a90
Revert "[dotnet] Remove libSystem.Net.Security.Native from tvOS builds when using NativeAOT." (#18514)
This reverts commit 97b91f1600.

Fixes #18481
2023-06-30 10:33:12 +02:00
Rolf Bjarne Kvinge e2c673972b [net8.0] Merge main into net8.0. 2023-06-29 17:05:54 +02:00
Meri Khamoyan 3f6d43c756
[iOS] HybridGlobalization set flag in SDK (#18498)
Add HybridGlobalization flag in SDK and load icudt_hybrid.dat file when
HybridGlobalization is on.

Contributes to https://github.com/dotnet/runtime/issues/80689
2023-06-28 10:25:24 +02:00
dotnet-maestro[bot] e83845e989
[net8.0] Update dependencies from dotnet/installer (#18489#pullrequestreview-1498967369)
This pull request updates the following dependencies

## Coherency Updates

The following updates ensure that dependencies with a *CoherentParentDependency*
attribute were produced in a build used as input to the parent dependency's build.
See [Dependency Description Format](https://github.com/dotnet/arcade/blob/master/Documentation/DependencyDescriptionFormat.md#dependency-description-overview)

- **Coherency Updates**:
  - **Microsoft.NET.ILLink.Tasks**: from 8.0.0-preview.6.23316.3 to 8.0.0-preview.7.23325.2 (parent: Microsoft.Dotnet.Sdk.Internal)
  - **Microsoft.AspNetCore.App.Ref**: from 8.0.0-preview.6.23316.5 to 8.0.0-preview.7.23324.1 (parent: Microsoft.Dotnet.Sdk.Internal)
  - **Microsoft.NETCore.App.Ref**: from 8.0.0-preview.6.23316.3 to 8.0.0-preview.7.23325.2 (parent: Microsoft.Dotnet.Sdk.Internal)
  - **Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport**: from 8.0.0-preview.6.23312.1 to 8.0.0-preview.7.23321.3 (parent: Microsoft.NETCore.App.Ref)
  - **Microsoft.NETCore.App.Ref**: from 8.0.0-preview.6.23316.3 to 8.0.0-preview.7.23325.2 (parent: Microsoft.Dotnet.Sdk.Internal)
  - **Microsoft.DotNet.Cecil**: from 0.11.4-alpha.23312.1 to 0.11.4-alpha.23319.2 (parent: Microsoft.NETCore.App.Ref)

## From https://github.com/dotnet/installer

- **Subscription**: f9b68d84-9c90-4bd0-5499-08db4112d57e
- **Build**: 20230625.5
- **Date Produced**: June 26, 2023 6:19:18 AM UTC
- **Commit**: d2a244f560b9f89387a5e748c19adf3114153f89
- **Branch**: refs/heads/main

- **Updates**:
  - **Microsoft.Dotnet.Sdk.Internal**: [from 8.0.100-preview.6.23320.7 to 8.0.100-preview.7.23325.5][14]
  - **Microsoft.NET.ILLink.Tasks**: [from 8.0.0-preview.6.23316.3 to 8.0.0-preview.7.23325.2][15]
  - **Microsoft.AspNetCore.App.Ref**: [from 8.0.0-preview.6.23316.5 to 8.0.0-preview.7.23324.1][16]
  - **Microsoft.NETCore.App.Ref**: [from 8.0.0-preview.6.23316.3 to 8.0.0-preview.7.23325.2][15]
  - **Microsoft.NET.Workload.Emscripten.Current.Manifest-8.0.100.Transport**: [from 8.0.0-preview.6.23312.1 to 8.0.0-preview.7.23321.3][17]
  - **Microsoft.NETCore.App.Ref**: [from 8.0.0-preview.6.23316.3 to 8.0.0-preview.7.23325.2][15]
  - **Microsoft.DotNet.Cecil**: [from 0.11.4-alpha.23312.1 to 0.11.4-alpha.23319.2][18]

[14]: 7a0bb9fd74...d2a244f560
[15]: 76da696f3f...eaa9717d90
[16]: 974d15e3b0...213eb282fc
[17]: 1640faa87e...e004a85d84
[18]: ad66dcb8a0...f449dc9923
2023-06-26 18:44:18 +02:00
Rolf Bjarne Kvinge 9b72a75613
Add support for using NativeAOT. (#17374)
Add support for using NativeAOT on all our platforms.

This contains numerous changes in a lot of places to add support for
NativeAOT:

* build logic
* runtime
* managed code
* tests 

And it all pretty much consists of special-casing NativeAOT everywhere
we need to.

Note: NativeAOT doesn't work on macOS yet, because a dotnet/runtime fix
is required, and thus the corresponding test variations for
monotouch-test have been commented out.

This PR is best reviewed commit-by-commit.

This contributes towards https://github.com/xamarin/xamarin-macios/issues/17339.
2023-06-22 17:00:37 +02:00
Rolf Bjarne Kvinge b4e3361a10 [dotnet] Tell ILC about any satellite assemblies. 2023-06-22 08:44:47 +02:00
Rolf Bjarne Kvinge 3c912d7aea [dotnet] Treat the ICU data file as a resource instead of an assembly.
We can fix this better once this fix reaches us:

    https://github.com/dotnet/runtime/pull/87813

because then we can set the ICU data file at build time (to a relative path).
2023-06-22 08:44:47 +02:00
Rolf Bjarne Kvinge 42d6121e12 [dotnet] Set a flag to avoid a bug with the NativeAOT compiler 2023-06-22 08:44:47 +02:00
Rolf Bjarne Kvinge 264be7055e [dotnet] Disable SelfContained for the outer build of a universal app build when using NativeAOT. 2023-06-22 08:44:47 +02:00
Rolf Bjarne Kvinge 97b91f1600 [dotnet] Remove libSystem.Net.Security.Native from tvOS builds when using NativeAOT. 2023-06-22 08:44:47 +02:00
Rolf Bjarne Kvinge 7d65804e32 [dotnet/tests] Only use NativeAOT when publishing.
This matches how NativeAOT works for other platforms.
2023-06-22 08:44:47 +02:00
Rolf Bjarne Kvinge a1d707c013 [dotnet] Fix items in TrimmerRootAssembly to follow docs and what ILC supports. 2023-06-22 08:44:47 +02:00
Rolf Bjarne Kvinge 18eaeb24b2
[net8.0] [build] Require using EnablePreviewFeatures=true when using preview releases. Contributes towards #18343. (#18476)
Detect if we're using a non-stable Xcode, and in that case produce packages
that show an error if they're used and the EnablePreviewFeatures flag isn't
enabled.

Also add logic to set this flag for our own build, otherwise all our tests
would fail.

This is the same as Android does.

Contributes towards https://github.com/xamarin/xamarin-macios/issues/18343.
2023-06-22 08:16:50 +02:00
Rolf Bjarne Kvinge e3228d04ea [dotnet] Turn off some publishing behavior we don't need 2023-06-21 20:49:56 +02:00
Rolf Bjarne Kvinge 183c76af40 [dotnet] Use a different min OS version when building with NativeAOT.
This is because NativeAOT contains swift code, and we'd have to add code to
embed the Swift libraries in any apps that target early OS versions. We could
eventually implement this, but let's wait and see if there's a demand first.
2023-06-21 20:49:56 +02:00
Rolf Bjarne Kvinge d601e51698 [dotnet] Set PublishAotUsingRuntimePack=true when using NativeAOT to get the correct BCL libraries. 2023-06-21 20:49:56 +02:00
Rolf Bjarne Kvinge 617f64e52d [dotnet] Enforce that the linker must be enabled for all assemblies when using NativeAOT (and warn if someone asks otherwise). 2023-06-21 20:49:56 +02:00
Rolf Bjarne Kvinge 2ee532690a [dotnet] Collect all the native linker arguments ILC would have used and use them ourselves. 2023-06-21 20:49:55 +02:00
Rolf Bjarne Kvinge c48d583025 [dotnet] Link the output from ILC into the native executable 2023-06-21 20:49:55 +02:00
Rolf Bjarne Kvinge 79b76574c7 [dotnet] Ask ILC to only trim assemblies if trimming is explicitly enabled 2023-06-21 20:49:55 +02:00
Rolf Bjarne Kvinge 39774937ba [dotnet] Ask ILC to process all unmanaged callers only methods from all assemblies 2023-06-21 20:49:55 +02:00
Rolf Bjarne Kvinge 6bd8915d1a [dotnet] Rearrange items in item groups so that ILC gets the output from ILLink 2023-06-21 20:49:54 +02:00
Rolf Bjarne Kvinge 8cfee8b599 [dotnet] Ask ILC to treat all P/Invokes to __Internal as direct P/Invokes 2023-06-21 20:49:54 +02:00
Rolf Bjarne Kvinge 00b2865f0d [dotnet] Adjust ILC's build dependencies to cope with the fact that ILC doesn't support executing after ILLink.
Currently, NativeAOT is implemented as a replacement (of sorts) for ILLink. However,
we need to execute both, and in order to do that, we force our own logic to execute
to determine what ILC does.

This might be improved in the future. Ref: https://github.com/dotnet/runtime/issues/87187.
2023-06-21 20:49:54 +02:00
Rolf Bjarne Kvinge b36db05275 [dotnet] Call ILC, the NativeAOT compiler, before we link the native executable 2023-06-21 20:49:54 +02:00
Rolf Bjarne Kvinge 13fa76923f [dotnet] Disable our own IL stripping when using NativeAOT, because NativeAOT already does something equivalent 2023-06-21 20:49:54 +02:00
Rolf Bjarne Kvinge 595bcdb92f [dotnet] Don't call ComputeResolvedFilesToPublishList when using NativeAOT. 2023-06-21 20:49:53 +02:00
Rolf Bjarne Kvinge 0db2c5c53f [dotnet] Rework feature detection and notification a bit. 2023-06-21 20:49:53 +02:00
Rolf Bjarne Kvinge e0e4b77a55 [dotnet] Set AutoreleasePoolSupport earlier so that the linker doesn't set it first.
Might not be necessary: https://github.com/dotnet/runtime/pull/86753
2023-06-21 20:49:52 +02:00
Rolf Bjarne Kvinge b4a67c69c8 [src] Make the Runtime.IsNativeAOT property a constant in the linker. 2023-06-21 20:49:52 +02:00
Rolf Bjarne Kvinge 94c96ec263 [dotnet] Don't run Mono's AOT compiler if we're using NativeAOT. 2023-06-21 20:49:50 +02:00
Rolf Bjarne Kvinge 607cc78555 [dotnet] Use the correct package infix for NativeAOT 2023-06-21 20:49:50 +02:00
Rolf Bjarne Kvinge d584840c1c [dotnet] Force the managed static registrar when using NativeAot. 2023-06-21 20:49:50 +02:00
Rolf Bjarne Kvinge a76690198f [dotnet] Choose the correct runtime library depending on which runtime we're using. 2023-06-21 20:49:49 +02:00
Rolf Bjarne Kvinge a192eed02b [net8.0] Merge main into net8.0. 2023-06-19 23:23:04 +02:00
Rolf Bjarne Kvinge 2761123a6b
[dotnet] Add a property to opt-out of the _CopyLocalBindingResources logic easily. (#18443)
It seems this target has more problems than at first I thought, so make
it easier to opt-out of it by just setting a property in the csproj.

More investigation is needed, but I'm keeping the target on by default
for now, since it solves a real-world problem as well.

Ref: https://github.com/xamarin/xamarin-macios/issues/18445
2023-06-15 09:54:22 +02:00
Rolf Bjarne Kvinge 7df3eb1520
[dotnet] Add targets to compute mlaunch arguments for installing and launching mobile apps. Fixes #18359. (#18446)
Add public targets to compute the mlaunch command lines for installing
and launching mobile apps.

These new targets are:

* ComputeMlaunchInstallArguments
* ComputeMlaunchRunArguments

As part of this change, also create a few new public properties:

* MlaunchPath
* MlaunchRunArguments
* MlaunchInstallArguments
* MlaunchRunScript
* MlaunchInstallScript

If the *Script variables are set, the corresponding target will create a
script file with the path to mlaunch + the corresponding arguments.

Otherwise, it's also possible to get the arguments directly from the
build log.

Fixes https://github.com/xamarin/xamarin-macios/issues/18359.
2023-06-15 07:21:09 +02:00
Rolf Bjarne Kvinge 5d6a92eaf0 [net8.0] Merge main into net8.0. 2023-06-12 18:56:10 +02:00
Ivan Povazan e3088879a6
Reduce the size of `__LINKEDIT Export Info` section in stripped binaries (#18408)
# Description

This PR reduces the application's SOD (size on disk) by making
`__LINKEDIT Export Info` section smaller in the stripped Mach-O
binaries.

The feature is controlled by `_ExportSymbolsExplicitly` MSBuild property
and can be disabled by specifying: `-p:_ExportSymbolsExplicitly=true`

Fixes #18332 

# Initial problem

It has been noticed that during stripping, the strip tool does not
resize the export info section after it removes the symbols. Instead it
only zeroes out the entries (achieved by calling `prune_trie` function):

- https://github.com/apple-oss-distributions/cctools/blob/cctools-986/misc/strip.c
- https://github.com/apple-oss-distributions/ld64/blob/ld64-711/src/other/PruneTrie.cpp

Thanks @lambdageek for helping to track this down.

# Approach

As Xamarin build process already collects all the [required symbols][1] needed
for the application to run and preserves them during the strip phase, we can
use the same file to instruct clang toolchain to export only those symbols via
the command line options: `-exported_symbols_list <file>` ([source][2]).

This will make the export info section only include what is necessary for the
runtime - and at the same time eliminate the problem of the `strip` tool which
does not resize stripped symbols.

# Investigation setup

The issue is observable by building and inspecting the test application:
https://github.com/xamarin/xamarin-macios/blob/main/tests/dotnet/MySingleView/MySingleView.csproj
and targeting iOS platform in Release mode.

## Results:

| Measure      | MySingleView - main | MySingleView - this PR | Diff (%) | 
| :---         |                ---: |                   ---: |     ---: |
| SOD (bytes)  |            13668940 |               13458476 |    -1.5% |
| .ipa (bytes) |             4829368 |                4827928 |   -0.03% |

Even though zeroes are compressed well, the SOD is still affected and
unused section takes around 1.5% of the most simplistic app size.
Much bigger impact has been noted when trying out a MAUI iOS template
app with NativeAOT where the `__LINKEDIT Export Info` zeroes take up to
20MB of the SOD, but also with the regular macOS applications:
https://github.com/dotnet/runtime/issues/86707

### Repro current state of MySingleView.app with stripped binary

1. Build the app (you can ignore the need to run the sample, I just did it to
   make sure the changes do not break anything)

```bash
make run-device
``` 

2. Print the load commands - [load_cmds_strip.list][3]

```bash
otool -l bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > load_cmds_strip.list
```

- We are interested in the export info section:

```
cmd LC_DYLD_INFO_ONLY
...
export_off 5942960
export_size 207712
```

3. Create a hex dump of the export info section - [hex_dump_strip.list][4]

``` bash
xxd -s 5942960 -l 207712 bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > hex_dump_strip.list
```

- NOTE: Notice around ~200kb of zeroes from ~0x005ab490 to ~0x005dda00
    
4. Verify exported symbols are correct - [dyld_info_strip.list][5]

``` bash
dyld_info -exports bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > dyld_info_strip.list
```

### Repro current state of MySingleView.app with unstripped binary

1. Build the app (the make target preserves the symbols)

```bash
make run-device-no-strip
``` 

2. Print the load commands - [load_cmds_nostrip.list][6]

```bash
otool -l bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > load_cmds_nostrip.list
```

- We are interested in the export info section:

```
cmd LC_DYLD_INFO_ONLY
...
export_off 5942960
export_size 207712
```

3. Create a hex dump of the export info section - [hex_dump_nostrip.list][7]

``` bash
xxd -s 5942960 -l 207712 bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > hex_dump_nostrip.list
```

- Notice that the range: ~ 0x005ab490 to ~ 0x005dda00 now includes exported symbol entries
    
4. Verify exported symbols are correct - [dyld_info_nostrip.list][8]

``` bash
dyld_info -exports bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > dyld_info_nostrip.list
```

### Repro the new approach 

1. Build the app (the make target uses the new approach)

```bash
make run-device-export-syms
``` 

2. Print the load commands - [load_cmds_export.list][9]

```bash
otool -l bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > load_cmds_export.list
```

- We are interested in the export info section ***notice the reduced size of the section***:

```
cmd LC_DYLD_INFO_ONLY
...
export_off 5942432
export_size 1048
```

3. Create a hex dump of the export info section - [hex_dump_export.list][10]

``` bash
xxd -s 5942432 -l 1048 bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > hex_dump_export.list
```
    
4. Verify exported symbols are correct - [dyld_info_export.list][11]

``` bash
dyld_info -exports bin/Release/net7.0-ios/ios-arm64/MySingleView.app/MySingleView > dyld_info_export.list
```

---

## Additional benefits

With this approach we could also switch the way strip tool is invoked to
always strip all debug and local symbols via `strip -S -x` instead of passing
the file with symbols to preserve. This would remove the warning that we are
currently getting (which is being ignored):

```
/Applications/Xcode_14.3.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip: warning: removing global symbols from a final linked no longer supported.  Use -exported_symbols_list at link time when building...
```

## Other references:

- https://github.com/qyang-nj/llios/blob/main/exported_symbol/README.md

[1]: 11e7883da0/tools/dotnet-linker/Steps/GenerateReferencesStep.cs (L38-L44)
[2]: https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
[3]: https://gist.github.com/ivanpovazan/d53f8d10be5e4ea9f39a41ea540aa7fa
[4]: https://gist.github.com/ivanpovazan/60637422f3ff8cb5f437ddd06a21d9c1
[5]: https://gist.github.com/ivanpovazan/352595ad15c2ac02f38dcb3bd4130642
[6]: https://gist.github.com/ivanpovazan/bf700161f2f3691d1d7381c98d4fa0be
[7]: https://gist.github.com/ivanpovazan/44269e4fff5ebd58a4d181451e5c106f
[8]: https://gist.github.com/ivanpovazan/38c5afe076502d514a77420af0e10b01
[9]: https://gist.github.com/ivanpovazan/3f663c3c630005f5a578605d48ba807e
[10]: https://gist.github.com/ivanpovazan/0bb84f64281d05ab20438aeaed64f13c
[11]: https://gist.github.com/ivanpovazan/78b3ba2288f53a2316b9bc46964e7e4f

---------

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2023-06-12 13:45:38 +02:00
Rolf Bjarne Kvinge 6f1c0ea534 [net8.0] Merge main into net8.0. 2023-06-08 13:32:48 +02:00
VS MobileTools Engineering Service 2 1527450920
[dotnet] Set _RequiresILLinkPack=true so that we always restore the ILLink package. (#18412)
This property will be required when building for a net7.0-* target framework
using .NET 8 (preview 6 - preview 5 does not need this fix)

Backport of #18411
2023-06-07 08:48:42 +02:00