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

[VMR] linux/mac-arm64 cross build fails w/ CoreCLR runtime #3698

Closed
steveisok opened this issue Oct 30, 2023 · 7 comments · Fixed by dotnet/installer#18915
Closed

[VMR] linux/mac-arm64 cross build fails w/ CoreCLR runtime #3698

steveisok opened this issue Oct 30, 2023 · 7 comments · Fixed by dotnet/installer#18915
Assignees

Comments

@steveisok
Copy link
Member

Describe the Bug

When triggering a building targeting arm64 from a linux or mac x64 host, the VMR build will fail at runtime with the following error:

      [ 29%] Building CXX object nativeaot/Runtime/Full/CMakeFiles/Runtime.ServerGC.dir/__/EHHelpers.cpp.o
      [ 29%] Building CXX object pal/src/CMakeFiles/coreclrpal.dir/thread/threadsusp.cpp.o
      /Users/steve/dev/dotnet-vmr/src/runtime/artifacts/source-build/self/src/src/coreclr/pal/src/synchmgr/synchmanager.cpp:4633:6: error: "Don't know how to get hi-res current time on this platform"
          #error "Don't know how to get hi-res current time on this platform"
           ^
      [ 30%] Building CXX object nativeaot/Runtime/Full/CMakeFiles/Runtime.WorkstationGC.dir/__/MethodTable.cpp.o
      1 error generated.
      make[2]: *** [pal/src/CMakeFiles/coreclrpal.dir/synchmgr/synchmanager.cpp.o] Error 1
      make[2]: *** Waiting for unfinished jobs....

Steps to Reproduce

For Mac:

./prep.sh 
./build.sh --online -- /p:OverrideTargetRid=osx-arm64

For Linux:

docker run -e CROSSCOMPILE=1 -e ROOTFS_DIR=/crossrootfs/arm64 -w pwd--platform linux/amd64 -vpwd:pwd -it mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64 
./build.sh --online -- /p:OverrideTargetRid=linux-arm64

Other Information

@dotnet-issue-labeler
Copy link

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.

@steveisok
Copy link
Member Author

/cc @jkoritzinsky

@directhex
Copy link

This is the error I get with Linux:

      Executing "/home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/src/coreclr/build-runtime.sh" -cmakeargs "-DCLR_CROSS_COMPONENTS_BUILD=1" -arm64 -release -ci -portablebuild=false -keepnativesymbols -os linux -hostarch x64 -hostos linux -outputrid linux-arm64 -component crosscomponents
      Commencing CoreCLR Repo build
      __OutputRid: linux-arm64
      Setting up directories for build
      Checking prerequisites...
      Commencing build of "  crosscomponents " target in "CoreCLR component" for linux.arm64.Release in /home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/obj/coreclr/linux.arm64.Release/x64
      Invoking "/home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/eng/native/gen-buildsys.sh" "/home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/src/coreclr" "/home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/obj/coreclr/linux.arm64.Release/x64" x64 linux clang Release ""  -DCLR_CMAKE_TARGET_ARCH=arm64 -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_PATH= -DCLR_CMAKE_PGO_OPTIMIZE=0 -DCLI_CMAKE_FALLBACK_OS="linux" -DFEATURE_DISTRO_AGNOSTIC_SSL=1 -DCLR_CROSS_COMPONENTS_BUILD=1  -DCLR_CMAKE_KEEP_NATIVE_SYMBOLS=true
      /home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/obj/coreclr/linux.arm64.Release/x64 /home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/src/coreclr
      Not searching for unused variables given on the command line.
      loading initial cache file /home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/eng/native/tryrun.cmake
      -- The C compiler identification is Clang 16.0.0
      -- The CXX compiler identification is Clang 16.0.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - failed
      -- Check for working C compiler: /usr/local/bin/clang-16
      -- Check for working C compiler: /usr/local/bin/clang-16 - broken
      CMake Error at /usr/share/cmake-3.21/Modules/CMakeTestCCompiler.cmake:69 (message):
        The C compiler
      
          "/usr/local/bin/clang-16"
      
        is not able to compile a simple test program.
      
        It fails with the following output:
      
          Change Dir: /home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/obj/coreclr/linux.arm64.Release/x64/CMakeFiles/CMakeTmp
          
          Run Build Command(s):/usr/bin/make -f Makefile cmTC_f4a38/fast && /usr/bin/make  -f CMakeFiles/cmTC_f4a38.dir/build.make CMakeFiles/cmTC_f4a38.dir/build
          make[1]: Entering directory '/home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/obj/coreclr/linux.arm64.Release/x64/CMakeFiles/CMakeTmp'
          Building C object CMakeFiles/cmTC_f4a38.dir/testCCompiler.c.o
          /usr/local/bin/clang-16 --target=x86_64-linux-gnu --gcc-toolchain=/crossrootfs/arm64/usr --sysroot=/crossrootfs/arm64    -MD -MT CMakeFiles/cmTC_f4a38.dir/testCCompiler.c.o -MF CMakeFiles/cmTC_f4a38.dir/testCCompiler.c.o.d -o CMakeFiles/cmTC_f4a38.dir/testCCompiler.c.o -c /home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/obj/coreclr/linux.arm64.Release/x64/CMakeFiles/CMakeTmp/testCCompiler.c
          Linking C executable cmTC_f4a38
          /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_f4a38.dir/link.txt --verbose=1
          /usr/local/bin/clang-16 --target=x86_64-linux-gnu --gcc-toolchain=/crossrootfs/arm64/usr --sysroot=/crossrootfs/arm64 -Wl,--rpath-link=/crossrootfs/arm64/lib/x86_64-linux-gnu -Wl,--rpath-link=/crossrootfs/arm64/usr/lib/x86_64-linux-gnu -Wl,--rpath-link=/crossrootfs/arm64/lib/x86_64-linux-gnu -Wl,--rpath-link=/crossrootfs/arm64/usr/lib/x86_64-linux-gnu -fuse-ld=lld  CMakeFiles/cmTC_f4a38.dir/testCCompiler.c.o -o cmTC_f4a38 
          ld.lld: error: cannot open Scrt1.o: No such file or directory
          ld.lld: error: cannot open crti.o: No such file or directory
          ld.lld: error: cannot open crtbeginS.o: No such file or directory
          ld.lld: error: unable to find library -lgcc
          ld.lld: error: unable to find library -lgcc_s
          ld.lld: error: unable to find library -lc
          ld.lld: error: unable to find library -lgcc
          ld.lld: error: unable to find library -lgcc_s
          ld.lld: error: cannot open crtendS.o: No such file or directory
          ld.lld: error: cannot open crtn.o: No such file or directory
          clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
          make[1]: *** [CMakeFiles/cmTC_f4a38.dir/build.make:100: cmTC_f4a38] Error 1
          make[1]: Leaving directory '/home/directhex/Projects/dotnet/src/runtime/artifacts/source-build/self/src/artifacts/obj/coreclr/linux.arm64.Release/x64/CMakeFiles/CMakeTmp'
          make: *** [Makefile:127: cmTC_f4a38/fast] Error 2
          
          
      
        
      
        CMake will not be able to correctly generate this project.
      Call Stack (most recent call first):
        CMakeLists.txt:9 (project)
      
      
      -- Configuring incomplete, errors occurred!

