Android builds failing when 'Script Debugging' is enabled

I’ve been struggling building for Android for a while and have narrowed things down somewhat but am stuck again and am not able to make any more progress.

Building without ‘Development Build’ checked: works fine and the game runs.

Building with ‘Development Build’ checked: the game freezes right after the splash screen.

Building with ‘Development Build’ + ‘Script Debugging’: build fails with the following error:

Edit: I forgot to say that this happens in both local and cloud builds

Edit 2: Also forgot to say that I’m running 2019.4.16f

Exception: C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe did not run properly!

Failed running “C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp/build/deploy/net471/il2cpp.exe” --compile-cpp --libil2cpp-static --platform=“Android” --architecture=“ARM64” --configuration=“ReleasePlus” --outputpath=“C:\Users\simon\repos\rugby-unity\Temp\StagingArea\assets\bin\Data\Native\arm64-v8a\libil2cpp.so” --cachedirectory=“C:\Users\simon\repos\rugby-unity\Assets..\Library\il2cpp_android_arm64-v8a/il2cpp_cache” --additional-include-directories=“C:/Program Files/Unity/Hub/Editor/2019.4.16f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\bdwgc/include” --additional-include-directories=“C:/Program Files/Unity/Hub/Editor/2019.4.16f1/Editor/Data/PlaybackEngines/AndroidPlayer/Tools\libil2cpp/include” --tool-chain-path=“C:/Program Files/Unity/Hub/Editor/2019.4.16f1/Editor/Data/PlaybackEngines/AndroidPlayer/NDK” --map-file-parser=“C:/Program Files/Unity/Hub/Editor/2019.4.16f1/Editor/Data/Tools/MapFileParser/MapFileParser.exe” --generatedcppdir=C:/Users/simon/repos/rugby-unity/Temp/StagingArea/Il2Cpp/il2cppOutput --dotnetprofile=“unityaot” --enable-debugger

stdout:
Building libil2cpp.so with AndroidToolChain
Output directory: C:\Users\simon\repos\rugby-unity\Temp\StagingArea\assets\bin\Data\Native\arm64-v8a
Cache directory: C:\Users\simon\repos\rugby-unity\Library\il2cpp_android_arm64-v8a\il2cpp_cache
ObjectFiles: 994 of which compiled: 0
Total compilation time: 935 milliseconds.
il2cpp.exe didn’t catch exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @“C:\Users\simon\AppData\Local\Temp\tmpBC36.tmp” -o “C:\Users\simon\repos\rugby-unity\Library\il2cpp_android_arm64-v8a\il2cpp_cache\linkresult_B7315E624227AAD87D98CA3B0A62996F\libil2cpp.so” -shared -Wl,-soname,libil2cpp.so -Wl,–no-undefined -Wl,-z,noexecstack -Wl,–gc-sections -Wl,–build-id -stdlib=libc++ -static-libstdc++ -target aarch64-linux-android21 -Wl,–wrap,sigaction -llog -rdynamic -fuse-ld=bfd.exe

C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function AndroidLogCallback(char const*)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/Initialize.cpp:12:(.text._ZL18AndroidLogCallbackPKc+0x18): relocation truncated to fit: R_AARCH64_JUMP26 against symbol __android_log_print’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/liblog.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function il2cpp::hushed:s::OpenAndroidConfig()': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/TimeZoneInfo.cpp:48:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1c): relocation truncated to fit: R_AARCH64_CALL26 against symbol getenv@@LIBC’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/libc.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function std::__ndk1::char_traits<char>::length(char const*)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/__string:217:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x50): relocation truncated to fit: R_AARCH64_CALL26 against symbol strlen@@LIBC’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/libc.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function il2cpp::hushed:s::OpenAndroidConfig()': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/TimeZoneInfo.cpp:49:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x88): relocation truncated to fit: R_AARCH64_CALL26 against symbol getenv@@LIBC’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/libc.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function std::__ndk1::__libcpp_allocate(unsigned long, unsigned long)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:259:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x9c): relocation truncated to fit: R_AARCH64_CALL26 against symbol operator new(unsigned long)’ defined in .text._Znwm section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function std::__ndk1::char_traits<char>::length(char const*)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/__string:217:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0xd0): relocation truncated to fit: R_AARCH64_CALL26 against symbol strlen@@LIBC’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/libc.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function std::__ndk1::_DeallocateCaller::__do_call(void*)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x114): relocation truncated to fit: R_AARCH64_CALL26 against symbol operator delete(void*)’ defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x124): relocation truncated to fit: R_AARCH64_CALL26 against symbol operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o) C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x18c): relocation truncated to fit: R_AARCH64_CALL26 against symbol operator delete(void*)’ defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1c4): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)’ defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1ec): additional relocation overflows omitted from the output
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)

