-
Notifications
You must be signed in to change notification settings - Fork 37
Building PSharp-as-language samples fails on macOS #413
Comments
I don't think LanguageServices will build on mac because of Roslyn dependencies that are unavailable for .net core. Is that right, @pdeligia? |
That is correct. Right now, if you want to use P# with .NET core you need to use it as a library, and thus can only use the framework samples. Basically, the .NET core port of P# is incomplete. The core library and production runtime as well as the testing services are fully supported in .NET core, but the language services, compiler and syntax rewriter (that the language-version samples depend upon) are not fully ported to .NET core yet. If I remember correctly, there were some API incompatibilities (because we are using some libraries that were not supported in .NET core when I worked on the port). There should be workarounds (or perhaps these APIs are now supported), but we have not looked into this lately. Saying this, we are happy to accept contributions to finish these parts of the .NET core port, but we are also planning to do this (but on low priority for now). |
When you talk about API incompatibilities, are you referring to MSBuildWorkspace, i.e., Roslyn issue 17974? The funny thing is, a month or two ago I was playing with the language samples, and I am pretty sure I managed to somehow get them to compile and run. I am not sure how that was possible, because indeed now I see LanguageServices depend on MSBuildWorkspace, which is apparently still incompatible with .NET Core. |
I made some progress on this. The good news is that the Roslyn daily build from the Roslyn MyGet feed is compatible with .NET core 2.1. So after bumping the Roslyn version and adjusting the dependencies and target frameworks, I can build all components of PSharp, including the compiler and the syntax rewriter. There are some failing unit tests in StaticAnalysis mostly caused by latent bugs that perhaps did not manifest themselves before (like dereferencing null references), but this is a topic for a separate issue report. What I am facing now are assembly loading issues. Namely, when building the language samples, MSBuild loads PSharpSyntaxRewriter.dll, but doesn't know where to find its dependencies:
The assembly in question is installed as a package for the PSharp solution and all the necessary dependency metadata is stored next to the DLL, but I guess MSBuild doesn't take it into account. So I need to investigate how exactly MSBuild resolves dependencies for build tasks. |
I succeeded in making the language samples work on macOS (and more generally, on .NET Core 2.1, so they should work on Linux as well). More importantly, this means that one can use P# as a language on these systems. Since the solution depends on the beta version of Roslyn, for now it is a workaround. Check it out in my PSharp fork. To deal with the assembly loading issue I mentioned in my previous comment, it turns out it is best not to have build tasks with dependencies. So I have switched to using SyntaxRewriterProcess, which I adapted to use the ToolTask API instead of manually spawning the rewriter process. |
What you describe sounds great @fniksic! Thanks a lot for driving this. I would be very happy to review and merge your solution, if you would like to open a PR? Since your solution depends on a beta version of Roslyn, we could use conditional compilation to target that version of Roslyn for .NET Core (and keep the existing version for .NET Framework to not break existing users of the language syntax) until its released. We can then move everything to your solution. |
I am having issues trying to build PSharp-as-language samples on macOS. Building PSharp itself works without problems by executing:
I can then build PSharp-as-framework samples by executing:
However, if I try executing
I get a number of error messages of the following form:
The csproj files reference the file Samples/Language/build.props, which in turn references a non-existing file bin/net46/PSharp.vs2017.targets. As far as I understand, the file is supposed to be copied from Tools/Compilation/SyntaxRewriter/PSharp.vs2017.targets, and it's purpose is to define a build task that runs PSharpSyntaxRewriter to rewrite PSharp files into C# files. So I tried to manually copy the file. There's a number of smaller changes I had to do as well:
Unfortunately, the build still doesn't go through. Here's the sample message I get:
I tried to run the syntax rewriter manually just to see if I can rewrite s PSharp file. It turns out this fails as well:
I guess there is some problem with the way dependencies are defined in Tools/Compilation/SyntaxRewriter/SyntaxRewriter.csproj. I will continue investigating the issue, but if someone with a better understanding of the build process knows how to quickly make this work, I would appreciate the help.
The text was updated successfully, but these errors were encountered: