-
Notifications
You must be signed in to change notification settings - Fork 508
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
[XM] Prototype of AOT support in Xamarin.Mac #1340
Conversation
Let's get this out here for testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beside the name, the rest is fine :)
@spouliot I'll %s/experimental-xm-aot/xm-aot/gc after QA approves it and we're going to master. I just want a scary sounding name for testing. |
Build success |
@@ -358,6 +359,7 @@ static void Main2 (string [] args) | |||
{ "xamarin-framework-directory=", "The framework directory", v => { xm_framework_dir = v; }, true }, | |||
{ "xamarin-full-framework", "Used with --target-framework=4.5 to select XM 4.5 Target Framework", v => { IsUnifiedFullXamMacFramework = true; } }, | |||
{ "xamarin-system-framework", "Used with --target-framework=4.5 to select XM 4.5 Target Framework", v => { IsUnifiedFullSystemFramework = true; } }, | |||
{ "experimental-xm-aot", "Enable experimental AOT Xamarin.Mac support. Careful, the pieces might be sharp.", v => { experimental_xm_aot = true; }, true }, // Experimental - If it breaks for now you get to keep the pieces |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would name this experimental-aot
(imho the xm
part is redundant).
@@ -771,12 +773,35 @@ static void Pack (IList<string> unprocessed) | |||
if (App.LinkMode != LinkMode.All && App.RuntimeOptions != null) | |||
App.RuntimeOptions.Write (App.AppDirectory); | |||
|
|||
if (experimental_xm_aot.HasValue && experimental_xm_aot.Value && IsUnified) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe show an error if aot is requested for Classic instead of silently ignoring it.
if (!string.IsNullOrEmpty (certificate_name)) { | ||
CodeSign (); | ||
Watch ("Code Sign", 1); | ||
} | ||
} | ||
|
||
static void AOTBundle () | ||
{ | ||
string monoExe = Is64Bit ? "/usr/local/bin/mono64" : "/usr/local/bin/mono"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think /Library/Frameworks/Mono.framework/Commands
is the supported location of the mono binaries.
Also I'd use mono32
and mono64
, since I think the mono binary one day will switch to be 64-bit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... not sure mono32
can AOT 64bits code.
I think that XM needs to ship it's own AOT compilers since the system mono might not match with the BCL version XM ships.
IOW the above code should be fine when using the system mono (as long as both 32 and 64 bits are shipping) but it might fail for the bundle 4.5 support coming out of XM.
For a first preview it might be good enough to specify which mono version(s) is/are compatible.
string quotedFileList = string.Join (" ", dirInfo.EnumerateFiles ().Where (aotableFile).Select (x => Quote(x.ToString ()))); | ||
foreach (var file in dirInfo.EnumerateFiles ().Where (aotableFile)) | ||
{ | ||
if (RunCommand (monoExe, String.Format ("--aot=hybrid {0}", Quote (file.ToString ())), new string [] {"MONO_PATH", mmp_dir }) > 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be parallelized to speed it up significantly.
mtouch currently uses Parallel.ForEach
to AOT in parallel [1] (the default is to set MaxDegreeOfParallelism to the number of processors, but this can be overridden by passing -jX /--jobs X (like for make) to motuch).
Build failure |
Build failure |
case "all": | ||
aot = AotType.All; | ||
break; | ||
case "platform": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another possibility here is sdk
: every assembly in the XM SDK (that we ship).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another syntax idea (but yours is fine if you like it better):
--aot:+System.dll,-MyCustom.dll
which would set AotType.Explicit, enable AOT for System.dll and disable it for MyCustom.dll
This is how mtouch' --dlsym: option works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rolfbjarne Lining up with how mtouch does things is good enough for me. :) I'll rework
case AotType.Explicit: | ||
return aot_explicit_reference.Contains (x.Name); | ||
default: | ||
throw new InvalidOperationException ($"AOTBundle with aot: {aot}?"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should have a better error number, maybe something like this: https://github.com/rolfbjarne/xamarin-macios/blob/framework-sdk/tools/mtouch/error.cs#L108
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
|
||
Parallel.ForEach (dirInfo.EnumerateFiles ().Where (aotableFile), new ParallelOptions () { MaxDegreeOfParallelism = Driver.Concurrency }, file => { | ||
if (RunCommand (monoExe, String.Format ("--aot=hybrid {0}", Quote (file.ToString ())), new string [] {"MONO_PATH", mmp_dir }) > 0) | ||
ErrorHelper.Warning (1337, string.Format ("AOT failed on {0}", file)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe make this an error? Users can now ignore specific assemblies if they're causing trouble, while still AOT-ing the rest, so making it an error won't prevent people from enabling AOT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it was a warning from back before ignore was an option. 👍
Build failure |
Build success |
// MM5103 Failed to compile. Error code - {0}. Please file a bug report at http://bugzilla.xamarin.com | ||
// MM5104 ** reserved mtouch ** | ||
// MM5105 Failed to AOT compile. Error code - {0}. Please file a bug report at http://bugzilla.xamarin.com |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MT3xxx
segment is reserved for AOT compiler errors
Build failure |
aotFiles.Add (file); | ||
break; | ||
case AotType.SDK: | ||
if (fileName == "Xamarin.Mac.dll" || fileName == "System.dll" || fileName == "mscorlib.dll") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for limiting "SDK" to these three assemblies? We already have a Profile.IsSdkAssembly method you can use: https://github.com/xamarin/xamarin-macios/blob/master/tools/mmp/driver.cs#L687
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No good reason. Let me use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So @rolfbjarne there is apparently a good reason:
The list of SDK assemblies turns out to be the entire BCL pretty much + the Xamarin.Mac bits.
The idea behind the SDK option was to be a middle ground of the stuff pulled in always while being fast.
I'm open to changing this list, or renaming it if you can think of a better name. Swapping to Profile.IsSdkAssembly would make it almost the same as All.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not overload (and confuse) the meaning of SDK in the tooling. Rename it to something else, e.g. core
?
FWIW sdk
might be an valid (we lack data to see if it's a good one) option, it's definitively a good one for the linker (and we should avoid confusion between them).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like core
as well, for the same reasons Sebastien mentions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if (!IsAOT) | ||
throw ErrorHelper.CreateError (0099, "Internal error \"AOTBundle with aot: {0}\" Please file a bug report with a test case (http://bugzilla.xamarin.com).", aotType); | ||
|
||
const string MonoExePath = "/Library/Frameworks/Xamarin.Mac.framework/Commands/bmac-mobile-mono"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't take XAMMAC_FRAMEWORK_PATH into account, you already have a method to get it: https://github.com/xamarin/xamarin-macios/blob/master/tools/mmp/driver.cs#L963
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch.
- Stop hard coded bmac-mobile-mono path - Rename sdk to core - Add real sdk option to AOT
Build failure |
Build error is my fault. Fixing. |
Build success |
@spouliot / @rolfbjarne Any more changes for this PR? |
The only outstanding thing on my end is to add the 32-bit mono to what we ship and remove the "only allow AOT in 64-bit" check. |
Ok. 32-bit changes are in. QA got back to us and said it will be awhile until they can test things manually. I'd like to get this in master now. We can rip out the option late in C10 if things unlikely don't work out. @rolfbjarne / @spouliot - Ready to go? Can I get an approve changes if 👍 |
Build failure |
@chamons 👍 please update the release notes in the wiki |
if (!IsAOT) | ||
throw ErrorHelper.CreateError (0099, "Internal error \"AOTBundle with aot: {0}\" Please file a bug report with a test case (http://bugzilla.xamarin.com).", aotType); | ||
|
||
string monoExePath = Path.Combine (XamarinMacPrefix, "bin/bmac-mobile-mono" + (Is64Bit ? "" : "-32")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work for all the three profiles (mobile, xm 4.5 and system)? I believe we'll have to use the system mono when using the system profile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bah. You are right. I incorrectly assumed that as long as we got the assemblies in place by the rest of the system, AOT could not care about which mono (system or built in) was used.
Let me rework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Build failure |
Build failure |
build |
Build failure |
build |
Build failure |
Test failure is a known issue in the mac bindings tests and is unrelated I believe. |
No description provided.