Skip to content

MacOS arm64 builds are failing on M1 devices #47172

Description

@mangod9

Description

After the latest change of using crossgen2 to build System.Private.CoreLib.dll. The issue seems to be related to using the right bitness of crossgen2 while compiling. Cross compilation from Intel machines should continue to work

Configuration

Build runtime on an M1 device with ./build.sh -subset clr -arch arm64 fails with

  Unhandled exception. System.DllNotFoundException: Unable to load shared library 'jitinterface_x64' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libjitinterface_x64, 1): image not found
     at System.Runtime.InteropServices.NativeLibrary.LoadByName(String libraryName, QCallAssembly callingAssembly, Boolean hasDllImportSearchPathFlag, UInt32 dllImportSearchPathFlag, Boolean throwOnError)
     at System.Runtime.InteropServices.NativeLibrary.LoadLibraryByName(String libraryName, Assembly assembly, Nullable`1 searchPath, Boolean throwOnError)
     at System.Runtime.InteropServices.NativeLibrary.Load(String libraryName, Assembly assembly, Nullable`1 searchPath)
     at Internal.JitInterface.JitConfigProvider.<>c__DisplayClass5_0.<Initialize>b__0(String libName, Assembly assembly, Nullable`1 searchPath) in /Users/usr/git/runtime/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs:line 61
     at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName, Assembly assembly, Boolean hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags)
     at Internal.JitInterface.CorInfoImpl.GetJitHost(IntPtr configProvider)
     at Internal.JitInterface.CorInfoImpl.Startup() in /Users/usr/git/runtime/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs:line 116
     at Internal.JitInterface.JitConfigProvider.Initialize(TargetDetails target, IEnumerable`1 jitFlags, IEnumerable`1 parameters, String jitPath) in /Users/usr/git/runtime/src/coreclr/tools/Common/JitInterface/JitConfigProvider.cs:line 69
     at ILCompiler.ReadyToRunCodegenCompilationBuilder.ToCompilation() in /Users/usr/git/runtime/src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs:line 254
     at ILCompiler.Program.Run(String[] args) in /Users/usr/git/runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 602
     at ILCompiler.Program.Main(String[] args) in /Users/usr/git/runtime/src/coreclr/tools/aot/crossgen2/Program.cs:line 754

Regression?

Building on M1 is new, but it was working before the switch to crossgen2. using arch -x86_64 ./build.sh -subset clr -arch arm64 doesnt help either. Switching back to using cg1 is a workaround for now.

Other information

This is most likely since the default .dotnet used for build is x64, but the build logic assumes its arm64 since that is the host its running on. Might need to special case to always assume x64 during builds.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions