Skip to content
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

[dotnet] Add support for universal apps. #11983

Merged
merged 44 commits into from
Jun 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
87de6ea
[runtime] Add support for finding assemblies in an RID-specific subdi…
rolfbjarne May 25, 2021
6fe54cb
[dotnet] Only trim when building a specific RuntimeIdentifier.
rolfbjarne May 21, 2021
9a9562c
[tests] Add unified simple test app for all platforms we support.
rolfbjarne Jun 15, 2021
0021c2b
[MachO] Make StaticLibrary.IsStaticLibrary work with files shorter th…
rolfbjarne May 21, 2021
7aec86f
ools] Create a PathUtils class and move some shareable code there.
rolfbjarne May 21, 2021
0af6ec5
[MachO] Add a MachO.IsMachOFile method
rolfbjarne May 21, 2021
ba83560
[tools] Move parts of the binary file comparison to a helper file to …
rolfbjarne May 21, 2021
f864ff3
[tools] Move another IsUptodate overload to the FileCopier file to in…
rolfbjarne Jun 16, 2021
5955cd1
[tests] Add a complex test library project with resources and app con…
rolfbjarne May 21, 2021
724d0fe
[dotnet] Set a default RuntimeIdentifier and validate that we get a v…
rolfbjarne Jun 14, 2021
e1f31c6
[tests] Quote parameters containing semicolons when passed to 'dotnet…
rolfbjarne May 21, 2021
003cf30
[dotnet] Don't execute ComputeResolvedFileToPublishList if we're in t…
rolfbjarne May 21, 2021
5c50a2f
[msbuild] Implement a MergeAppBundles task to merge two (or more) app…
rolfbjarne May 21, 2021
4f8e9a8
[tests] Add new tests for merging app bundles
rolfbjarne May 21, 2021
91311a0
[dotnet] Implement support for multiple RuntimeIdentifiers.
rolfbjarne May 21, 2021
81b139e
[dotnet] Ignore RuntimeIdentifier if RuntimeIdentifiers is set.
rolfbjarne Jun 16, 2021
62865cb
Merge remote-tracking branch 'origin/main' into HEAD
rolfbjarne Jun 21, 2021
a32d605
[msbuild] Fix symlink check to check for file presence first.
rolfbjarne Jun 18, 2021
4526a5e
[msbuild] Copy directories correctly.
rolfbjarne Jun 18, 2021
bc9e007
[tests] Updated list of not-yet-localized error messages.
rolfbjarne Jun 18, 2021
718d954
[tests] Improve error reporting when SetUp fails in MergeAppBundleTas…
rolfbjarne Jun 21, 2021
f1cc00c
[tests] Update tests according to the actual error messages.
rolfbjarne Jun 21, 2021
7179cac
[dotnet] Set the default RuntimeIdentifier earlier.
rolfbjarne Jun 21, 2021
2f1667e
[tests] Remove MSBuildSDKsPath from the environment before invoking m…
rolfbjarne Jun 22, 2021
70d0f86
Merge remote-tracking branch 'origin/main' into HEAD
rolfbjarne Jun 23, 2021
889cf99
[dotnet] Compile entitlements before signing the merged app bundle.
rolfbjarne Jun 22, 2021
5ecb7ae
[msbuild] List all files causing errors.
rolfbjarne Jun 23, 2021
2a203b5
[msbuild] Compute input files slightly differently for CreateMergedAp…
rolfbjarne Jun 23, 2021
f6e9f55
[runtime] Add a xamarin_locate_app_resource function.
rolfbjarne Jun 23, 2021
608dfb3
[dotnet] Make the globalization data file an architecture-specific file.
rolfbjarne Jun 23, 2021
a78be0a
[dotnet] Ignore Info.plist files from the input app bundles when merg…
rolfbjarne Jun 23, 2021
e68831b
[dotnet] Compile the app manifest in the outer build for multi-rid apps.
rolfbjarne Jun 23, 2021
7f505c3
[dotnet] Rework how we compute the TargetArchitectures property.
rolfbjarne Jun 23, 2021
9f82694
[msbuild] Use the same prefix in ErrorHelper as we do in other MSBuil…
rolfbjarne Jun 24, 2021
df369da
[MachO] Simplify code a bit according to review.
rolfbjarne Jun 24, 2021
c5dad31
[dotnet] Don't create debug settings / configurations for inner builds.
rolfbjarne Jun 24, 2021
1fa1cf3
[dotnet] Use the correct relative paths for Info.plist for all platfo…
rolfbjarne Jun 24, 2021
82fc13e
[tests] Fix assertions regarding errors after recent changes.
rolfbjarne Jun 24, 2021
9a406d2
[tests] Fix makefile for ComplexAssembly to do nothing on a rebuild.
rolfbjarne Jun 24, 2021
2f65937
[tests] Remove BOM in new file.
rolfbjarne Jun 24, 2021
3497373
[dotnet] Compute 'ComputedPlatform' correctly for outer multi-rid bui…
rolfbjarne Jun 24, 2021
31b48eb
[tests] Copy more supporting files for building monotouch-test with .…
rolfbjarne Jun 24, 2021
6d6db24
[dotnet] Use relative paths in a few places.
rolfbjarne Jun 24, 2021
8aff15a
[tests] Don't run parallel make in tests/common/TestProjects/ComplexA…
rolfbjarne Jun 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@
<ProduceReferenceAssembly Condition="'$(ProduceReferenceAssembly)' == '' And ('$(OutputType)' == 'Exe' Or '$(IsAppExtension)' == 'true')">false</ProduceReferenceAssembly>
</PropertyGroup>

