Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug XCode can not build UnityWebRequest.o

Discussion in 'iOS and tvOS' started by JesOb, Apr 20, 2021.

  1. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,081
    Hi

    ld: b(l) ARM64 branch out of range (136049796 max is +/-128MB): from +[UnityURLRequest storeRequest:taskID:] (0x00006F60) to __Unwind_Resume@0x00000000 (0x081C64D0) in ‘+[UnityURLRequest storeRequest:taskID:]’ from /Users/xxx/Library/Developer/Xcode/DerivedData/Unity-iPhone-axjxbqexywgtvtcndrhyokjjgstl/Build/Intermediates.noindex/Unity-iPhone.build/Debug-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityWebRequest.o
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    Unity 2020.2.4f1

    How can we workaround this?
    I even dont know where to start
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,640
    Do you end up have a VERY LOT of generated C++ code in your project?
    The error indicates that the resulting machine code is so huge that you hit the limitations. To solve this you need to either reduce the code (are you using engine code stripping?) or have a look at clang linker options, maybe there is an option for generating different machine code for branching.
     
  3. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,081
    Android easily builded and sizes are:
    - libil2cpp.so 311 MB
    - managed dlls 24 MB
    - il2cppOutput 1228 MB

    I dont know exactly is it too much or not. il2cpp always been x50 to managed Code
    If this is too much, how can we understand why il2cpp create so much code from such small codebase?
     
  4. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,081
    Yes we are

    Actually nothing changed in xcode project just build.
    Will try to find some useful settings.
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,640
    Does it compress well enough for you? Because you risk exceeding the store limitations:
    https://developer.android.com/google/play/expansion-files

    It mostly comes does to how compiler lays things in the executable. iOS and Android use different linkers, so there can be difference, but what concerning is that you seem to be pushing stuff to the limit.
     
  6. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,081
    Thanks. We already on google play store, use android app bundles and play asset delivery

    Now trying to build for iOS.
    Builds stop building few days ago.

    Can you please clarify what average ilbil2cpp.so and il2cppOutput size considered normal?
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,640
    There are no "normal" here. Just having apk size limited to 100MB the 300+MB library even when zipped should put you not that far from the limit.
    The things to watch for are C# generics, which can easily explode in size, and any libraries (including .NET standard one) that you use, maybe some can be avoided.
     
  8. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    @Jes28 I think that 1GB of generated code is really a lot for most projects, certainly it is too much if you consider this to be a small project.

    Can you try this project with the latest 2021.2 beta? If so, please try the "IL2CPP Code Generation" option "smaller (faster) builds" in the Build Settings window. That should minimize the cost of generics in code size by doing much more generic sharing. I'm curious about how that impacts the build size.

    Also, is this a project you can share via a bug report? We may be able to have a look and better understand where the large code size is coming from.
     
  9. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    135
    @JoshPeterson
    Hi, I am having the same problem right now.
    And it is not caused by a change in the code, but by a Unity version upgrade. (2020.3.18 -> 2020.3.42)
    My project is already released, so it is difficult to raise it to 2021. And I want to use the bug fixes that came in 2020.3.26.
    Do you know up to which version I can raise it?
    Also, like myself, there are people who say that it occurred when they raised it to 2020.3.33.
    This comment section.
    https://issuetracker.unity3d.com/is...lding-development-build-with-script-debugging
     
  10. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    90
    Same here after updating 2021.3.12f1 to 2021.3.15f1

    "Strip engine code" is disabled on both versions of Unity, 2021.3.12f1 builds fine, 2021.3.15f1 crashes with the same error above. Enabling "strip engine code" on Unity 2021.3.15f1 fixes the issue.
     
    Last edited: Dec 4, 2022
  11. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    135
    Additional information.
    In my environment, "Strip engine code" is enabled and "strippingLevel" is set to Medium, but with 2020.3.42, I get an error.
    If I set "strippingLevel" to High, the build passes, but looking at the size of the C++ code, I think this too will soon reach its limit.
     
  12. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Do you have the "Script Debugging" option enabled in the Build Settings? That is the trigger for the problem in https://issuetracker.unity3d.com/is...lding-development-build-with-script-debugging.
     
  13. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    135
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Yes, if you are seeing an error with script debugging disabled (and it sounds like that is the case), then something else is happening which is unexpected.

    Can you post the specific error message here?
     
  15. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    135
    Do you need a full log?
    It looks like the same log as when it goes through normally until just before this.


    ❌ ld: b(l) ARM64 branch out of range (134537264 max is +/-128MB): from +[UnityURLRequest storeRequest:taskID:] (0x00006DA0) to __Unwind_Resume@0x00000000 (0x08054E8C) in '+[UnityURLRequest storeRequest:taskID:]' from /Users/oinkun/Library/Developer/Xcode/DerivedData/Unity-iPhone-ajjzuruupamzzwghesapudcjmrac/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/Unity-iPhone.build/Debug-iphoneos/UnityFramework.build/Objects-normal/arm64/UnityWebRequest.o



    ❌ clang: error: linker command failed with exit code 1 (use -v to see invocation)


    ** ARCHIVE FAILED **


    The following build commands failed:
    Ld /Users/oinkun/Library/Developer/Xcode/DerivedData/Unity-iPhone-ajjzuruupamzzwghesapudcjmrac/Build/Intermediates.noindex/ArchiveIntermediates/Unity-iPhone/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/UnityFramework.framework/UnityFramework normal (in target 'UnityFramework' from project 'Unity-iPhone')
    (1 failure)
    [08:38:02]: Exit status: 65
     
    Last edited: Dec 5, 2022
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Thanks for the details. To be clear, does this happen when script debugging is not enabled?
     
  17. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    135
    Yes.
    Script Debugging is off.
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    I don't know of any specific changes in Unity during that timeframe which would have significantly increased the code size. I suspect that this project was always right on the edge, and some small-ish change pushed it over the line into this problem.

    You can try a work around - set the IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND define in Xcode when you compile. See the code in the il2cpp-config-platforms.h header file for some details in a comment. This will avoid this linker problem, but it will make managed stack traces less reliable. It is not a great solution, but might work for the time being.
     
    shoji_kohei_xa and kyubuns like this.
  19. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    135
    That is an excellent suggestion.
    I'll try it tomorrow!
    Thanks!
     
  20. kyubuns

    kyubuns

    Joined:
    Aug 6, 2013
    Posts:
    135
    This worked perfectly on my project!
    Thank you so much!

    ---

    To others who have seen this thread.
    IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND is not added to the Unity defines, but to the Xcode defines.
    I was using fastlane to build, so I added the following option to xcargs.

    ```
    xcargs += " GCC_PREPROCESSOR_DEFINITIONS=\"$(inherited) IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND=1\""
    ```
     
    TakayaNinagawa likes this.
  21. IgorBoyko

    IgorBoyko

    Joined:
    Sep 28, 2020
    Posts:
    90
    Added IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND to xcodebuild and the issue seems to be gone for now.
    For those who are building via xcodebuild, the command would look like this:
    Code (CSharp):
    1. xcodebuild -workspace Unity-iPhone.xcworkspace \
    2. ...
    3. GCC_PREPROCESSOR_DEFINITIONS='$GCC_PREPROCESSOR_DEFINITIONS IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND=1' \
    4. ...
    5. -archivePath build.xcarchive archive
     
  22. tthibault

    tthibault

    Joined:
    Oct 5, 2021
    Posts:
    4
    To others needing to get this working in Unity Cloud Build: I got this working by creating a file called Gymfile in Assets\ucb with the contents :

    xcargs 'GCC_PREPROCESSOR_DEFINITIONS="$GCC_PREPROCESSOR_DEFINITIONS IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND=1"'


    And a file called ucb_xcode_fastlane.json in Assets with the contents :

    {
    "gymfile": "Assets/ucb/Gymfile"
    }


    There was no need to touch any settings in the cloud build settings
     
  23. ETGgames

    ETGgames

    Joined:
    Jul 10, 2015
    Posts:
    88
    I cannot get it to work. It seems like the flag got passed fine, but it's not being considered by the build properly or smth


    ld: B/BL out of range 182887748 (max +/-128MB) to '__ZN3Geo8GeoArrayIPKN9Enlighten13MaterialGuids12InstanceInfoEE11SetCapacityEi'

    clang: error: linker command failed with exit code 1 (use -v to see invocation)

    This is the command
    xcodebuild -project Unity-iPhone.xcodeproj GCC_PREPROCESSOR_DEFINITIONS='IL2CPP_LARGE_EXECUTABLE_ARM_WORKAROUND=1' -archivePath build.xcarchive archive -scheme "Unity-iPhone"

    Unity 2023.1.15f1
     
    Last edited: Oct 12, 2023
  24. RGCO

    RGCO

    Joined:
    Jul 27, 2016
    Posts:
    1
    @JoshPeterson we wanted to bump this thread. We started seeing this exact issue with the macOS Sonoma and Xcode 15 upgrade on our build farm. The builds were working just fine yesterday, and post the upgrades the builds now fail with this issue.

    We're currently on 2022.3.11f1 and are seeing the following:

    Code (CSharp):
    1. d: B/BL out of range 144489060 (max +/-128MB) to '__ZN3Geo8GeoArrayIPKN9Enlighten13MaterialGuids12InstanceInfoEE11SetCapacityEi'
    The workaround above does not work, however if you add -ld64 to the other linker flags on the Unity target and framework allows it to build.

    Another reference: https://developer.apple.com/forums/thread/738275?login=true&page=1#769744022

    Best regards
     
    Last edited: Oct 25, 2023