microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6k stars 2.12k forks source link

Cannot build any MRTK example with VS 2022 for ARM #10647

Closed dl4mmers closed 9 months ago

dl4mmers commented 2 years ago

Describe the issue

Hi! On my old PC I have VS 2017 installed and can build my HL application (Unity 2019.4.39f1 / Legacy XR) for Release / Master / x86 / ARM.

Now I have to setup a new PC for HoloLens developing and installed all the tools as listed here: https://docs.microsoft.com/en-us/windows/mixed-reality/develop/install-the-tools

When trying to build the existing application for ARM with VS 2022 I get compiler errors and so I created a new project with MRTK 2.8.0 / OpenXR / Unity 2020.3.35f1 and tried to build one of the MRTK example scenes: Same compiler error.

EXEC : error : Unity.IL2CPP.Building.BuilderFailedException: mscorlib2.cpp
1>C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\Source\il2cppOutput\mscorlib2.cpp(23662): fatal error C1001: Interner Compilerfehler.
1>(Compilerdatei "D:\a\_work\1\s\src\vctools\Compiler\Utc\src\p2\main.c", Zeile 220)
1> Um dieses Problem zu umgehen, vereinfachen oder �ndern Sie das Programm im Umfeld der oben aufgef�hrten Positionen.
1>Geben Sie nach M�glichkeit hier Reproduktionsschritte an: https://developercommunity.visualstudio.com
1>W�hlen Sie im Men� "Hilfe" von Visual C++ den Befehl "Technischer Support",
1> oder �ffnen Sie die Hilfedatei des technischen Supports, um weitere Informationen zu erhalten.
1>
1>Invocation was: Executable: "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\ARM\cl.exe"
1>Arguments: "C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\Source\il2cppOutput\mscorlib2.cpp" /nologo /c /bigobj /W3 /Z7 /EHs /GR- /Gy /utf-8 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /wd4996 /wd4200 /wd4834 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /Yupch-cpp.hpp /Fp"C:\Users\xxxxx\MRTK_Test\App\build\obj\il2cppOutputProject\ARM\Release\ABC3A73165AD83A75203E2694DF0F1AF.pch" /MD /DWINDOWS_UWP /DUNITY_UWP /DUNITY_WSA_10_0 /DUNITY_WSA /DUNITY_WINRT /DPLATFORM_WINRT /DNET_4_0 /DUNITY_AOT /DIL2CPP_MONO_DEBUGGER_DISABLED /DGC_NOT_DLL /DRUNTIME_IL2CPP /DIL2CPP_ENABLE_WRITE_BARRIERS=1 /DIL2CPP_INCREMENTAL_TIME_SLICE=3 /DBASELIB_INLINE_NAMESPACE=il2cpp_baselib /DIL2CPP_DEFAULT_DATA_DIR_PATH=Data/il2cpp_data /D_WIN32 /DWIN32 /DWIN32_THREADS /D_WINDOWS /DWINDOWS /D_UNICODE /DUNICODE /D_CRT_SECURE_NO_WARNINGS /D_SCL_SECURE_NO_WARNINGS /D_WINSOCK_DEPRECATED_NO_WARNINGS /DNOMINMAX /D_NDEBUG /DNDEBUG /D__arm__ /DWINDOWS_SDK_BUILD_VERSION=19041 /D__WRL_NO_DEFAULT_LIB__ /DWINAPI_FAMILY=WINAPI_FAMILY_APP /I"C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\IL2CPP\libil2cpp" /I"C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\IL2CPP\libil2cpp" /I"C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\IL2CPP\external\bdwgc\include" /I"C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\IL2CPP\external\xxHash" /I"C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\IL2CPP\external\baselib\Include" /I"C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\IL2CPP\external\baselib\Platforms\UniversalWindows\Include" /I"C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\IL2CPP\libil2cpp\pch" /I"C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\Source" /I"C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt" /Fo"C:\Users\xxxxx\MRTK_Test\App\build\obj\il2cppOutputProject\ARM\Release\D7642EB35C1402E254D1D71C0334BDAD.obj" /Fd"C:\Users\xxxxx\MRTK_Test\App\build\obj\il2cppOutputProject\ARM\Release\D7642EB35C1402E254D1D71C0334BDAD.pdb"
1>EnvArg key: PATH value: C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x64;C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86;C:\Program Files (x86)\Windows Kits\10\bin\x86;C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\x64
1>
1>   at Unity.IL2CPP.Building.CppProgramBuilder.BuildAllCppFiles(IEnumerable`1 sourceFilesToCompile, IBuildStatisticsCollector statisticsCollector)
1>   at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
1>   at il2cpp.Compilation.CompilationDriver.Run(RuntimePlatform platform, BuildingOptions buildingOptions, ReadOnlyCollection`1 matchedAssemblyMethodSourceFiles)
1>   at il2cpp.Program.DoRun(String[] args, RuntimePlatform platform, BuildingOptions buildingOptions, Boolean throwExceptions)
1>C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\Microsoft.MakeFile.Targets(45,5): error MSB3073: Der Befehl ""C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\\IL2CPP\build\deploy\netcoreapp3.1\il2cpp.exe" --libil2cpp-static --compile-cpp -architecture=ARMv7 -configuration=Release -platform=winrt -outputpath="C:\Users\xxxxx\MRTK_Test\App\\build\bin\ARM\Release\GameAssembly.dll" --data-folder="C:\Users\xxxxx\MRTK_Test\App\\build\bin\ARM\Release\\" -cachedirectory="C:\Users\xxxxx\MRTK_Test\App\\build\obj\il2cppOutputProject\ARM\Release\\" -generatedcppdir="C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\\Source"  --incremental-g-c-time-slice=3 --baselib-directory="C:\Program Files\Unity\Hub\Editor\2020.3.35f1\Editor\Data\PlaybackEngines\MetroSupport\Players\UAP\il2cpp\ARM\Release" --avoid-dynamic-library-copy --profiler-report --additional-defines=WINDOWS_UWP --additional-defines=UNITY_UWP --additional-defines=UNITY_WSA_10_0 --additional-defines=UNITY_WSA --additional-defines=UNITY_WINRT --additional-defines=PLATFORM_WINRT -dotnetprofile=unityaot -verbose --relative-data-path=Data/il2cpp_data --map-file-parser="C:\Users\xxxxx\MRTK_Test\App\Il2CppOutputProject\\IL2CPP\MapFileParser\MapFileParser.exe"" wurde mit dem Code 4 beendet.
1>Die Erstellung des Projekts "Il2CppOutputProject.vcxproj" ist abgeschlossen -- FEHLER.

