-
Notifications
You must be signed in to change notification settings - Fork 133
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
[mono] msbuild aborts due to 4.7 dependencies #2618
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
I filed #2596 to track getting CI with a mono-based stack to identify these mono-only issues earlier. |
[Triage] This issue is tracking the overall s390x/mono issue. @crummel, Can you link the related issues in the product repos. |
[Triage] @crummel can you check if the underlying issue has been resolved? |
This is still a relevant issue although it has been worked around. It's a symptom of the whole issue with mono trying to load the MSBuild full-framework assemblies eagerly instead of delaying loading them until they are needed like CoreCLR does, which causes issues because they are missing in source-built packages. |
Do we have an issue in dotnet/runtime which tracks this for mono? |
My understanding was that the Mono behavior isn't actually wrong, just different from CoreCLR - the CIL standard allows either. That's why I opened this as a bug here to fix the code that contains those references, instead of against Mono. |
[Triage] @crummel - please validate this is still an issue for .net 7.0. |
@MichaelSimons in .net 7.0 this particular issue no longer shows up, as msbuild no longer use 4.7.0 versions of these libraries, but was upgraded to 6.0 here: |
@uweigand - is a fix needed for 6.0 or can this issue be closed? |
I don't think we need a 6.0 fix at this time. The Red Hat RPMs for 6.0 still have a local workaround applied. |
Building the .NET 6 final source-build on s390x (using the Mono runtime) results in an msbuild assembly that will always crash on startup, via an exception along these lines:
The
System.Configuration.ConfigurationManager
assembly that is missing here is hard-coded to use a 4.7.0 version in the msbuildeng/Packages.props
file:When doing a non-source-build build, the version of this assembly gets restored from a nuget package and is actually included in the resulting SDK tarball.
However, when using source-build, that nuget package is not used, and the assembly is not present in the SDK tarball, but there is still a dependency on it from msbuild, as can be seen e.g. in the
sdk/6.0.100/MSBuild.deps.json
file that is in the tarball:Types defined by the missing assembly are used for members of
ToolsetConfigurationReader
, which is why the Mono JIT aborts when attempting to build the constructor (or other functions) of that class. This happens in particular when building the routineInitializeToolsetCollection
from the above error message, which is always called on msbuild startup.Now, I think that this happens to work even in the absence of that assembly on CoreCLR, because the
ToolsetConfigurationReader
is not actually used when running msbuild on Linux, instances of it are just passed around. That is because any actual use of the configuration reader is guarded (inToolsetReader.ReadAllToolsets
) by this check:and the default value of
locations
is provided byMicrosoft.Build.Evaluation.ToolsetDefinitionLocation:Default
, which is defined as:Note that when building on Linux, the
FEATURE_SYSTEM_CONFIGURATION
define is false, and thereforeConfigurationFile
is not included in theDefault
value.And indeed, adding a
FEATURE_SYSTEM_CONFIGURATION
guard to all places whereToolsetConfigurationReader
is referenced makes the abort go away, with no apparent adverse effect on the operation of msbuild otherwise. However, there are still places in the msbuild unit test that apparently deliberately use theConfigurationFile
setting even on Linux - not sure what to do about those.There is a second missing dependency on a 4.7 assembly,
System.Security.Permissions
, which causes similar aborts during JIT. In this case, the functionMicrosoft.Build.Shared.ExceptionHandling.IsXmlException
cannot be compiled on Mono as it refers to a typeXmlSyntaxException
defined bySystem.Security.Permissions
.This case triggers much more rarely, only when msbuild runs into some other exception that it would otherwise be able to recover from. I've seen this when building the runtime repo on s390x - msbuild gets a
DirectoryNotFoundException
during a restore operation since somecrossgen2
directory is not present (due to building for Mono which doesn't support crossgen2), and it would normally just recover and ignore that exception, but in the process theIsXmlException
routine is called, but it cannot be JITed.Putting the use of
XmlSyntaxException
under a#if FEATURE_SECURITY_PERMISSIONS
guard makes that abort go away for me as well. With those two work-arounds applies, I can bootstrap source-build (i.e run the source-build using a source-built SDK) on s390x successfully.It seems strange that a Linux build of the SDK even has any references to those 4.7 assemblies (which I understand are Windows only?) in the first place. What is the appropriate fix for these issues?
CC @crummel @leecow @omajid @tmds
The text was updated successfully, but these errors were encountered: