Skip to content

Commit

Permalink
[dotnet] Pass the Optimize flags from the extra bundler arguments to …
Browse files Browse the repository at this point in the history
…the linker configuration. (#9599)

* [dotnet] Pass the Optimize flags from the extra bundler arguments to the linker configuration.

Also call Application.InitializeCommon to initialize the application instance. The
important part here is that InitializeCommon calls Optimizations.Initialize to compute
the default optimizations. It also calls Set*ExceptionMode and sets the default EnableCoopGC
value (so we don't need to call/set those anymore), and it does a few other initialization
tasks which we don't need yet, but eventually will.

And finally remember to parse the bundler arguments before using them in the dotnet
build logic. How did this not cause problems before? 🤦

* [tests] Set the verbosity using the additional args instead of an internal variable.

The internal _BundlerVerbosity variable is overwritten now (with the verbosity
value from the additional args).

* [xharness] Disable tvOS generation for the introspection/.NET test, it incorrect and needs fixing.
  • Loading branch information
rolfbjarne committed Sep 9, 2020
1 parent 7a79845 commit 941d65f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion dotnet/targets/Xamarin.Shared.Sdk.targets
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
<_AdditionalTaskAssemblyDirectory>$(_XamarinSdkRootDirectory)tools/dotnet-linker/</_AdditionalTaskAssemblyDirectory>
<_AdditionalTaskAssembly>$(_AdditionalTaskAssemblyDirectory)dotnet-linker.dll</_AdditionalTaskAssembly>
</PropertyGroup>
<Target Name="_ComputeLinkerArguments" DependsOnTargets="_ComputeLinkMode;_ComputeFrameworkVariables;_ComputeFrameworkAssemblies;ComputeResolvedFilesToPublishList">
<Target Name="_ComputeLinkerArguments" DependsOnTargets="_ComputeLinkMode;_ComputeFrameworkVariables;_ComputeFrameworkAssemblies;ComputeResolvedFilesToPublishList;_ParseBundlerArguments;">
<!-- 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'" />

Expand All @@ -164,6 +164,7 @@
LinkMode=$(_LinkMode)
MarshalManagedExceptionMode=$(_MarshalManagedExceptionMode)
MarshalObjectiveCExceptionMode=$(_MarshalObjectiveCExceptionMode)
Optimize=$(_BundlerOptimize)
PartialStaticRegistrarLibrary=$(_LibPartialStaticRegistrar)
Platform=$(_PlatformName)
PlatformAssembly=$(_PlatformAssemblyName).dll
Expand Down
5 changes: 4 additions & 1 deletion tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
namespace Xamarin.Tests {
[TestFixture]
public class DotNetProjectTest {
Dictionary<string, string> verbosity = new Dictionary<string, string> { { "_BundlerVerbosity", "1" } };
Dictionary<string, string> verbosity = new Dictionary<string, string> {
{ "MtouchExtraArgs", "-v" },
{ "MonoBundlingExtraArgs", "-v" },
};

string GetProjectPath (string project, string subdir = null)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/xharness/Harness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void AutoConfigureIOS ()
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "interdependent-binding-projects", "interdependent-binding-projects.csproj"))) { Name = "interdependent-binding-projects" });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "interdependent-binding-projects", "dotnet", "iOS", "interdependent-binding-projects.csproj"))) { Name = "interdependent-binding-projects", IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "iOS", "introspection-ios.csproj"))) { Name = "introspection" });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "iOS", "introspection-ios-dotnet.csproj"))) { Name = "introspection", IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = false, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "introspection", "iOS", "introspection-ios-dotnet.csproj"))) { Name = "introspection", IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "monotouch-test", "dotnet", "iOS", "monotouch-test.csproj"))) { Name = "monotouch-test", IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true, });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" } });
IOSTestProjects.Add (new iOSTestProject (Path.GetFullPath (Path.Combine (RootDirectory, "linker", "ios", "dont link", "dotnet", "iOS", "dont link.csproj"))) { Configurations = new string [] { "Debug", "Release" }, IsDotNetProject = true, SkipiOSVariation = false, SkiptvOSVariation = true, SkipwatchOSVariation = true, SkipTodayExtensionVariation = true, SkipDeviceVariations = true, SkipiOS32Variation = true });
Expand Down
17 changes: 14 additions & 3 deletions tools/dotnet-linker/LinkerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class LinkerConfiguration {

// The list of assemblies is populated in CollectAssembliesStep.
public List<AssemblyDefinition> Assemblies = new List<AssemblyDefinition> ();

string user_optimize_flags;

public static LinkerConfiguration GetInstance (LinkContext context)
{
Expand Down Expand Up @@ -134,6 +136,9 @@ public static LinkerConfiguration GetInstance (LinkContext context)
Application.MarshalObjectiveCExceptions = mode;
}
break;
case "Optimize":
user_optimize_flags = value;
break;
case "PartialStaticRegistrarLibrary":
PartialStaticRegistrarLibrary = value;
break;
Expand Down Expand Up @@ -191,10 +196,16 @@ public static LinkerConfiguration GetInstance (LinkContext context)

ErrorHelper.Platform = Platform;

// Optimizations.Parse can only be called after setting ErrorHelper.Platform
if (!string.IsNullOrEmpty (user_optimize_flags)) {
var messages = new List<ProductException> ();
Application.Optimizations.Parse (Application.Platform, user_optimize_flags, messages);
ErrorHelper.Show (messages);
}

Application.CreateCache (significantLines.ToArray ());
Application.Cache.Location = CacheDirectory;
Application.DeploymentTarget = DeploymentTarget;
Application.EnableCoopGC ??= Platform == ApplePlatform.WatchOS;
Application.SdkVersion = SdkVersion;

switch (Platform) {
Expand All @@ -211,8 +222,7 @@ public static LinkerConfiguration GetInstance (LinkContext context)
if (Driver.TargetFramework.Platform != Platform)
throw ErrorHelper.CreateError (99, "Inconsistent platforms. TargetFramework={0}, Platform={1}", Driver.TargetFramework.Platform, Platform);

Application.SetManagedExceptionMode ();
Application.SetObjectiveCExceptionMode ();
Application.InitializeCommon ();
}

public void Write ()
Expand All @@ -232,6 +242,7 @@ public void Write ()
Console.WriteLine ($" LinkMode: {LinkMode}");
Console.WriteLine ($" MarshalManagedExceptions: {Application.MarshalManagedExceptions} (IsDefault: {Application.IsDefaultMarshalManagedExceptionMode})");
Console.WriteLine ($" MarshalObjectiveCExceptions: {Application.MarshalObjectiveCExceptions}");
Console.WriteLine ($" Optimize: {user_optimize_flags} => {Application.Optimizations}");
Console.WriteLine ($" PartialStaticRegistrarLibrary: {PartialStaticRegistrarLibrary}");
Console.WriteLine ($" Platform: {Platform}");
Console.WriteLine ($" PlatformAssembly: {PlatformAssembly}.dll");
Expand Down

8 comments on commit 941d65f

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Pipeline scripts tests failed on VSTS: device tests iOS (DDFun) 🔥

The tests of the scripts used in the pipeline failed. The build was cancelled.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Tests failed catastrophically on VSTS: device tests iOS (DDFun) 🔥

Not enough free space in the host.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Tests failed catastrophically on VSTS: device tests iOS (DDFun) 🔥

Failed provisioning profiles.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Tests failed catastrophically on VSTS: device tests iOS (Cambridge) 🔥

Failed provisioning profiles.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

🔥 Tests failed catastrophically on VSTS: device tests iOS (Cambridge) 🔥

Failed installing dependencies.

Pipeline on Agent

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

Jenkins job (on internal Jenkins) succeeded

Provisioning succeeded
Build succeeded
✅ Packages built successfully

View packages

API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
Test run succeeded

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Device tests failed on VSTS: device tests iOS32b (Cambridge) ❌

Device tests failed on VSTS: device tests iOS32b (Cambridge).

Test results

15 tests failed, 146 tests passed.

Failed tests

  • monotouch-test/iOS Unified 32-bits - device/Debug: Failed
  • monotouch-test/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug): Failed
  • monotouch-test/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug): Failed
  • monotouch-test/iOS Unified 32-bits - device/AssemblyBuildTarget: dylib (debug, profiling): Failed
  • monotouch-test/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed
  • monotouch-test/iOS Unified 32-bits - device/Release: Failed
  • monotouch-test/iOS Unified 32-bits - device/Release: UseThumb: Failed
  • monotouch-test/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (release): Failed
  • monotouch-test/iOS Unified 32-bits - device/Release (all optimizations): Failed
  • monotouch-test/iOS Unified 32-bits - device/Debug (all optimizations): Failed
  • monotouch-test/iOS Unified 32-bits - device/Debug: SGenConc: Failed
  • [NUnit] Mono BCL tests group 2/iOS Unified 32-bits - device/Release: UseThumb: TimedOut
  • mscorlib Part 1/iOS Unified 32-bits - device/Release: BuildFailure Known issue: Undefined symbol ___multi3 on Release Mode.
  • mscorlib Part 1/iOS Unified 32-bits - device/Release: UseThumb: BuildFailure Known issue: Undefined symbol ___multi3 on Release Mode.
  • mscorlib Part 1/iOS Unified 32-bits - device/AssemblyBuildTarget: SDK framework (release): BuildFailure Known issue: Undefined symbol ___multi3 on Release Mode.

Pipeline on Agent XI-CAPTAIN-MARVEL

@xamarin-release-manager
Copy link
Collaborator

Choose a reason for hiding this comment

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

❌ Device tests failed on VSTS: device tests tvOS (DDFun) ❌

Device tests failed on VSTS: device tests tvOS (DDFun).

Test results

7 tests failed, 143 tests passed.

Failed tests

  • dont link/tvOS - device/AssemblyBuildTarget: SDK framework (release): Crashed
  • [NUnit] Mono BCL tests group 1/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • [NUnit] Mono BCL tests group 2/tvOS - device/AssemblyBuildTarget: SDK framework (debug, profiling): Failed (Install failed, exit code: 137.)
  • [NUnit] Mono BCL tests group 2/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • [xUnit] Mono BCL tests group 3/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)
  • mscorlib Part 1/tvOS - device/Release: Failed (Install failed, exit code: 137.)
  • mscorlib Part 1/tvOS - device/AssemblyBuildTarget: SDK framework (release): Failed (Install failed, exit code: 137.)

Pipeline on Agent XAMTESTMAC13

Please sign in to comment.