<PropertyGroup>
<_GlobalizationDataFile Condition="'$(_PlatformName)' != 'macOS' And '$(InvariantGlobalization)' != 'true' And '$(_GlobalizationDataFile)' == ''">icudt.dat</_GlobalizationDataFile>
</PropertyGroup>

<PropertyGroup>
<TargetPlatformSupported Condition=" '$(TargetPlatformIdentifier)' == '$(_PlatformName)' ">true</TargetPlatformSupported>
</PropertyGroup>
Expand Down Expand Up @@ -298,6 +302,8 @@
<ItemGroup>
<!-- If we're creating a runtimeconfig.json file, then the resulting binary runtimeconfig.bin file can be put in the architecture-specific subdirectory -->
<_ArchitectureSpecificFiles Include="$(_RuntimeConfigurationFile)" Condition="'$(GenerateRuntimeConfigurationFiles)' != ''" />
<!-- The globalization data file can be put in the architecture-specific subdirectory -->
<_ArchitectureSpecificFiles Include="$(_GlobalizationDataFile)" Condition="'$(_GlobalizationDataFile)' != ''" />
</ItemGroup>

<MergeAppBundles
Expand All @@ -324,6 +330,9 @@
<!-- Validate the linker mode -->
<Error Text="Invalid link mode: '$(_LinkMode)'. Valid link modes are: 'None', 'SdkOnly' and 'Full'" Condition="'$(_LinkMode)' != 'None' And '$(_LinkMode)' != 'SdkOnly' And '$(_LinkMode)' != 'Full'" />

<!-- it's invariant or it's one of the ICU data files, not both -->
<Error Text="Can not set values for both InvariantGlobalization '$(InvariantGlobalization)' and _GlobalizationDataFile '$(_GlobalizationDataFile)'" Condition="'$(_GlobalizationDataFile)' != '' And '$(InvariantGlobalization)' == 'true'" />

<PropertyGroup>
<!-- Pass the custom options to our custom steps -->
<_CustomLinkerOptionsFile>$([System.IO.Path]::GetFullPath('$(IntermediateOutputPath)custom-linker-options.txt'))</_CustomLinkerOptionsFile>
Expand All @@ -348,6 +357,7 @@
DeploymentTarget=$(_MinimumOSVersion)
@(_BundlerEnvironmentVariables -> 'EnvironmentVariable=%(Identity)=%(Value)')
@(_XamarinFrameworkAssemblies -> 'FrameworkAssembly=%(Filename)')
GlobalizationDataFile=$(_GlobalizationDataFile)
Interpreter=$(MtouchInterpreter)
IntermediateLinkDir=$(IntermediateLinkDir)
InvariantGlobalization=$(InvariantGlobalization)
Expand Down Expand Up @@ -901,7 +911,7 @@
<ResolvedFileToPublish
Update="@(ResolvedFileToPublish)"
RelativePath="$([MSBuild]::MakeRelative($(MSBuildProjectDirectory)\$(PublishDir),$(_AssemblyPublishDir)))\%(Filename)%(Extension)"
Condition="'$(_PlatformName)' != 'macOS' And '$(InvariantGlobalization)' != 'true' And '%(Filename)%(Extension)' == 'icudt.dat'" />
Condition="'$(_PlatformName)' != 'macOS' And '$(InvariantGlobalization)' != 'true' And '%(Filename)%(Extension)' == '$(_GlobalizationDataFile)'" />

