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

Intermittent errors building CoreCLR on Windows ARM #104674

Closed
eiriktsarpalis opened this issue Jul 10, 2024 · 13 comments · Fixed by #104695 or #104763
Closed

Intermittent errors building CoreCLR on Windows ARM #104674

eiriktsarpalis opened this issue Jul 10, 2024 · 13 comments · Fixed by #104695 or #104763
Assignees
Milestone

Comments

@eiriktsarpalis
Copy link
Member

eiriktsarpalis commented Jul 10, 2024

When building CoreCLR on Windows ARM I sometimes get a Failed to create virtual memory for PCH error. I'm using a Snapdragon X Elite 78-100 CPU with 32 GB RAM and building the repo inside a Dev Drive. A few examples:

  FAILED: utilcode/CMakeFiles/utilcode_dac.dir/stgpool.cpp.obj
  C:\PROGRA~1\MICROS~3\2022\Preview\VC\Tools\MSVC\1441~1.340\bin\Hostx86\arm64\cl.exe  /nologo /TP -DDACCESS_COMPILE -DDEBUGGING_SUPPORTED -DDISABLE_C
  ONTRACTS -DFEATURE_BASICFREEZE -DFEATURE_CODE_VERSIONING -DFEATURE_COLLECTIBLE_TYPES -DFEATURE_COMINTEROP -DFEATURE_COMINTEROP_APARTMENT_SUPPORT -DF
  EATURE_COMINTEROP_UNMANAGED_ACTIVATION -DFEATURE_COMWRAPPERS -DFEATURE_CORECLR -DFEATURE_DEFAULT_INTERFACES -DFEATURE_EH_FUNCLETS -DFEATURE_EVENT_TR
  ACE -DFEATURE_HIJACK -DFEATURE_ICASTABLE -DFEATURE_IJW -DFEATURE_INSTANTIATINGSTUB_AS_IL -DFEATURE_INTEROP_DEBUGGING -DFEATURE_ISYM_READER -DFEATURE
  _MANUALLY_MANAGED_CARD_BUNDLES -DFEATURE_METADATA_UPDATER -DFEATURE_MULTICOREJIT -DFEATURE_MULTIREG_RETURN -DFEATURE_ON_STACK_REPLACEMENT -DFEATURE_
  PERFTRACING -DFEATURE_PGO -DFEATURE_PORTABLE_SHUFFLE_THUNKS -DFEATURE_READYTORUN -DFEATURE_REJIT -DFEATURE_REMAP_FUNCTION -DFEATURE_SPECIAL_USER_MOD
  E_APC -DFEATURE_STANDALONE_GC -DFEATURE_STUBS_AS_IL -DFEATURE_SVR_GC -DFEATURE_SYMDIFF -DFEATURE_TIERED_COMPILATION -DFEATURE_TYPEEQUIVALENCE -DFEAT
  URE_USE_ASM_GC_WRITE_BARRIERS -DFEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP -DHOST_64BIT -DHOST_ARM64 -DHOST_WINDOWS -DNDEBUG -DNOMINMAX -DPROFILIN
  G_SUPPORTED_DATA -DSELF_NO_HOST -DTARGET_64BIT -DTARGET_ARM64 -DTARGET_WINDOWS -DUNICODE -DURTBLDENV_FRIENDLY=Retail -DWIN32 -DWIN32_LEAN_AND_MEAN -
  DWINVER=0x0602 -D_CRT_SECURE_NO_WARNINGS -D_FILE_OFFSET_BITS=64 -D_SECURE_SCL=0 -D_TIME_BITS=64 -D_UNICODE -D_WIN32 -D_WIN32_WINNT=0x0602 -IC:\Users
  \eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\coreclr\windows.arm64.Release\utilcode -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\c
  oreclr\utilcode -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\native -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\native\inc -IC:\U
  sers\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\pal\prebuilt\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj -IC:\Users\
  eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\debug\inc -IC:\Users\eitsarpa\d
  evel\dotnet\runtime-baseline\src\coreclr\debug\inc\arm64 -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\debug\inc\dump -IC:\Users\eit
  sarpa\devel\dotnet\runtime-baseline\src\coreclr\md\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\classlibnative\bcltype -IC:\Use
  rs\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\classlibnative\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\coreclr\win
  dows.arm64.Release\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\hosts\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src
  \coreclr\minipal -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\coreclr\windows.arm64.Release\inc\etw /DWIN32 /D_WINDOWS  /GR- /O2
  /Ob2 /DNDEBUG -MT /GL /Ox /EHa /nologo /W4 /WX /Oi /Oy- /Gm- /Zp8 /Gy /GS /fp:precise /FC /MP /Zm200 /Zc:strictStrings /Zc:wchar_t /Zc:inline /Zc:fo
  rScope /wd4065 /wd4100 /wd4127 /wd4131 /wd4189 /wd4200 /wd4201 /wd4206 /wd4239 /wd4245 /wd4291 /wd4310 /wd4324 /wd4366 /wd4456 /wd4457 /wd4458 /wd44
  59 /wd4463 /wd4505 /wd4702 /wd4706 /wd4733 /wd4815 /wd4838 /wd4918 /wd4960 /wd4961 /wd5105 /wd5205 /we4007 /we4013 /we4102 /we4551 /we4640 /we4806 /
  we4055 /we4146 /we4242 /we4244 /we4267 /we4302 /we4308 /we4509 /we4510 /we4532 /we4533 /we4610 /we4611 /we4700 /we4701 /we4703 /we4789 /we4995 /we49
  96 /w34092 /w34121 /w34125 /w34130 /w34132 /w34212 /w34530 /w35038 /w44177 /Zi /ZH:SHA_256 /source-charset:utf-8 /guard:cf /Zl /YuC:/Users/eitsarpa/
  devel/dotnet/runtime-baseline/artifacts/obj/coreclr/windows.arm64.Release/utilcode/CMakeFiles/utilcode_dac.dir/cmake_pch.hxx /FpC:/Users/eitsarpa/de
  vel/dotnet/runtime-baseline/artifacts/obj/coreclr/windows.arm64.Release/utilcode/CMakeFiles/utilcode_dac.dir/./cmake_pch.cxx.pch /FIC:/Users/eitsarp
  a/devel/dotnet/runtime-baseline/artifacts/obj/coreclr/windows.arm64.Release/utilcode/CMakeFiles/utilcode_dac.dir/cmake_pch.hxx /showIncludes /Foutil
  code\CMakeFiles\utilcode_dac.dir\stgpool.cpp.obj /Fdutilcode\CMakeFiles\utilcode_dac.dir\utilcode_dac.pdb /FS -c C:\Users\eitsarpa\devel\dotnet\runt
  ime-baseline\src\coreclr\utilcode\stgpool.cpp
  c1xx: error C3859: Failed to create virtual memory for PCH
  c1xx: note: PCH: Unable to get the requested block of memory
  c1xx: note: consider using /Fp to allow the compiler to reserve the memory early
  c1xx: note: please visit https://aka.ms/pch-help for more details
  c1xx: fatal error C1076: compiler limit: internal heap limit reached
  [1092/2405] Building CXX object jit\CMakeFiles\clrjit_unix_x64_arm64.dir\likelyclass.cpp.obj
  FAILED: jit/CMakeFiles/clrjit_unix_x64_arm64.dir/likelyclass.cpp.obj
  C:\PROGRA~1\MICROS~3\2022\Preview\VC\Tools\MSVC\1441~1.340\bin\Hostx86\arm64\cl.exe  /nologo /TP -DDEBUGGING_SUPPORTED -DDISABLE_CONTRACTS -DFEATURE
  _BASICFREEZE -DFEATURE_CODE_VERSIONING -DFEATURE_COLLECTIBLE_TYPES -DFEATURE_COMINTEROP -DFEATURE_COMINTEROP_APARTMENT_SUPPORT -DFEATURE_COMINTEROP_
  UNMANAGED_ACTIVATION -DFEATURE_COMWRAPPERS -DFEATURE_CORECLR -DFEATURE_DEFAULT_INTERFACES -DFEATURE_EVENT_TRACE -DFEATURE_HIJACK -DFEATURE_HW_INTRIN
  SICS -DFEATURE_ICASTABLE -DFEATURE_IJW -DFEATURE_INSTANTIATINGSTUB_AS_IL -DFEATURE_INTEROP_DEBUGGING -DFEATURE_ISYM_READER -DFEATURE_MANUALLY_MANAGE
  D_CARD_BUNDLES -DFEATURE_MASKED_HW_INTRINSICS -DFEATURE_METADATA_UPDATER -DFEATURE_MULTICOREJIT -DFEATURE_MULTIREG_RETURN -DFEATURE_NO_HOST -DFEATUR
  E_ON_STACK_REPLACEMENT -DFEATURE_PERFTRACING -DFEATURE_PGO -DFEATURE_PORTABLE_SHUFFLE_THUNKS -DFEATURE_PROFAPI_ATTACH_DETACH -DFEATURE_READYTORUN -D
  FEATURE_REJIT -DFEATURE_REMAP_FUNCTION -DFEATURE_SIMD -DFEATURE_SPECIAL_USER_MODE_APC -DFEATURE_STANDALONE_GC -DFEATURE_STUBS_AS_IL -DFEATURE_SVR_GC
   -DFEATURE_SYMDIFF -DFEATURE_TIERED_COMPILATION -DFEATURE_TYPEEQUIVALENCE -DFEATURE_USE_ASM_GC_WRITE_BARRIERS -DFEATURE_USE_SOFTWARE_WRITE_WATCH_FOR
  _GC_HEAP -DFX_VER_INTERNALNAME_STR=clrjit_unix_x64_arm64.dll -DHOST_64BIT -DHOST_ARM64 -DHOST_WINDOWS -DJIT_BUILD -DNDEBUG -DNOMINMAX -DPROFILING_SU
  PPORTED -DSELF_NO_HOST -DTARGET_64BIT -DTARGET_AMD64 -DTARGET_UNIX -DTARGET_UNIX_ANYOS -DUNICODE -DUNIX_AMD64_ABI -DURTBLDENV_FRIENDLY=Retail -DWIN3
  2 -DWIN32_LEAN_AND_MEAN -DWINVER=0x0602 -DWITH_NATIVE_PGO -D_CRT_SECURE_NO_WARNINGS -D_FILE_OFFSET_BITS=64 -D_SECURE_SCL=0 -D_TIME_BITS=64 -D_UNICOD
  E -D_WIN32 -D_WIN32_WINNT=0x0602 -Dclrjit_unix_x64_arm64_EXPORTS -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\coreclr\windows.arm
  64.Release\jit -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\jit -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\native -IC:\U
  sers\eitsarpa\devel\dotnet\runtime-baseline\src\native\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\pal\prebuilt\inc -IC:\Users
  \eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\inc -IC:\Users\eitsarpa\devel\do
  tnet\runtime-baseline\src\coreclr\debug\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\debug\inc\arm64 -IC:\Users\eitsarpa\devel\
  dotnet\runtime-baseline\src\coreclr\debug\inc\dump -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\md\inc -IC:\Users\eitsarpa\devel\do
  tnet\runtime-baseline\src\coreclr\classlibnative\bcltype -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\classlibnative\inc -IC:\Users
  \eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\coreclr\windows.arm64.Release\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\corecl
  r\hosts\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\minipal -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\co
  reclr\windows.arm64.Release\inc\etw -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\jit\.\jitstd -IC:\Users\eitsarpa\devel\dotnet\runt
  ime-baseline\src\coreclr\jit\..\inc /DWIN32 /D_WINDOWS  /GR- /O2 /Ob2 /DNDEBUG -MT /GL /Ox /EHa /nologo /W4 /WX /Oi /Oy- /Gm- /Zp8 /Gy /GS /fp:preci
  se /FC /MP /Zm200 /Zc:strictStrings /Zc:wchar_t /Zc:inline /Zc:forScope /wd4065 /wd4100 /wd4127 /wd4131 /wd4189 /wd4200 /wd4201 /wd4206 /wd4239 /wd4
  245 /wd4291 /wd4310 /wd4324 /wd4366 /wd4456 /wd4457 /wd4458 /wd4459 /wd4463 /wd4505 /wd4702 /wd4706 /wd4733 /wd4815 /wd4838 /wd4918 /wd4960 /wd4961
  /wd5105 /wd5205 /we4007 /we4013 /we4102 /we4551 /we4640 /we4806 /we4055 /we4146 /we4242 /we4244 /we4267 /we4302 /we4308 /we4509 /we4510 /we4532 /we4
  533 /we4610 /we4611 /we4700 /we4701 /we4703 /we4789 /we4995 /we4996 /w34092 /w34121 /w34125 /w34130 /w34132 /w34212 /w34530 /w35038 /w44177 /Zi /ZH:
  SHA_256 /source-charset:utf-8 /guard:cf /Zl /permissive- /YuC:/Users/eitsarpa/devel/dotnet/runtime-baseline/artifacts/obj/coreclr/windows.arm64.Rele
  ase/jit/CMakeFiles/clrjit_unix_x64_arm64.dir/cmake_pch.hxx /FpC:/Users/eitsarpa/devel/dotnet/runtime-baseline/artifacts/obj/coreclr/windows.arm64.Re
  lease/jit/CMakeFiles/clrjit_unix_x64_arm64.dir/./cmake_pch.cxx.pch /FIC:/Users/eitsarpa/devel/dotnet/runtime-baseline/artifacts/obj/coreclr/windows.
  arm64.Release/jit/CMakeFiles/clrjit_unix_x64_arm64.dir/cmake_pch.hxx /showIncludes /Fojit\CMakeFiles\clrjit_unix_x64_arm64.dir\likelyclass.cpp.obj /
  Fdjit\CMakeFiles\clrjit_unix_x64_arm64.dir\ /FS -c C:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\jit\likelyclass.cpp
  c1xx: error C3859: Failed to create virtual memory for PCH
  c1xx: note: PCH: Unable to get the requested block of memory
  c1xx: note: consider using /Fp to allow the compiler to reserve the memory early
  c1xx: note: please visit https://aka.ms/pch-help for more details
  c1xx: fatal error C1076: compiler limit: internal heap limit reached
  [892/2405] Building CXX object jit\CMakeFiles\clrjit.dir\codegenarm64.cpp.obj
  FAILED: jit/CMakeFiles/clrjit.dir/codegenarm64.cpp.obj
  C:\PROGRA~1\MICROS~3\2022\Preview\VC\Tools\MSVC\1441~1.340\bin\Hostx86\arm64\cl.exe  /nologo /TP -DDEBUGGING_SUPPORTED -DDISABLE_CONTRACTS -DFEATURE
  _BASICFREEZE -DFEATURE_CODE_VERSIONING -DFEATURE_COLLECTIBLE_TYPES -DFEATURE_COMINTEROP -DFEATURE_COMINTEROP_APARTMENT_SUPPORT -DFEATURE_COMINTEROP_
  UNMANAGED_ACTIVATION -DFEATURE_COMWRAPPERS -DFEATURE_CORECLR -DFEATURE_DEFAULT_INTERFACES -DFEATURE_EVENT_TRACE -DFEATURE_HIJACK -DFEATURE_HW_INTRIN
  SICS -DFEATURE_ICASTABLE -DFEATURE_IJW -DFEATURE_INSTANTIATINGSTUB_AS_IL -DFEATURE_INTEROP_DEBUGGING -DFEATURE_ISYM_READER -DFEATURE_MANUALLY_MANAGE
  D_CARD_BUNDLES -DFEATURE_MASKED_HW_INTRINSICS -DFEATURE_METADATA_UPDATER -DFEATURE_MULTICOREJIT -DFEATURE_MULTIREG_RETURN -DFEATURE_NO_HOST -DFEATUR
  E_ON_STACK_REPLACEMENT -DFEATURE_PERFTRACING -DFEATURE_PGO -DFEATURE_PORTABLE_SHUFFLE_THUNKS -DFEATURE_PROFAPI_ATTACH_DETACH -DFEATURE_READYTORUN -D
  FEATURE_REJIT -DFEATURE_REMAP_FUNCTION -DFEATURE_SIMD -DFEATURE_SPECIAL_USER_MODE_APC -DFEATURE_STANDALONE_GC -DFEATURE_STUBS_AS_IL -DFEATURE_SVR_GC
   -DFEATURE_SYMDIFF -DFEATURE_TIERED_COMPILATION -DFEATURE_TYPEEQUIVALENCE -DFEATURE_USE_ASM_GC_WRITE_BARRIERS -DFEATURE_USE_SOFTWARE_WRITE_WATCH_FOR
  _GC_HEAP -DFX_VER_INTERNALNAME_STR=clrjit.dll -DHOST_64BIT -DHOST_ARM64 -DHOST_WINDOWS -DJIT_BUILD -DNDEBUG -DNOMINMAX -DPROFILING_SUPPORTED -DSELF_
  NO_HOST -DTARGET_64BIT -DTARGET_ARM64 -DTARGET_WINDOWS -DUNICODE -DURTBLDENV_FRIENDLY=Retail -DWIN32 -DWIN32_LEAN_AND_MEAN -DWINVER=0x0602 -DWITH_NA
  TIVE_PGO -D_CRT_SECURE_NO_WARNINGS -D_FILE_OFFSET_BITS=64 -D_SECURE_SCL=0 -D_TIME_BITS=64 -D_UNICODE -D_WIN32 -D_WIN32_WINNT=0x0602 -Dclrjit_EXPORTS
   -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\coreclr\windows.arm64.Release\jit -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline
  \src\coreclr\jit -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\native -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\native\inc -IC:\
  Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\pal\prebuilt\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj -IC:\Users
  \eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\debug\inc -IC:\Users\eitsarpa\
  devel\dotnet\runtime-baseline\src\coreclr\debug\inc\arm64 -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\debug\inc\dump -IC:\Users\ei
  tsarpa\devel\dotnet\runtime-baseline\src\coreclr\md\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\classlibnative\bcltype -IC:\Us
  ers\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\classlibnative\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\coreclr\wi
  ndows.arm64.Release\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\hosts\inc -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\sr
  c\coreclr\minipal -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\artifacts\obj\coreclr\windows.arm64.Release\inc\etw -IC:\Users\eitsarpa\devel\do
  tnet\runtime-baseline\src\coreclr\jit\.\jitstd -IC:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\jit\..\inc /DWIN32 /D_WINDOWS  /GR- /O2
   /Ob2 /DNDEBUG -MT /GL /Ox /EHa /nologo /W4 /WX /Oi /Oy- /Gm- /Zp8 /Gy /GS /fp:precise /FC /MP /Zm200 /Zc:strictStrings /Zc:wchar_t /Zc:inline /Zc:f
  orScope /wd4065 /wd4100 /wd4127 /wd4131 /wd4189 /wd4200 /wd4201 /wd4206 /wd4239 /wd4245 /wd4291 /wd4310 /wd4324 /wd4366 /wd4456 /wd4457 /wd4458 /wd4
  459 /wd4463 /wd4505 /wd4702 /wd4706 /wd4733 /wd4815 /wd4838 /wd4918 /wd4960 /wd4961 /wd5105 /wd5205 /we4007 /we4013 /we4102 /we4551 /we4640 /we4806
  /we4055 /we4146 /we4242 /we4244 /we4267 /we4302 /we4308 /we4509 /we4510 /we4532 /we4533 /we4610 /we4611 /we4700 /we4701 /we4703 /we4789 /we4995 /we4
  996 /w34092 /w34121 /w34125 /w34130 /w34132 /w34212 /w34530 /w35038 /w44177 /Zi /ZH:SHA_256 /source-charset:utf-8 /guard:cf /Zl /permissive- /YuC:/U
  sers/eitsarpa/devel/dotnet/runtime-baseline/artifacts/obj/coreclr/windows.arm64.Release/jit/CMakeFiles/clrjit.dir/cmake_pch.hxx /FpC:/Users/eitsarpa
  /devel/dotnet/runtime-baseline/artifacts/obj/coreclr/windows.arm64.Release/jit/CMakeFiles/clrjit.dir/./cmake_pch.cxx.pch /FIC:/Users/eitsarpa/devel/
  dotnet/runtime-baseline/artifacts/obj/coreclr/windows.arm64.Release/jit/CMakeFiles/clrjit.dir/cmake_pch.hxx /showIncludes /Fojit\CMakeFiles\clrjit.d
  ir\codegenarm64.cpp.obj /Fdjit\CMakeFiles\clrjit.dir\ /FS -c C:\Users\eitsarpa\devel\dotnet\runtime-baseline\src\coreclr\jit\codegenarm64.cpp
  c1xx: error C3859: Failed to create virtual memory for PCH
  c1xx: note: PCH: Unable to get the requested block of memory
  c1xx: note: consider using /Fp to allow the compiler to reserve the memory early
  c1xx: note: please visit https://aka.ms/pch-help for more details
  c1xx: fatal error C1076: compiler limit: internal heap limit reached

