Bug 60415 - AOT directory is not build in extension projects
Summary: AOT directory is not build in extension projects
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools ()
Version: unspecified
Hardware: PC Mac OS
: --- normal
Target Milestone: 15.6
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-10-27 14:32 UTC by Manuel de la Peña [MSFT]
Modified: 2017-11-17 17:43 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: No
Last known good build:


Attachments
Sample project showing the issue. (23.83 KB, application/zip)
2017-10-27 14:34 UTC, Manuel de la Peña [MSFT]
Details
build.log (786.62 KB, text/plain)
2017-11-06 16:21 UTC, Manuel de la Peña [MSFT]
Details
Build.zip (641.86 KB, application/zip)
2017-11-06 16:25 UTC, Manuel de la Peña [MSFT]
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Manuel de la Peña [MSFT] 2017-10-27 14:32:06 UTC
Although the parameters are passed to the project to create the AOT directory, this is not created and the iOS tools fail with a warning stating that the directory could not be found.

Attached is a sample project that shows the issue. The directory should be created and the copied via de msym-copy but this fails since the dir is not present.
Comment 1 Manuel de la Peña [MSFT] 2017-10-27 14:34:28 UTC
Created attachment 25485 [details]
Sample project showing the issue.
Comment 2 Zoltan Varga 2017-10-27 18:00:42 UTC
Can you attach the build output ?
Comment 3 Manuel de la Peña [MSFT] 2017-11-06 16:21:37 UTC
Created attachment 25564 [details]
build.log

Full build log.
Comment 4 Manuel de la Peña [MSFT] 2017-11-06 16:25:04 UTC
Created attachment 25565 [details]
Build.zip

Added the retouch-cache that contains the Msym folder and the files generated for it. For some reason we have in the path ./msymtest/myactionextension/obj/iPhone/Release/mtouch-cache/64/Build/Msym/Msym/tmp/ Not quite sure why we are getting Mysm/Msym in the path, that could be the issue when msym-copy fails.
Comment 5 Zoltan Varga 2017-11-06 23:47:41 UTC
The aot compiler is invoked as follows:

    MONO_PATH=/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/64/Build /Library/Frameworks/Xamarin.iOS.framework/Versions/11.2.0.11/bin/arm64-darwin-mono-sgen --debug -O=gsharedvt -O=float32  --aot=mtriple=arm64-ios,data-outfile=/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/arm64/msymtest.aotdata.arm64,static,asmonly,direct-icalls,full,nodebug,dwarfdebug,msym-dir=/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/64/Build/Msym,outfile=/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/arm64/msymtest.exe.s "/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/64/Build/msymtest.exe"

So the msym files, if generated, should end up in the '/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/64/Build/Msym' directory, not the directory where the normal aot outputs are.
Comment 6 Manuel de la Peña [MSFT] 2017-11-16 13:44:05 UTC
Looking at some extra log messages I added we have when building the project:

For the application:

App is extension False
App executable name msymtest
Enabling msym generation
Msym setting path is 'msym-dir=/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/64/Build/Msym'

For the extension:

App is extension True
App executable name myactionextension
Enabling msym generation
Msym setting path is 'msym-dir=/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/64/Build/Msym'

The output path is calculated in 

public static string GetAotArguments (Application app, string filename, Abi abi, string outputDir, string outputFile, string llvmOutputFile, string dataFile)

With => StringUtils.Quote (Path.Combine (outputDir, "Msym"));

So, the error is that when we try to copy the AOT files of the extension from 

/Users/mandel/Downloads/msymtest/myactionextension/obj/iPhone/Release/mtouch-cache/64/Build/Msym

we fail because the path passed to the compiler was:

/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/64/Build/Msym

that is, we have the msym files of the extension in the same path of the application. Yet the target.BuildDirectory seems to be pointing to a different path,  which is 

/Users/mandel/Downloads/msymtest/myactionextension/obj/iPhone/Release/mtouch-cache/64/Build/Msym

The Msym dir is not present and therefore assume that the files were not generated. I think that the correct fix would be to ensure that the output dir that we pass to the GetAOTParameters method is the correct one for the extension.
Comment 7 Rolf Bjarne Kvinge [MSFT] 2017-11-16 15:18:21 UTC
(In reply to Manuel de la Peña from comment #6)
> Looking at some extra log messages I added we have when building the project:
> 
> For the application:
> 
> App is extension False
> App executable name msymtest
> Enabling msym generation
> Msym setting path is
> 'msym-dir=/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/
> mtouch-cache/64/Build/Msym'
> 
> For the extension:
> 
> App is extension True
> App executable name myactionextension
> Enabling msym generation
> Msym setting path is
> 'msym-dir=/Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/
> mtouch-cache/64/Build/Msym'
> 
> The output path is calculated in 
> 
> public static string GetAotArguments (Application app, string filename, Abi
> abi, string outputDir, string outputFile, string llvmOutputFile, string
> dataFile)
> 
> With => StringUtils.Quote (Path.Combine (outputDir, "Msym"));
> 
> So, the error is that when we try to copy the AOT files of the extension
> from 
> 
> /Users/mandel/Downloads/msymtest/myactionextension/obj/iPhone/Release/mtouch-
> cache/64/Build/Msym
> 
> we fail because the path passed to the compiler was:
> 
> /Users/mandel/Downloads/msymtest/msymtest/obj/iPhone/Release/mtouch-cache/64/
> Build/Msym
> 
> that is, we have the msym files of the extension in the same path of the
> application.

This is normal when sharing native code between the main app and the extension (in which the native code for most of the assemblies is shared between the app and the extension, and for the remaining extension-exclusive assemblies we just use the same target directory).

If you disable native code sharing (by passing --nodevcodeshare to mtouch), you can see that we AOT compile into different directories (for mSYM support we should of course support both scenarios).
Comment 8 Sebastien Pouliot 2017-11-16 16:59:27 UTC
https://github.com/xamarin/xamarin-macios/pull/3016