Bug 3984 - Cannot compile any async project
Summary: Cannot compile any async project
Status: RESOLVED FIXED
Alias: None
Product: Xamarin Studio
Classification: Desktop
Component: Project Model ()
Version: Trunk
Hardware: PC Linux
: Normal normal
Target Milestone: ---
Assignee: Mikayla Hutchinson [MSFT]
URL:
: 2042 ()
Depends on:
Blocks:
 
Reported: 2012-03-20 06:29 UTC by Marek Safar
Modified: 2012-05-03 15:46 UTC (History)
2 users (show)

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

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 Marek Safar 2012-03-20 06:29:32 UTC
Get Mono master and try to create a new project targeting .NET 4.5. MD uses dmcs compiler which is 4.0 bound and therefore fails to compile any async code.
Comment 1 Mikayla Hutchinson [MSFT] 2012-03-20 12:33:30 UTC
Pretty sure I gave you a patch for this a while back, but I don't recall what happened. If it worked for you, do you still have it?
Comment 2 Mikayla Hutchinson [MSFT] 2012-03-20 14:25:37 UTC
Found that patch: http://mjhutchinson.com/files/temp/md-mcs-corlib.diff
Comment 3 Marek Safar 2012-03-22 07:36:37 UTC
Yes, this works now.

Although it should explicitly reference mscorlib and not to depend on mcs to reference 4.5 mscorlib which will break once .net next is out.
Comment 4 Marek Safar 2012-03-22 07:37:21 UTC
.
Comment 5 Mikayla Hutchinson [MSFT] 2012-03-22 13:57:45 UTC
It does explicitly reference corlib, doesn't it? That's what the first hunk of the patch does.
Comment 6 Marek Safar 2012-03-22 13:59:34 UTC
I could not see any mscorlib reference in log MD shows when calling mcs
Comment 7 Mikayla Hutchinson [MSFT] 2012-03-22 14:10:13 UTC
Does the target framework definition XML file include corlib in its list of assemblies?
Comment 8 Marek Safar 2012-03-22 14:21:40 UTC
FrameworkList.xml contains only single line with path to all assemblies
Comment 9 Mikayla Hutchinson [MSFT] 2012-03-22 14:26:36 UTC
Okay, so it's relying on the fallback that enumerates all dll files from that directory. I assume that mscorlib.dll is present in that directory?

Maybe our logic for looking up the corlib from the framework definition is buggy. Does code completion show you members from the new corlib?
Comment 10 Marek Safar 2012-03-22 14:31:20 UTC
Yes, mscorlib.dll is present, otherwise I could not compile the code. code completion is also working for new mscorlib.

The compiler arguments as logged by MD are

mcs "/out:/home/marek/Projects/test45/test45/bin/Debug/test45.exe"
"/r:/home/marek/mono/lib/mono/4.5/System.dll"
"/r:/home/marek/mono/lib/mono/4.5/System.Core.dll"
/nologo
/warn:4
/debug:full
/optimize-
/codepage:utf8
/platform:x86
"/define:DEBUG"

/t:exe
"/home/marek/Projects/test45/test45/Main.cs"
"/home/marek/Projects/test45/test45/AssemblyInfo.cs"
Comment 11 Mikayla Hutchinson [MSFT] 2012-05-02 11:56:32 UTC
*** Bug 2042 has been marked as a duplicate of this bug. ***
Comment 12 Mikayla Hutchinson [MSFT] 2012-05-02 12:52:41 UTC
It seems the patch was reverted:
https://github.com/mono/monodevelop/commit/3baa0b83515d5d331a0f804181cd13a88864aa00

Jeff, how did this break MonoTouch?
Comment 13 Mikayla Hutchinson [MSFT] 2012-05-02 17:00:46 UTC
New patch, can you try this please?

http://mjhutchinson.com/files/temp/md-mcs-corlib.diff
Comment 14 Marek Safar 2012-05-02 17:07:48 UTC
Michael,

The patch is wrong it should have

+						corlib = project.AssemblyContext.GetAssemblyLocation (corlib, project.TargetFramework);
+						if (corlib != null && !alreadyAddedReference.Contains (corlib))
+							corlibRef = " \"/r:" + corlib + "\" ";
+							
+						sb.AppendLine ("-nostdlib");	

instead or you cannot compile mscorlib.dll itself
Comment 15 Mikayla Hutchinson [MSFT] 2012-05-02 17:27:12 UTC
And with that change it works?
Comment 16 Mikayla Hutchinson [MSFT] 2012-05-02 17:28:13 UTC
Wait, shouldn't you just set nostdlib when building mscorlib itself?
Comment 17 Mikayla Hutchinson [MSFT] 2012-05-02 17:39:13 UTC
Actually, that's a special case, when building mscorlib you should set
<NoStdLib>True</NoStdLib>
in your project configuration.

I updated the patch to error out when it can't find mscorlib.
Comment 18 Mikayla Hutchinson [MSFT] 2012-05-02 17:44:23 UTC
I also filed bug 4835 for UI for the NoStdLib option, but you can manually edit it into your csproj for now.
Comment 19 Mikayla Hutchinson [MSFT] 2012-05-03 15:46:54 UTC
Committed with cleanup.