cc @jkotas

@dotnet-policy-service dotnet-policy-service bot added the untriaged New issue has not been triaged by the area owner label Jul 10, 2024
Copy link
Contributor

Tagging subscribers to this area: @hoyosjs
See info in area-owners.md if you want to be subscribed.

@jkotas
Copy link
Member

jkotas commented Jul 10, 2024

Hostx86

I think this is likely the problem. You want to be using HostArm64 compilers for this, not the one running on 32-bit x86 emulator. Is there HostArm64 compiler on your machine?

eng\native\init-vs-env.cmd is probably the place to fix this.

@vcsjones
Copy link
Member

Seems related to #96141

@eiriktsarpalis
Copy link
Member Author

Is there HostArm64 compiler on your machine?

Yes, it's included by default in ARM installations of VS with the C++ tools.

eng\native\init-vs-env.cmd is probably the place to fix this.

What do you suggest? I tried following @tannergooding's recommendation from #76516 hardcoding __VCBuildArch to arm64 but then I started seeing the following in my build output:

  **********************************************************************
  ** Visual Studio 2022 Developer Command Prompt v17.11.0-pre.3.0
  ** Copyright (c) 2022 Microsoft Corporation
  **********************************************************************
  [vcvarsall.bat] Environment initialized for: 'arm64'
  BUILD: Commencing CoreCLR product build
  BUILD: Checking prerequisites
  BUILD: Using CMake from C:\Program Files\Microsoft Visual Studio\2022\Preview\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe
  'wmic' is not recognized as an internal or external command,
  operable program or batch file.
  BUILD: Number of processor cores 0
  BUILD: Commencing build of native components for windows.arm64.Release
  BUILD: Using environment: "C:\Program Files\Microsoft Visual Studio\2022\Preview\VC\Auxiliary\Build\vcvarsall.bat" x86_arm64
  **********************************************************************
  ** Visual Studio 2022 Developer Command Prompt v17.11.0-pre.3.0
  ** Copyright (c) 2022 Microsoft Corporation
  **********************************************************************
  [vcvarsall.bat] Environment initialized for: 'x86_arm64'
  BUILD: Regenerating the Visual Studio solution
  Calling "C:\Users\eitsarpa\devel\dotnet\runtime\eng\native\gen-buildsys.cmd" "C:\Users\eitsarpa\devel\dotnet\runtime\src\coreclr" "C:\Users\eitsarpa\devel\dotnet\runtime\artifacts\obj\coreclr\windows.arm64.Release" vs2022 arm64 windows "-DCMAKE_BUILD_TYPE=Release" "-DCLR_CMAKE
  _TARGET_ARCH=arm64" "-DCLR_CMAKE_TARGET_OS=windows" "-DCLI_CMAKE_FALLBACK_OS=win10" "-DCLR_CMAKE_PGO_INSTRUMENT=0" "-DCLR_CMAKE_OPTDATA_PATH=C:\Users\eitsarpa\.nuget\packages\optimization.windows_nt-arm64.pgo.coreclr\1.0.0-prerelease.24223.3" "-DCLR_CMAKE_PGO_OPTIMIZE=1" "-DCD
  AC_BUILD_TOOL_BINARY_PATH=C:\Users\eitsarpa\devel\dotnet\runtime\artifacts\bin\coreclr\windows.arm64.Release\cdac-build-tool\cdac-build-tool.dll" "-DCLR_DOTNET_HOST_PATH=C:\Program Files\dotnet\dotnet.exe"
  Not searching for unused variables given on the command line.
  -- The C compiler identification is MSVC 19.41.34021.0
  -- The CXX compiler identification is MSVC 19.41.34021.0