x86 and ARM64 working fine, but because I'm using MixedReality-WebRTC in my application, i cannot build for ARM64. Is this a known issue?

As stated in the documentation I've installed VS 2022 package "C++ (v142) Universal Windows Platform tools (required when using Unity)" but it seems that for the build v143 is used (and also listed in the vxproj files). I tried to set this to v142 in the vxproj files, but then get this error:

1>il2cpp.exe didn't catch exception: System.NotSupportedException: Visual Studio 2017 support for ARMv7 is not installed.
1>   bei Unity.IL2CPP.Building.ToolChains.MsvcVersions.Msvc15InstallationBase.ThrowIfArchitectureNotInstalled(Architecture architecture)
1>   bei Unity.IL2CPP.Building.ToolChains.MsvcVersions.Msvc15InstallationBase.<GetSdkIncludeDirectories>d__20.MoveNext()
1>   bei Unity.IL2CPP.Building.ToolChains.MsvcVersions.MsvcInstallation.IsWindowsSDKInstalled(Architecture architecture)
1>   bei Unity.IL2CPP.Building.ToolChains.MsvcVersions.MsvcInstallation.GetReasonCannotBuildCode(Architecture architecture)
1>   bei Unity.IL2CPP.Building.ToolChains.MsvcVersions.MsvcInstallation.GetReasonMsvcInstallationCannotBuild(Architecture architecture)
1>   bei Unity.IL2CPP.Building.ToolChains.MsvcVersions.MsvcInstallation.GetReasonMsvcInstallationCannotBuild(Version version, Architecture architecture)
1>   bei Unity.IL2CPP.Building.ToolChains.MsvcVersions.MsvcInstallation.GetMsvcVersionRequirementsForBuildingAndReasonItCannotBuild(Version version, Architecture architecture)
1>   bei Unity.IL2CPP.Building.ToolChains.MsvcWinRtToolChain.GetCannotBuildInCurrentEnvironmentErrorMessage()
1>   bei Unity.IL2CPP.Building.CppProgramBuilder.ThrowIfCannotBuildInCurrentEnvironment()
1>   bei Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics)
1>   bei il2cpp.Program.DoRun(String[] args, List`1 foundAssemblies)
1>   bei il2cpp.Program.Run(String[] args, Boolean setInvariantCulture)
1>   bei il2cpp.Program.Main(String[] args)

Or when removing all of C++ (v143) packages I get:

1>il2cpp.exe didn't catch exception: System.InvalidOperationException: C++ code builder is unable to build C++ code. In order to build C++ code for Universal Windows Platform, you must have one of these installed:
1>        Visual Studio 2015 with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed or missing C++ workload component)
1>        Visual Studio 2015 installation is found by looking at "SOFTWARE\Microsoft\VisualStudio\14.0_Config\InstallDir" in the registry
1>        Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry
1>
1>        Visual Studio 2017 (or newer) with C++ compilers and Windows 10 SDK (it cannot build C++ code because it is not installed or missing C++ workload component)
1>        Visual Studio 2017 (or newer) installation is found using Microsoft.VisualStudio.Setup.Configuration COM APIs
1>        Windows 10 SDK is found by looking at "SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0\InstallationFolder" in the registry

I think an older compiler (used in VS 2017 or VS 2019) should work for ARM when build is started from VS 2022, but I could not find out how this can be configured.

Feature area

VS 2022 should be able to build HoloLens applications for all supported platforms, but ARM does not work. After building a MRTK example scene in Unity, VS 2022 is showing up a notification that package "C++ (v143) Universal Windows Platform tools" should be installed to be able to build the application, while this package is not listed in the documentation. The vxproj files in Unity output folder do contain references to v143 build tools. When changing these references to v142 build tools, VS 2022 is showing an error when trying to build the app "Visual Studio 2017 support for ARMv7 is not installed" although v142 build tools are installed as suggested in docs.

Existing doc link

https://docs.microsoft.com/en-us/windows/mixed-reality/develop/install-the-tools

keveleigh commented 2 years ago

Interesting...I haven't hit this myself, but it looks like it should be fixed in the latest version of VS 2022 according to https://developercommunity.visualstudio.com/t/latest-update-of-vs2022-prevents-the-building-of-h/1694185. Can you please confirm which release you're on, and possibly update if there's one available?

dl4mmers commented 2 years ago

Should be the latest version:

Microsoft Visual Studio Community 2022 (64-Bit) - Current Version 17.2.3

Mh, maybe this issue was resolved for ARM64 but not for ARM?

keveleigh commented 2 years ago

Interesting...I just updated to 17.2.4 and was successful building for both ARM and ARM64. I'll keep trying to repro though.

Legllers commented 2 years ago

Interesting...I just updated to 17.2.4 and was successful building for both ARM and ARM64. I'll keep trying to repro though.

I have same problem, and I updated to 17.2.4. Still can not build.

jcady commented 2 years ago

Can confirm that this issue is also happening to me on both 17.2.3 and 17.2.4. Building for Master and Release on ARM fails with the above error.

dl4mmers commented 2 years ago

Interesting...I just updated to 17.2.4 and was successful building for both ARM and ARM64. I'll keep trying to repro though.

Do you also have VS 2019 installed? I have now installed VS 2019 and uninstalled package "C++ (v143) Universal Windows Platform tools" from VS 2022. When building for VS 2019 in Unity, the build for ARM works in VS 2022 and output shows

1>  Msvc Install Version: 15.0
1>  Msvc Install SDK Directory: C:\Program Files (x86)\Windows Kits\10
1>  Msvc Linker Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\ARM\link.exe
1>  Msvc Compiler Path: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX64\ARM\cl.exe

Before output was

1>  Msvc Install Version: 17.0
1>  Msvc Install SDK Directory: C:\Program Files (x86)\Windows Kits\10
1>  Msvc Linker Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\ARM\link.exe
1>  Msvc Compiler Path: C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\bin\HostX64\ARM\cl.exe

and build resulted in above error.

I have noticed that VS 2022 folder C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\ is also containing MSVC version 14.29.30133, but I could not find out how this version can be used to build the app when VS 2022 is the only VS version installed (second error of my main post occurs when vcxproj files are manually set to v142 build tools and VS 2019 is not installed).

AlexP-Coding commented 1 year ago

Have there been any updates?

IssueSyncBot commented 9 months ago

We appreciate your feedback and thank you for reporting this issue.

Microsoft Mixed Reality Toolkit version 2 (MRTK2) is currently in limited support. This means that Microsoft is only fixing high priority security issues. Unfortunately, this issue does not meet the necessary priority and will be closed. If you strongly feel that this issue deserves more attention, please open a new issue and explain why it is important.

Microsoft recommends that all new HoloLens 2 Unity applications use MRTK3 instead of MRTK2.

Please note that MRTK3 was released in August 2023. It features an all new architecture for developing rich mixed reality experiences and has a minimum requirement of Unity 2021.3 LTS. For more information about MRTK3, please visithttps://www.mixedrealitytoolkit.org.

Thank you for your continued support of the Mixed Reality Toolkit!