Skip to content
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

The AOT compiler doesn't support a MONO_PATH with a colon #90422

Closed
rolfbjarne opened this issue Aug 11, 2023 · 6 comments
Closed

The AOT compiler doesn't support a MONO_PATH with a colon #90422

rolfbjarne opened this issue Aug 11, 2023 · 6 comments
Assignees
Milestone

Comments

@rolfbjarne
Copy link
Member

Description

We use MONO_PATH to point to the directory where all the assemblies are for the AOT compiler.

Unfortunately, the Mono allows for multiple paths in MONO_PATH, splitting them by colon:

split = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 1000);

this means that we can't use the AOT compiler for a path with a colon in it.

Now why would that ever happen?

It happens when building remotely from Windows, and [Intermediate]OutputPath is set to a full (Windows) path. In that case, all the assemblies end up in a directory with a colon in it on the Mac: xamarin/xamarin-macios#14904.

This wasn't very common, because [Intermediate]OutputPath used to be relative paths. However, with the new artifacts output path in .NET 8, [Intermediate]OutputPath are both absolute paths.

Reproduction Steps

mkdir colonexample && cd colonexample
dotnet new ios
dotnet build /p:RuntimeIdentifier=ios-arm64 /p:IntermediateOutputPath=$PWD/l:i:b/ /bl
[...]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.7090/targets/Xamarin.Shared.Sdk.targets(1045,3): error : Failed to AOT compile System.Runtime.dll, the AOT compiler exited with code 134 [/Users/rolf/test/dotnet/colonexample/colonexample.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.7090/targets/Xamarin.Shared.Sdk.targets(1045,3): error : Failed to AOT compile System.Runtime.InteropServices.dll, the AOT compiler exited with code 134 [/Users/rolf/test/dotnet/colonexample/colonexample.csproj]
/usr/local/share/dotnet/packs/Microsoft.iOS.Sdk/16.4.7090/targets/Xamarin.Shared.Sdk.targets(1045,3): error : Failed to AOT compile colonexample.dll, the AOT compiler exited with code 134 [/Users/rolf/test/dotnet/colonexample/colonexample.csproj]
[...]

Expected behavior

No crash.

Actual behavior

Crash.

Binlog:
msbuild.binlog.zip

Regression?

No, but importance has increased due to unrelated changes making the scenario more frequent.

Known Workarounds

No response

Configuration

$ $ dotnet --info
.NET SDK:
 Version:   7.0.306
 Commit:    f500069cb7

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  13.5
 OS Platform: Darwin
 RID:         osx.13-arm64
 Base Path:   /usr/local/share/dotnet/sdk/7.0.306/

Host:
  Version:      7.0.9
  Architecture: arm64
  Commit:       8e9a17b221

.NET SDKs installed:
  7.0.306 [/usr/local/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Other information

No response

@ghost ghost added the untriaged New issue has not been triaged by the area owner label Aug 11, 2023
@SamMonoRT SamMonoRT removed the untriaged New issue has not been triaged by the area owner label Aug 14, 2023
@SamMonoRT SamMonoRT added this to the 8.0.0 milestone Aug 14, 2023
@vargaz
Copy link
Contributor

vargaz commented Aug 14, 2023

Colon is the unix path separator. Maybe we can support a backslash escaped colon.

@kotlarmilos
Copy link
Member

kotlarmilos commented Aug 14, 2023

Colon is the unix path separator. Maybe we can support a backslash escaped colon.

Would that require changing Xamarin build to escape the paths?

It happens when building remotely from Windows

@rolfbjarne Does that mean targeting Windows from Unix platforms (or other way)?

As Zoltan said, ':' is the unix path separator, while ';' is the windows path separator. It is already implemented in that way, but may require changing the HOST_WIN32 to TARGET_WIN32 in:

if(HOST_WIN32)
set(EGLIB_GNUC_PRETTY "__FUNCTION__")
set(EGLIB_BREAKPOINT "__debugbreak()")
set(EGLIB_PATHSEP "\\\\")
set(EGLIB_SEARCHSEP ";")
set(EGLIB_OS "WIN32")
set(EGLIB_PIDTYPE "void *")
if(HOST_AMD64 OR HOST_ARM64)
set(EGLIB_GSIZE_FORMAT "\"Iu\"")
else()
set(EGLIB_GSIZE_FORMAT "\"u\"")
endif()
else()
set(EGLIB_BREAKPOINT "G_STMT_START { raise(SIGTRAP); } G_STMT_END")
if(GCC)
set(EGLIB_GNUC_UNUSED "__attribute__((__unused__))")
set(EGLIB_GNUC_NORETURN "__attribute__((__noreturn__))")
if(HOST_AMD64 OR HOST_X86)
set(EGLIB_BREAKPOINT "G_STMT_START { __asm__(\"int \$03\"); } G_STMT_END")
endif()
endif()
set(EGLIB_PATHSEP "/")
set(EGLIB_SEARCHSEP ":")
set(EGLIB_OS "UNIX")
set(EGLIB_PIDTYPE "int")
set(EGLIB_GSIZE_FORMAT "\"zu\"")
endif()

As a quick fix, we may implement escaping the ':\' for windows targets only.

@rolfbjarne
Copy link
Member Author

Colon is the unix path separator. Maybe we can support a backslash escaped colon.

Would that require changing Xamarin build to escape the paths?

Yes.

It happens when building remotely from Windows

@rolfbjarne Does that mean targeting Windows from Unix platforms (or other way)?

It means building an iOS project on a (remote) Mac using Windows.

As a quick fix, we may implement escaping the ':' for windows targets only.

This isn't happening when executing on Windows, it's when executing on Mac, so doing something for Windows only won't help us :)

That said, I believe that adding an escaping mechanism would be the solution (while colon is the unix path separator, it's also a legal character in a file name).

@vargaz
Copy link
Contributor

vargaz commented Aug 14, 2023

Another option would be adding a --path command line argument which would append to the path.

@ghost ghost added in-pr There is an active PR which will close this issue when it is merged and removed in-pr There is an active PR which will close this issue when it is merged labels Aug 14, 2023
@SamMonoRT
Copy link
Member

PR to fix this is #90544

@SamMonoRT
Copy link
Member

This is fixed, PR merged to 8.0\rc1. Closing this issue

@ghost ghost locked as resolved and limited conversation to collaborators Sep 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants