Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Xcode hang/freeze when including armv7 architecture in build

Discussion in 'iOS and tvOS' started by trooper, Feb 21, 2019.

  1. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    676
    When I build for amrv7 IL2CPP i will get a hang on this line:

    F/jenkins/workspace/TGW_BuildiOS/main_armv7_constructor_cleanup/build/debug/TGW/Frameworks/Plugins/iOS/UnityAdapter-2.1.2.0 -DINIT_SCRIPTING_BACKEND=1 -fno-strict-overflow -DNET_4_0 -DRUNTIME_IL2CPP=1 -DIL2CPP_MONO_DEBUGGER=1 -DENABLE_IOS_ON_DEMAND_RESOURCES -DINIT_SCRIPTING_BACKEND=1 -fno-strict-overflow -DNET_4_0 -DRUNTIME_IL2CPP=1 -DIL2CPP_MONO_DEBUGGER=1 -DENABLE_IOS_ON_DEMAND_RESOURCES -include /Users/osx2/Library/Developer/Xcode/DerivedData/Unity-iPhone-apepdbbqmnhbdybgqfhumkhllfgi/Build/Intermediates.noindex/PrecompiledHeaders/SharedPrecompiledHeaders/7817584888105464563/Prefix.pch -MMD -MT dependencies -MF /Users/osx2/Library/Developer/Xcode/DerivedData/Unity-iPhone-apepdbbqmnhbdybgqfhumkhllfgi/Build/Intermediates.noindex/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/Bulk_Assembly-CSharp_9.d --serialize-diagnostics /Users/osx2/Library/Developer/Xcode/DerivedData/Unity-iPhone-apepdbbqmnhbdybgqfhumkhllfgi/Build/Intermediates.noindex/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/Bulk_Assembly-CSharp_9.dia -c /jenkins/workspace/TGW_BuildiOS/main_armv7_constructor_cleanup/build/debug/TGW/Classes/Native/Bulk_Assembly-CSharp_9.cpp -o /Users/osx2/Library/Developer/Xcode/DerivedData/Unity-iPhone-apepdbbqmnhbdybgqfhumkhllfgi/Build/Intermediates.noindex/Unity-iPhone.build/Release-iphoneos/Unity-iPhone.build/Objects-normal/armv7/Bulk_Assembly-CSharp_9.o


    With architecture ARM64, everything build normally.

    Universal builds also hang.

    I've gone back through my changesets and noticed that some constructors in one of my classes had changed and a few fields were converted to properties when it started failing.

    I've done at least 20 different build with different changes to the code to try find out if something is tripping up IL2CPP but I really can't nail it down, here's some of what I've tried.
    1. Removing all constructors
    2. Removing auto properties
    3. Adding random params to existing constructors
    4. Completely re-writing the constructor flow so base classes flow differently.
    5. Turning off null checks via the IL2CPP attribute
    6. Removing enums from constructors
    7. Removing default properties in constructors
    I know the Bulk_Assembly-CSharp_9.o is around the 5MB mark so I was thinking that maybe there is an upper limit when building for ARMV7 for code file sizes, does Xcode get stuck due to a memory limit or something, I dunno.

    H ere's some side-by-side code diffs of different scenarios where one failed and one succeeded.

    LEFT succeeds, RIGHT fails
    upload_2019-2-21_21-46-11.png

    LEFT fails, RIGHT succeeds
    upload_2019-2-21_21-48-43.png
     
  2. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    676
    I'm fairly confident it's due to some sort of code size:

    Left side worked but right side did not in il2cpp configuration debug mode... however, I also built right side in il2cpp configuration release mode and it succeeded.
    upload_2019-2-22_0-52-53.png
     
  3. areavisuale

    areavisuale

    Joined:
    Jul 23, 2015
    Posts:
    44
  4. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    676
  5. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    676
    So this is definitely an issue with there being too much code in either the cpp file it hangs on or perhaps some other limit to do with the class.

    By limiting how much IL2CPP is generated I was able to get these builds to work on ARMV7. Instead of using a database I define all my 'data' inside C# classes (i know it's backwards) and our decals were quite numerous.

    I've changed our generated code to use the Il2cppSetOption attribute so it generates less code and now we have no issue.
    upload_2019-2-23_12-34-45.png
     
  6. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    4,136
    I'm glad you tracked this down. IL2CPP struggles with code like this, where a lot of 'data' is defined in C# code. It leads to many local variables in the IL code, which translate to many local variables in the generated C++ code. The C++ compiler's register allocator tends to struggle with many local variables.

    One work around is to break up the 'data' in C# into a number of smaller functions. That can often help the C++ compiler with the register allocation problem.
     
  7. trooper

    trooper

    Joined:
    Aug 21, 2009
    Posts:
    676
    I hit the limit again (somewhere over 4.6mb this time) so I'm biting the bullet and putting our reference data into a database instead.