It appears to be trying to use arm64 but then is falling back to x86_arm64 again. I'm not entirely sure if this is caused by the wmic error message but that tool isn't present in my developer command prompt. According to documentation it's a deprecated utility.

@eiriktsarpalis
Copy link
Member Author

I'm guessing this is the culprit?

if /i "%__HostArch%" == "arm64" (
set __VCTargetArch=x86_arm64
)

@eiriktsarpalis
Copy link
Member Author

After hardcoding __VCTargetArch to arm64 in both init-vs-env.cmd and build-runtime.cmd I can confirm that this resolved the issue for me, and also shaved 3 minutes off my build time. What isn't clear to me however is how we could fix the problem sustainably: it's very clear that at some point using the x86_arm64 tools was deemed preferable so I'm not sure who I could end up breaking by updating this.

@jkotas
Copy link
Member

jkotas commented Jul 10, 2024

The native arm64 hosted compilers did not exist in the early days of arm64 port. Feel free to submit PR. I am not worried about it breaking anything.

@jkotas
Copy link
Member

jkotas commented Jul 10, 2024

Also, you can delete the arm handling next to it. We do not support Windows arm32 anymore.

@eiriktsarpalis eiriktsarpalis removed the untriaged New issue has not been triaged by the area owner label Jul 10, 2024
@eiriktsarpalis eiriktsarpalis added this to the 9.0.0 milestone Jul 10, 2024
@eiriktsarpalis eiriktsarpalis self-assigned this Jul 10, 2024
@huoyaoyuan
Copy link
Member

