Search code examples
androidunity-game-engineandroid-ndkil2cpp

Unity 2018.3, linker crashes during il2cpp compilation on Android (ndk n16b) after upgrading to Catalina


After upgrading to macOS Catalina, my Unity 2018.3 fails to compile for Android using il2cpp.

The error seems to happen during the linking process.

Here's the output:

/Users/myuser/Applications/android-ndk-r16b/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ @"/var/folders/vq/04653nwj79jdpld6_lndr1lw0000gn/T/tmpXtN5uB.tmp" -o "/Users/myuser/Documents/Unity/MyProject/Library/il2cpp_android_arm64-v8a/il2cpp_cache/linkresult_44B2FEF258539B2B7FE0DE0B1C88B423/libil2cpp.so" -shared -Wl,-soname,libil2cpp.so -Wl,--no-undefined -Wl,-z,noexecstack -Wl,--gc-sections -Wl,--build-id --sysroot "/Users/myuser/Applications/android-ndk-r16b/platforms/android-21/arch-arm64" -gcc-toolchain "/Users/myuser/Applications/android-ndk-r16b/toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64" -target aarch64-none-linux-android -Wl,--wrap,sigaction -L "/Users/myuser/Applications/android-ndk-r16b/sources/cxx-stl/gnu-libstdc++/4.9/libs/arm64-v8a" -lgnustl_static -llog -Xlinker -Map="/Users/myuser/Documents/Unity/MyProject/Library/il2cpp_android_arm64-v8a/il2cpp_cache/linkresult_44B2FEF258539B2B7FE0DE0B1C88B423/libil2cpp.map" -rdynamic -fuse-ld=bfd
clang++: error: invalid linker name in argument '-fuse-ld=bfd'

Looks like in the NDK there is no linker ld-bfd for darwin-x86_64 :(

Do you have any idea on how to fix?


Solution

  • I've found a (really bad) workaround, that... works.

    Navigate to your NDK folder, then:

    cd toolchains/aarch64-linux-android-4.9/prebuilt/darwin-x86_64/aarch64-linux-android/bin

    Now, copy the gold linker as bfd:

    cp ld.gold ld.bfd

    Not sure if it has any side effect, but, well... it compiles!