Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Neverending IL2CPP build

Discussion in 'Windows' started by brettj, Mar 27, 2020.

  1. brettj

    brettj

    Joined:
    Feb 9, 2015
    Posts:
    43
    I'm building on 2019.3 for Windows with IL2CPP. Everything seems to be working right when building, but it never finishes. I've left it overnight and still nothing. There are no errors in the editor. And looking at the Task Manager in Windows, it shows a Microsoft C-C++ Compiler Driver still running at around 14% CPU.

    For comparison, the Mac IL2CPP builds successfully in about 10-20 minutes max.

    What's going on here? Is there a way to debug it?
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Can you check which executable is taking that long? Is it cl.exe or link.exe? If it's cl.exe, can you check the command line invocation to figure out which source file it's compiling?
     
  3. brettj

    brettj

    Joined:
    Feb 9, 2015
    Posts:
    43
    It's cl.exe.

    Here's the last segment from the Editor.log:
    Invoking UnityLinker with arguments: -out="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/tempStrip" -x="C:/Users/BRETTJ~1/AppData/Local/Temp/tmp184b0b39.tmp" -x="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/TypesInScenes.xml" -d="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/Assembly-CSharp-firstpass.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/Assembly-CSharp.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/Unity.Polybrush.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/AwesomeTechnologies.TouchReactSystemPro.Runtime.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/UnityEngine.UI.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/NavMeshComponents.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/AwesomeTechnologies.VegetationStudioPro.Runtime.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/Unity.Postprocessing.Runtime.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/Unity.TextMeshPro.dll" --include-unity-root-assembly="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/Rewired_Core.dll" --dotnetruntime=il2cpp --dotnetprofile=unityaot --use-editor-options --include-directory="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed" --rule-set=Conservative --editor-data-file="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed/EditorToUnityLinkerData.json" --platform=WindowsDesktop --engine-modules-asset-file="C:/Program Files/Unity/Hub/Editor/2019.3.7f1/Editor/Data/PlaybackEngines/WindowsStandaloneSupport/Whitelists/../modules.asset"
    C:\Program Files\Unity\Hub\Editor\2019.3.7f1\Editor\Data\il2cpp\build/deploy/net471/UnityLinker.exe exited after 6740 ms.
    Invoking il2cpp with arguments: --convert-to-cpp --emit-null-checks --enable-array-bounds-check --dotnetprofile="unityaot" --compile-cpp --libil2cpp-static --platform="WindowsDesktop" --architecture="x64" --configuration="Release" --outputpath="C:\Users\Brett Johnson\Documents\Stealth%20Adventure\Temp/StagingArea/Data\Native\GameAssembly.dll" --cachedirectory="C:\Users\Brett Johnson\Documents\Stealth%20Adventure\Assets\..\Library/il2cpp_cache" --incremental-g-c-time-slice=3 --profiler-report --map-file-parser="C:/Program Files/Unity/Hub/Editor/2019.3.7f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe" --directory="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/Managed" --generatedcppdir="C:/Users/Brett Johnson/Documents/Stealth%20Adventure/Temp/StagingArea/Data/il2cppOutput"
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    I meant the command line invocation for cl.exe. You can find it via various tools like process explorer or task manager.
     
  5. brettj

    brettj

    Joined:
    Feb 9, 2015
    Posts:
    43
    Oh gotcha. Here's the command line invocation for cl.exe:

    "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\bin\HostX64\x64\cl.exe" "C:\Users\Brett Johnson\Documents\Stealth%20Adventure\Temp\StagingArea\Data\il2cppOutput\Rewired_Core10.cpp" /nologo /c /bigobj /W3 /Zi /EHs /GR- /Gy /utf-8 /wd4102 /wd4800 /wd4056 /wd4190 /wd4723 /wd4467 /wd4503 /wd4996 /wd4200 /Ox /Oi /Oy- /GS- /Gw /GF /Zo /MT /DNET_4_0 /DUNITY_AOT /DIL2CPP_MONO_DEBUGGER_DISABLED /DGC_NOT_DLL /DRUNTIME_IL2CPP /DIL2CPP_ENABLE_WRITE_BARRIERS=1 /DIL2CPP_INCREMENTAL_TIME_SLICE=3 /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 /DWINDOWS_SDK_BUILD_VERSION=18362 /DWINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP /I"C:\Program Files\Unity\Hub\Editor\2019.3.7f1\Editor\Data\il2cpp\libil2cpp" /I"C:\Program Files\Unity\Hub\Editor\2019.3.7f1\Editor\Data\il2cpp\libil2cpp" /I"C:\Program Files\Unity\Hub\Editor\2019.3.7f1\Editor\Data\il2cpp\external\bdwgc\include" /I"C:\Program Files\Unity\Hub\Editor\2019.3.7f1\Editor\Data\il2cpp\external\xxHash" /I"C:\Users\Brett Johnson\Documents\Stealth%20Adventure\Temp\StagingArea\Data\il2cppOutput" /I"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.25.28610\include" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\shared" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\um" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\winrt" /I"C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt" /Fo"C:\Users\Brett Johnson\Documents\Stealth%20Adventure\Library\il2cpp_cache\8F6F44A13D25792CF4CCC2CB93E9B876.obj" /Fd"C:\Users\Brett Johnson\Documents\Stealth%20Adventure\Library\il2cpp_cache\8F6F44A13D25792CF4CCC2CB93E9B876.pdb"
     
    NateReese77 likes this.
  6. brettj

    brettj

    Joined:
    Feb 9, 2015
    Posts:
    43
    @guavaman I'm noticing it could be related to Rewired ("Rewired_Core10.cpp"). Any thoughts on whether it's a bug or something I might be missing?
     
    NateReese77 likes this.
  7. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Rewired version please?

    The obfuscation is known to cause IL2CPP errors on Windows and Android builds. I manually test every single version of Rewired for each version of Unity (release and trial) with IL2CPP on Windows and Android by building before publishing because of this issue. But you could certainly be using some old version that wasn't tested before publishing.

    Incidentally, this issue has been traced to compiler bugs in both Visual Studio and Android Studio. Apparently the bug that causes it was fixed in VS 2019 in some service pack/update as I recall. I've also not seen the bug in recent versions of Android Studio.
     
    Last edited: Mar 30, 2020
    NateReese77 likes this.
  8. NateReese77

    NateReese77

    Joined:
    Jun 14, 2017
    Posts:
    26
    I've been running into the same issues since moving to a new computer last week. It will build on other machines just fine, but not my new home machine. I'll get something like:
    il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: Rewired_Core10.cpp

    So originally I thought it was an issue with the version of Rewired. When I updated the Asset to the latest version - then I get a build that just hangs forever. So far I've let it run for 4 hours with no luck.

    I've tried repairing Visual Studio, and uninstalling / reinstalling Unity a few times.
     
  9. NateReese77

    NateReese77

    Joined:
    Jun 14, 2017
    Posts:
    26
    Also - I should mention that Rewired does seem to work in an empty project with IL2CPP (though it still takes about 30+ mins to compile which seems odd for a completely empty project - its about a 40 second build without the asset). However, when I upgrade the actual project our team is working on, that's when it hangs.
     
  10. brettj

    brettj

    Joined:
    Feb 9, 2015
    Posts:
    43
    I'm using Unity 2019.3.7 and Rewired 1.1.30.3. I installed Visual Studio through the Unity Hub.

    Like @NateReese77, I moved the project from another computer (Mac), and I've also tried reinstalling everything.
     
  11. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @NateReese77 It definitely should not take 30 minutes to build Rewired in an empty project.
    @brettj I just tested compiling to IL2CPP in 2019.3.7 with Rewired 1.1.30.3. I am using Visual Studio 2017 as I do not have VS 2019 installed. It is definitely not stalling on build. It only takes a couple of minutes to build, therefore it should not be related to the obfuscation issue.

    Unless there is some kind of new bug in VS2019 that was not there in VS2017, I can't see how either of you could be having this problem. Am I going to have to start doing test builds in every version of Unity and in every version of Visual Studio now? These compiler bugs with IL2CPP are really a huge problem and have exploded the amount of time it takes me to do an update.
     
    NateReese77 likes this.
  12. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Yep. Installing VS 2019 16.5.1 and doing a build results in eternal build time. New VS compiler bug. I cannot possibly test all versions of Visual Studio. One person may have 16.5.1 installed while another has 16.1.0 installed.

    Apparently IL2CPP chooses the latest version of VS to build to it finds installed, so I won't be able to do tests with multiple versions of Visual Studio on the same machine. Even if I have it create a VS project, when I build that project from VS 2017, it invokes IL2CPP which in turn invokes cl.exe from VS 2019.

    I have no choice but to set up a bunch of VMs, each with one version of Visual Studio 2015, 2017, and 2019 and Unity 2017, 2018, and 2019 so I can control what version I'm testing. I can only possibly test the latest version of VS of each branch. What a complete mess.
     
    Last edited: Mar 30, 2020
    NateReese77 likes this.
  13. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    The problem is even worse than I imagined. After extensive testing, even when IL2CPP is able to build properly with VS 2019 (different Rewired builds that don't have the rare condition that causes the bug), the executable VS 2019 creates cannot run. Unity just freezes after the splash screen. This is regardless of the version of Unity I build with and regardless of the version or build of Rewired I build with.

    I tried building various different versions of Rewired with 2018.4.20, 2019.1.0f2, and 2019.3.7f1. All 3 work flawlessly when building with Visual Studio 2017 (15.9.21 and 15.9.19). All 3 fail in the exact same way (freeze after splash screen) when built with Visual Studio 2019 (16.5.1). All 3 also work flawlessly when built with Mono. All I have to do is install VS 2019 16.5.1 on the system so it becomes the preferred compiler by IL2CPP and every build of any version of Rewired made with any version of Unity fails to run.

    There's a serious issue here with Visual Studio 2019, and I suspect it's something in a recent update because both I and Unity (bug case) have tested Rewired IL2CPP on Visual Studio 2019 before without any issues. Now I can't get it to run at all when built with VS 2019.

    If the compiler is compiling the code without failing or going into an infinite loop, it should be executing when the app is launched, but it's not, instead appearing to go into an infinite loop in the application. I'm going to have to ask Unity to get involved here to help me figure out what is going on.
     
    Last edited: Mar 30, 2020
    NateReese77 likes this.
  14. NateReese77

    NateReese77

    Joined:
    Jun 14, 2017
    Posts:
    26
    @guavaman Thank you for the quick and fast support! Sorry this is such a frustrating bug. I've gone ahead and uninstalled Visual Studio 2019 for the time being - however I actually ran into a few issues downgrading. The Windows SDK in the registry was set to an incorrect version - I followed this post and was just able to do a build without issues: https://forum.unity.com/threads/cannot-build-with-ilc2pp-in-2019-1-8f1.743393/

    Going to do a few tests again with 2019 using this SDK and will let you if I have any success.
     
  15. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    You shouldn't have to be forced to use VS 2017. I'm going to keep poking at this from every angle I can think of to see if I can find some kind of workaround.

    As for SDK problems after uninstalling VS 2019, the exact same thing happened to me. I was getting errors from IL2CPP indicating the Windows SDK was also uninstalled. I had to reinstall the SDK again separately from VS and I was able to get things building again.
     
    NateReese77 and brettj like this.
  16. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Best I can guess upon tracing the disassembly is that compiler optimizations are throwing it into an infinite loop. Worst case scenario.
     
    Last edited: Mar 30, 2020
    NateReese77 likes this.
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Compiler bugs are so nasty to deal with :(. We can certainly dig into it and report the bug to Microsoft once you send us a repro.
     
    NateReese77 likes this.
  18. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks! Much appreciated.

    This is going to be very time consuming and complicated. I'm going to have to do 3 separate bug reports. There are 3 cases of failure, each different:

    1. On some builds, the cl.exe build will hang forever.
    2. On some builds, cl.exe will finish, but the resulting code will hang forever on launch.
    3. New scenario -- I just simplified the obfuscation code I believe is triggering this and that only lead to a completely different fail scenario. Now with this change, the il2cpp.exe build is failing with il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException.
     
    diegoadrada and NateReese77 like this.
  19. brettj

    brettj

    Joined:
    Feb 9, 2015
    Posts:
    43
    Wow.

    Thanks @guavaman for the quick and helpful support as always. And thanks @Tautvydas-Zilys for pushing on it from your side.

    While we all wait for compiler fixes, should I downgrade to Visual Studio 2017?
     
  20. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    I think that would be the quickest path to unblock yourself.
     
  21. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @Tautvydas-Zilys I've made 3 bug reports. Not sure if you'll be looking into this yourself or not, but I'll send you the links in a PM in case.
     
  22. iMer

    iMer

    Joined:
    May 21, 2013
    Posts:
    29
    Ran into this exact issue on a fresh install aswell
    From what I can tell visual studio 2019 16.4.5 works fine and the newest 16.5.2 is broken
     
    NateReese77 likes this.
  23. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks for this information. This is important.

    I am unable to download older versions of Visual Studio to test.
     
  24. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    @Tautvydas-Zilys I've had several customers show me evidence that builds built to the Mono scripting backend with Visual Studio 2019 16.5.x also either hang forever on start or take 10+ seconds to start. Removing Visual Studio 2019 and using 2017 resolves all issues. Does this even make sense that a Mono build would be affected by a Visual Studio compiler bug? Does Unity compile to IL using VS on Windows?
     
  25. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    That makes no sense. Mono scripting backend does not compile code using Visual Studio at all (or even checks for its existence). It just copied precompiled files from within Unity directory.

    Do you know which process hangs during the build process?
     
  26. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    That's what I thought. I am at a total loss based on what these users are telling me.
    • So on Mono builds, the project building doesn't hang. Only the built executable does on start. (I haven't been able to reproduce this, but my users are telling me this.)
    • On IL2CPP cl.exe hangs during compile.
    Does Unity use VS to compile the scripts in the Unity project to assembly-csharp.dll? If so, perhaps the compiling problem in their Mono builds is coming form a compiler bug having an impact on the compiling of their scripts in the project.
     
    Last edited: Apr 9, 2020
  27. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,646
    Nope, we use the compiler we bundle in with Unity at "Editor\Data\Tools\Roslyn".

    Did those users that experience hang on startup try to attach a profiler? That might reveal what's taking so long.
     
    deus0 and guavaman like this.
  28. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    After following up more and digging deeper with one of the users having an issue in Mono, it appears he was mistaken. Something else in his project is causing Mono builds to freeze and it's not Rewired. I'm going to wager the others are having some similar issue. This likely is isolated to IL2CPP.
     
  29. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Edit: This workaround is no longer necessary as of Rewired 1.1.40.0:
    https://guavaman.com/projects/rewired/docs/KnownIssues.html#windows-standalone-il2cpp-vs2019-hang

    More information on this Visual Studio 2019 compiler bug:

    Due to a new compiler bug in Visual Studio 2019 16.5, when built with IL2CPP for the Windows Standalone target with Visual Studio 2019 installed, the build may never finish (hang during compile) or the built executable may hang after launch. This issue can be avoided by uninstalling Visual Studio 2019 and installing Visual Studio 2017, or you can use one of the following workarounds to make builds work again in VS 2019.

    Update: This has been updated to disable just the jump threading optimizer instead of the entire SSA optimizer based on feedback from Microsoft. This issue still occurs as of Visual Studio 2019 16.7.6, the latest version available at the time of writing.

    I have tracked the issue down to the new optimizer used in VS2019.
    • This affects Release and Master builds, not debug builds.
    • You can disable the new optimizer in the VS generated IL2CPP build project by adding the following to the end of the IL2CPP command line:
      --compiler-flags=-d2ssa-cfg-jt-

    Option 1: Editor Script (Probably the best solution)
    1. Download the DisableNewVS2019Optimizer script and extract the cs file.
    2. Create a folder somewhere in your Unity project's Assets folder and name it Editor.
    3. Copy the DisableNewVS2019Optimizer.cs script into the Editor folder.
    4. Now IL2CPP builds on Windows will automatically have the new optimizer disabled, but it won't affect builds to other build targets.
    5. Note that this method will not automatically copy the compiler flag options to the Visual Studio project if you choose to make an IL2CPP build with the "Create Visual Studio Solution" option in the build window. If "Create Visual Studio Solution" is enabled, you will have to manually add the compiler option by following the instructions under Option 2: Manual Build below.
    6. Note that you will get a compiler error if you use this script and do not have Visual Studio 2019 installed as VS 2017 or other versions do not have this compiler flag option.
    7. Deleting the script will not remove the compiler option if it has already been set. You can remove it by editing ProjectSettings\ProjectSettings.asset in a text editor under the heading additionalIl2CppArgs.
    Option 2: Manual Build

    Steps:
    1. Set Unity Build Settings -> PC, Mac & Linux Standalone -> Create Visual Studio Solution
    2. Build
    3. Open solution in Visual Studio
    4. Right click the IL2CPPOutputProject project in the Solution Explorer and select Properties.
    5. Make sure you have the correct build Configuration selected at the top for the type of build you want to make (Master, Release, etc).
    6. Go to the NMake page
    7. On the Build Command Line field, add to the end (adding a space first):
    8. --compiler-flags=-d2ssa-cfg-jt-
    9. Compile
    10. Run
    11. No more infinite loops
    Option 3: Environment Variable

    On Windows, another easier way to disable the optimizer is to add an environment variable. Be advised, this may cause IL2CPP builds for other build targets to fail because I assume it will add the compiler option regardless of the build target:
    1. Click Start Menu
    2. Type environment
    3. Launch "Edit the system environment variables"
    4. Under "User Variables for USERNAME", click New.
    5. Set the variable name to: IL2CPP_ADDITIONAL_ARGS
    6. Set the variable value to: --compiler-flags=-d2ssa-cfg-jt-
    7. Press Ok.
    8. Close all copies of the Unity editor and re-open it.
    9. Direct IL2CPP builds (without creating VS solution) will now work correctly.
     
    Last edited: Sep 18, 2021
  30. xinoHITO1

    xinoHITO1

    Joined:
    Jul 2, 2012
    Posts:
    33
    THANK YOU SOOO MUCH!!! I'v been going crazy trying to figure out why my build wasn't working TuT
     
    diegoadrada likes this.
  31. AntiSilence

    AntiSilence

    Joined:
    Aug 17, 2016
    Posts:
    5
    I've been having this very issue for the past few weeks and have been unable to find much about it. I've had both Visual Studio 2017 and 2019 installed since 2019 was released, and have been building in IL2CPP with Rewired for the past few months without issues. Then, all of a sudden, it stopped working causing either the editor to freeze whilst building with IL2CPP, or, if it did build, the exe would just crash when ran.

    I also found that the C++ compiler process was sat using 14~20% CPU at the time, and ending that task caused Unity to unlock and spit out an actual console error, which was "il2cpp.exe didn't catch exception: Unity.IL2CPP.Building.BuilderFailedException: Rewired_Core10.cpp" which I did a Google search for and found this topic. Building to Mono still worked fine.
     
  32. AntiSilence

    AntiSilence

    Joined:
    Aug 17, 2016
    Posts:
    5
    Many thanks to @guavaman for the editor script update - I've now removed VS 2017, and my project is now building with IL2CPP again, using VS 2019.
     
  33. diegoadrada

    diegoadrada

    Joined:
    Nov 27, 2014
    Posts:
    59
    Thanks so much @guavaman, I was so frustrated with this, you can't imagine.
     
  34. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    I think I can, after spending days trying to figure out what was happening, debugging all the way down to the assembly, trying to find a cause and come up with a workaround...
     
    MarkDev_S and diegoadrada like this.
  35. Dmitry-Pyalov

    Dmitry-Pyalov

    Joined:
    Dec 13, 2011
    Posts:
    125
    @guavaman is the Hero (with capital "H") here. Having the same issue with VS 2019 16.6
    Is this bug reported to Microsoft/Unity or is this the new reality we have to live in?
     
  36. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    They've all been reported to Unity who in turn reported them to Microsoft. No word on any resolution at this time.
     
    Dmitry-Pyalov likes this.
  37. GavinoGrifoni

    GavinoGrifoni

    Joined:
    Jan 7, 2014
    Posts:
    3
    Just hopping in to thank @guavaman for the precise and prompt debugging of the issue. The DisableNewVS2019Optimizer script is working like a charm. You're the man!
     
  38. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Is there any progress with this from MS/Unity yet?
     
  39. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    No. This is entirely a Microsoft issue.
     
    Last edited: Jun 5, 2020
  40. brinca

    brinca

    Joined:
    Mar 29, 2015
    Posts:
    33
    Just wanted to say thanks, this worked like a charm!

    I also would like to point out that on solution 2 (adding the environment variable), there is actually no conflict because you can only build with IL2CPP on the actual platform you're targeting (e.g. you cannot build for Linux on a Windows machine using IL2CPP), so there's no risk of conflicting with another platform.

    Having said that, solution 2 actually didn't work for me (the executable fails to run), but solution 3 (script) works for sure.
     
    guavaman likes this.
  41. Dmitry-Pyalov

    Dmitry-Pyalov

    Joined:
    Dec 13, 2011
    Posts:
    125
    It seems like IL2CPP compilation is now crashing on Rewired_Core_9.cpp instead of producing broken build with the latest VS 2020 16.7
     
  42. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    With or without the optimizer workaround?
     
  43. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Lol.. I guess this is an improvement.
     
  44. Dmitry-Pyalov

    Dmitry-Pyalov

    Joined:
    Dec 13, 2011
    Posts:
    125
    Without the workaround. With workaround it compiles and works fine.
     
  45. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    Thanks!
     
  46. centaurianmudpig

    centaurianmudpig

    Joined:
    Dec 16, 2011
    Posts:
    92
    If it wasn't for this, I'd probably be still banging my head against the wall.

    @guavaman thank you for posting a fix. Do you have a tip jar or some such so I can buy you a coffee?
     
  47. Snigros

    Snigros

    Joined:
    Jun 12, 2018
    Posts:
    37
    Guavaman - Much thanks from me also...the ever hanging compilation was doing my head in!
     
  48. RoyArtorius

    RoyArtorius

    Joined:
    Jul 11, 2013
    Posts:
    73
    Can confirm this still seems to be a problem with the latest version of Visual Studio 2019 (16.10.3)

    I have moved the project and Unity editor (2021.1.14f1) to an SSD as well as added the paths as exceptions to my Antivirus according the manual page to speed up IL2CPP builds.
    I originally had just Visual Studio 2017 on my computer but I tried installing Unity's new hub beta (3.0.0) and it installed Visual Studio 2019 when I installed the Unity Editor with a greyed out option to disable Visual Studio under the module selection. Adding the script provided by guavaman seems to have the fixed the issue for me and I didn't even have Rewired in my project.

    It was also happening to me when doing Android builds. They seem to work now as well.
     
  49. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Microsoft never seems to fix this problem after almost whole year... even after nagging constantly on their forum. It is just beyond my understanding on why critical bug like this can not be fixed over whole year...
     
    guavaman likes this.
  50. guavaman

    guavaman

    Joined:
    Nov 20, 2009
    Posts:
    5,609
    This has to be a coincidence. The script only applies to Visual Studio. Android is not compiled with Visual Studio. And the script only sets the flag to disable the jump optimizer in VS in the build targets where VS is used as the compiler (Windows Standalone, UWP, Xbox, etc.)