huoyaoyuan commented Jul 11, 2024

Side question: does VS open folder of src\coreclr work fine on ARM64 machine? It may require to click "Enable CMake support" in menu or some configuration file, based on the experience last time I cleaned my workspace.

It may also works just fine for cross compilation if CMake integration of VS is sane.

I'm using open folder as my primary coreclr developing approach, and CMakePresets.json is effectively maintained by me for now.

@hez2010
Copy link
Contributor

hez2010 commented Jul 11, 2024

Side question: does VS open folder of src\coreclr work fine on ARM64 machine? It may require to click "Enable CMake support" in menu or some configuration file, based on the experience last time I cleaned my workspace.

It may also works just fine for cross compilation if CMake integration of VS is sane.

I'm using open folder as my primary coreclr developing approach, and CMakePresets.json is effectively maintained by me for now.

Yes. It works without any issue.

@eiriktsarpalis
Copy link
Member Author

Reopening since the issue still occurs when cross compiling on ARM.

@vcsjones
Copy link
Member

🙇 thanks for the first PR, @eiriktsarpalis. This has significantly improved my build speed.

I noticed there is one other HostX86 tool being used, here.

file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)

I don't think this is the end of the world as this one tool does not account for much of the build time, but if it's easy to fix it would be nice. I am not sure if makes sense to just change HostX86 to Hostarm64 there.

@hez2010
Copy link
Contributor

hez2010 commented Jul 11, 2024

🙇 thanks for the first PR, @eiriktsarpalis. This has significantly improved my build speed.

I noticed there is one other HostX86 tool being used, here.

file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}\\bin\\HostX86\\arm64\\armasm64.exe" CMAKE_ASM_COMPILER)

I don't think this is the end of the world as this one tool does not account for much of the build time, but if it's easy to fix it would be nice. I am not sure if makes sense to just change HostX86 to Hostarm64 there.

Did a simple search on the entire repo and seems that this one is the last piece contains Hostx86. Here it is used when assembling the ijwhost, so I guess it won't hurt the build performance too much. But it'll be nice to have it fixed too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.