I don't know enough about CoreCLR to know what crosscomponents is, but if it's needed, it indicates a need for bi-arch Docker images to satisfy the attempts to compile x64 code for the x64 host on the arm64 build (a valid need in theory, but every instance needs auditing)

@steveisok
Copy link
Member Author

@jtschuster @agocke looping you guys in too

@jtschuster
Copy link
Member

I have a build finished and the arm64 sdk runs on my machine with qemu.
I've made a PR on my fork with the diff for reference: jtschuster/dotnet#1

I have dotnet/dotnet cloned at /src/dotnet in wsl, then ran

> docker run -e ROOTFS_DIR=/crossrootfs/arm64 -w /src/dotnet --platform linux/amd64 -v \\wsl.localhost\Ubuntu\src\dotnet:/src/dotnet -it mcr.microsoft.com/dotnet-buildtools/prereqs:cbl-mariner-2.0-cross-arm64
$ ./prep.sh && ./build.sh --online -- /p:OverrideTargetRid=linux-arm64 /p:OverrideTargetArch=arm64

jtschuster added a commit to dotnet/runtime that referenced this issue Nov 22, 2023
To make the runtime compatible with cross-arch compilation, we should add --cross to the source-build build, and avoid publishing ReadyToRun or AOT compiled. The compilers don't have a valid runtime pack for the host during the cross-build at this point, so trying to run them fails.

Part of dotnet/source-build#3698
@jtschuster
Copy link
Member

jtschuster commented Dec 8, 2023

The issue requiring workarounds is that we don't specify the build machine's runtime pack as a prerequisite and runtime is told not to download packages (DotNetBuildOffline = true), even using --online at the root. The in-build crossgen and ilc are published self-contained, but without the runtime pack, they fail when they try to run. I've added workarounds for this so that the build can finish (see mentions above), but it's probably not what we want to ship. I can't figure out how to declare source-build prerequisites to properly fix this, can anyone point me to that?

jtschuster added a commit to dotnet/installer that referenced this issue Dec 11, 2023
In the VMR, we don't yet specify the host runtime pack as a prerequisite for cross-arch builds, so the crossgen2 package that would be run on the build machine doesn't work. For now we can work around this by not running crossgen on cross-arch VMR builds.

Related to dotnet/source-build#3698
@jtschuster
Copy link
Member

Made #3793 to track reenabling crossgen and ilc.

@jtschuster jtschuster self-assigned this Jan 12, 2024
jtschuster added a commit to dotnet/runtime that referenced this issue Jan 12, 2024
…iting in source-build (#96858)

In #75597, for source-build we replace all the RIDs with only the `PackageRID` in the `KnownFrameworkReference` for `NetCurrent` when we should have only added an additional RID.

This was causing issues in crossbuilds of vertical builds. The crossgen and ilc projects that run within the build require a runtime for the build machine's RID, but it wasn't found in `KnownFrameworkReference` and the build failed during restore.

Part of reenabling Crossgen and ILC in arm64 crossbuild verticals dotnet/source-build#3698
tmds pushed a commit to tmds/runtime that referenced this issue Jan 23, 2024
…iting in source-build (dotnet#96858)

In dotnet#75597, for source-build we replace all the RIDs with only the `PackageRID` in the `KnownFrameworkReference` for `NetCurrent` when we should have only added an additional RID.

This was causing issues in crossbuilds of vertical builds. The crossgen and ilc projects that run within the build require a runtime for the build machine's RID, but it wasn't found in `KnownFrameworkReference` and the build failed during restore.

Part of reenabling Crossgen and ILC in arm64 crossbuild verticals dotnet/source-build#3698
@jkoritzinsky jkoritzinsky self-assigned this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

5 participants