at Unity.IL2CPP.Building.CppProgramBuilder.PostprocessObjectFiles(HashSet1 objectFiles, CppToolChainContext toolChainContext) at Unity.IL2CPP.Building.CppProgramBuilder.Build(IBuildStatistics& statistics) at il2cpp.Program.DoRun(String[ ] args, List1 foundAssemblies)
at il2cpp.Program.Run(String[ ] args, Boolean setInvariantCulture)
at il2cpp.Program.Main(String[ ] args)
stderr:

Unhandled Exception: Unity.IL2CPP.Building.BuilderFailedException: C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++ @“C:\Users\simon\AppData\Local\Temp\tmpBC36.tmp” -o “C:\Users\simon\repos\rugby-unity\Library\il2cpp_android_arm64-v8a\il2cpp_cache\linkresult_B7315E624227AAD87D98CA3B0A62996F\libil2cpp.so” -shared -Wl,-soname,libil2cpp.so -Wl,–no-undefined -Wl,-z,noexecstack -Wl,–gc-sections -Wl,–build-id -stdlib=libc++ -static-libstdc++ -target aarch64-linux-android21 -Wl,–wrap,sigaction -llog -rdynamic -fuse-ld=bfd.exe

C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function AndroidLogCallback(char const*)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/Initialize.cpp:12:(.text._ZL18AndroidLogCallbackPKc+0x18): relocation truncated to fit: R_AARCH64_JUMP26 against symbol __android_log_print’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/liblog.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function il2cpp::hushed:s::OpenAndroidConfig()': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/TimeZoneInfo.cpp:48:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1c): relocation truncated to fit: R_AARCH64_CALL26 against symbol getenv@@LIBC’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/libc.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function std::__ndk1::char_traits<char>::length(char const*)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/__string:217:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x50): relocation truncated to fit: R_AARCH64_CALL26 against symbol strlen@@LIBC’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/libc.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function il2cpp::hushed:s::OpenAndroidConfig()': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\il2cpp\libil2cpp\os\Android/TimeZoneInfo.cpp:49:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x88): relocation truncated to fit: R_AARCH64_CALL26 against symbol getenv@@LIBC’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/libc.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function std::__ndk1::__libcpp_allocate(unsigned long, unsigned long)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:259:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x9c): relocation truncated to fit: R_AARCH64_CALL26 against symbol operator new(unsigned long)’ defined in .text._Znwm section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function std::__ndk1::char_traits<char>::length(char const*)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/__string:217:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0xd0): relocation truncated to fit: R_AARCH64_CALL26 against symbol strlen@@LIBC’ defined in .text section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android/21/libc.so
C:/Users/simon/repos/rugby-unity/Library/il2cpp_android_arm64-v8a/il2cpp_cache/libil2cpp/DBC5130846C16018DCB65FE676D3FFB2.o: In function std::__ndk1::_DeallocateCaller::__do_call(void*)': C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x114): relocation truncated to fit: R_AARCH64_CALL26 against symbol operator delete(void*)’ defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x124): relocation truncated to fit: R_AARCH64_CALL26 against symbol operator delete(void*)' defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o) C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/../sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x18c): relocation truncated to fit: R_AARCH64_CALL26 against symbol operator delete(void*)’ defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/lib/aarch64-linux-android\libc++_static.a(new.o)
C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackEngines\AndroidPlayer\NDK\toolchains\llvm\prebuilt\windows-x86_64\bin/…/sysroot/usr/include/c++/v1/new:340:(.text._ZN6il2cpp2os17OpenAndroidConfigEv+0x1c4): relocation truncated to fit: R_AARCH64_CALL26 against symbol `operator delete(void*)’ defined in .text._ZdlPv section in C:\Program Files\Unity\Hub\Editor\2019.4.16f1\Editor\Data\PlaybackE

1 Like

Unfortunately, this is a known bug in the Android NDK r19 used with this version of Unity. When the executable size is too large, the native linker in the Android NDK will fail with this error. Enabling script debugging with IL2CPP adds a good bit of code size, and triggers this issue.

This is corrected in newer NDK versions, but at the moment, we can’t correct it in Unity versions before 2021.1. We’re investigating ways to work around this issue.

Ahh, that’s a bummer. Thanks for the response though.

“When the executable size is too large”
What might count as too large?

Do you have any guidance on how we might overcome this issue, besides updating to 2021.1?

I’m not sure what executable code size will trigger this bug in the Android linker, unfortunately, as I can’t specifically quantify it.

We’re working on some improvements to lower the generated code size, which I hope to back port - but they are not ready yet.

From your end, you can can review the code in your project. Determine if it is all necessary. You can increase the managed code stripping level to allow our managed code stripping tool to remove unused code. You can find details about this in our documentation here: https://docs.unity3d.com/Manual/ManagedCodeStripping.html

Had this same problem - our Android build has been failing last 6 days with confusing linker errors. Glad I found this thread!
Turning on “Strip Engine Code” (our project had it off) and changing “Managed Stripping Level” from Low to High seems to have helped the build finish. Hopefully there will not be any missing code at runtime - will test soon.
(Unity 2019.4.18)
Oddly we were only seeing the problem in command line builds - editor builds worked fine.

Encountered the same issue, and lost WAY too much time debugging this …

This only happens if we try to build against ARM64, ARMv7 builds are working just fine.

Disabling code debugging solves the issue, but that’s not a solution. Will try to bump code stripping from low to medium,

3 Likes

The issue is not fixed even in unity 2021.1.15f1. What gives?

Is the fix included in unity 2021.1.15f1? The build stil lfails when Script Debugging is enabled…

We could not come up with a good work around in Unity 2021.1, due to some other problems with the Android NDK tools. We attempted to use the lld linker in that version of Unity, but that lead to performance regressions, from what I understand, although I was not directly involved in this work.

In Unity 2021.2, we have a new IL2CPP code generation option that significantly reduces code size - check it out in the Build Settings dialog. I think that will be the best option to work around this issue for projects that cannot make the code size lower manually.

1 Like

Thanks! For the meantime, changing the stripping level to medium fixed the issue. But broke a lot of parts of our serialization system that is too much headache to deal with

@JoshPeterson From what I understand, linking large source base for ARM64 with ld.bfd can cause creation of a pretty large stub groups, so resizing it with –stub-group-size linker flag might be a workaround

What you need is to try PlayerSettings.SetAdditionalIl2CppArgs("–linker-flags="-Wl,–stub-group-size=11534360") (that is 110 MB per group) prior build.

The only issue there is that linker flag is obviously ARM64-only, thus ARM7 will fail if both architectures were chosen to build - because linker flags from additional cpp args are applied to all architectures at once.

Is there any way to separate linker flags setup for different architectures?

5 Likes

I was not aware of that flag - that is an interesting option. I don’t believe there is a way to add it for just one architecture now, but we may be able to always pass it internally for ARM64 builds.

3 Likes

Are there any news to this issue, I am using Unity 2021.2.13f1 and it is still not possible to enable script debugging without causing the android build to fail.

There are changes coming for Unity 2022.2 that update to a newer Android NDK (r23) and use lld as the native linker. Those changes alleviate this issue for most projects.

2 Likes

Is it possible to push those changes to Unity 2021 too because 2022 is still beta if I am not wrong. And using a beta version of Unity for a production ready project would be far from optimal.

Unfortunately no - this Android NDK update required a number of changes, from what I understand.

Yes this is unfortunate and impractical. Thank you for your quick replies!

Sorry that I don’t have better news!

I had the problem in 2020.3.28. Setting the code stripping from low to medium solved it.

1 Like