<!-- Remove the libxamarin-*.dylib files we don't want -->
<ResolvedFileToPublish Remove="@(ResolvedFileToPublish)" Condition="'%(Extension)' == '.dylib' And '%(Filename)%(Extension)' != '$(_LibXamarinName)' And $([System.String]::new('%(Filename)').StartsWith('libxamarin-dotnet', StringComparison.Ordinal))" />
Expand Down
14 changes: 13 additions & 1 deletion runtime/runtime.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
#endif
int xamarin_log_level = 0;
const char *xamarin_executable_name = NULL;
#if DOTNET
const char *xamarin_icu_dat_file_name = NULL;
#endif
#if MONOMAC || TARGET_OS_MACCATALYST
NSString * xamarin_custom_bundle_name = @"MonoBundle";
#endif
Expand Down Expand Up @@ -2384,6 +2387,15 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
xamarin_vm_initialize ()
{
char *pinvokeOverride = xamarin_strdup_printf ("%p", &xamarin_pinvoke_override);
char *icu_dat_file_path = NULL;

char path [1024];
if (!xamarin_locate_app_resource (xamarin_icu_dat_file_name, path, sizeof (path))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That looks like ios-arm and ios-arm64 each as a copy of the icu data file ?
I don't recall if those are identical (or not) between architectures... but if they are then it's a big opportunity for sharing it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the icu data file is different between architectures (the arm one is bigger):

 ls -la [...]/xamarin-macios/tests/dotnet/packages/microsoft.netcore.app.runtime.mono.ios-arm*/6.0.0-preview.6.21276.13/runtimes/ios-arm*/native/icudt.dat
-rwxr--r--  1 rolf  wheel  1713152 May 18 21:54 [...]/xamarin-macios/tests/dotnet/packages/microsoft.netcore.app.runtime.mono.ios-arm/6.0.0-preview.6.21276.13/runtimes/ios-arm/native/icudt.dat
-rwxr--r--  1 rolf  wheel  1636880 May 18 21:54 [...]/xamarin-macios/tests/dotnet/packages/microsoft.netcore.app.runtime.mono.ios-arm64/6.0.0-preview.6.21276.13/runtimes/ios-arm64/native/icudt.dat

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference is unintentional. I don't think there's a tracking issue for it but I already mentioned it few times in some comments. The ICU data are generated from same input using the same tools. My theory is that there is some compression involved and the zlib library consumed by different builds is slightly different version with different defaults.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's unintended, they should be identical. Filed dotnet/runtime#55637

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I was about to file an issue and look into it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filipnavara I wonder if ICU data for 64bit is a bit bigger due to some 64bit paddings etc for performance sake 🙂

Copy link
Contributor

@filipnavara filipnavara Jul 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EgorBo Unlikely. The arm64 ones on Android and iOS are different size (dotnet/designs#225 (comment)). I don't think it's even memory mapped so the micro-optimizations would not make much difference.

LOG (PRODUCT ": Could not locate the ICU data file '%s' in the app bundle.\n", xamarin_icu_dat_file_name);
} else {
icu_dat_file_path = path;
}

// All the properties we pass here must also be listed in the _RuntimeConfigReservedProperties item group
// for the _CreateRuntimeConfiguration target in dotnet/targets/Xamarin.Shared.Sdk.targets.
const char *propertyKeys[] = {
Expand All @@ -2394,7 +2406,7 @@ -(void) xamarinSetFlags: (enum XamarinGCHandleFlags) flags;
const char *propertyValues[] = {
xamarin_get_bundle_path (),
pinvokeOverride,
"icudt.dat",
icu_dat_file_path,
};
static_assert (sizeof (propertyKeys) == sizeof (propertyValues), "The number of keys and values must be the same.");

Expand Down
4 changes: 4 additions & 0 deletions tools/dotnet-linker/LinkerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class LinkerConfiguration {
public string CacheDirectory { get; private set; }
public Version DeploymentTarget { get; private set; }
public HashSet<string> FrameworkAssemblies { get; private set; } = new HashSet<string> ();
public string GlobalizationDataFile { get; private set; }
public string IntermediateLinkDir { get; private set; }
public bool InvariantGlobalization { get; private set; }
public string ItemsDirectory { get; private set; }
Expand Down Expand Up @@ -232,6 +233,9 @@ public static LinkerConfiguration GetInstance (LinkContext context, bool createI
throw new InvalidOperationException ($"Invalid XamarinRuntime '{value}' in {linker_file}");
Application.XamarinRuntime = rv;
break;
case "GlobalizationDataFile":
GlobalizationDataFile = value;
break;
case "InvariantGlobalization":
InvariantGlobalization = string.Equals ("true", value, StringComparison.OrdinalIgnoreCase);
break;
Expand Down
5 changes: 5 additions & 0 deletions tools/dotnet-linker/Steps/GenerateMainStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ protected override void TryEndProcess ()
var contents = new StringBuilder ();

contents.AppendLine ("#include <stdlib.h>");
contents.AppendLine ();
contents.AppendLine ("extern \"C\" const char *xamarin_icu_dat_file_name;");
contents.AppendLine ();
contents.AppendLine ("static void xamarin_initialize_dotnet ()");
contents.AppendLine ("{");
if (Configuration.InvariantGlobalization) {
contents.AppendLine ("\tsetenv (\"DOTNET_SYSTEM_GLOBALIZATION_INVARIANT\", \"1\", 1);");
} else {
contents.AppendLine ($"\txamarin_icu_dat_file_name = \"{Configuration.GlobalizationDataFile}\";");
}
contents.AppendLine ("}");
contents.AppendLine ();
Expand Down