One: [infra/Android] Using gold linker for android build

Created on 16 Sep 2020  路  3Comments  路  Source: Samsung/ONE

This issue come from #4273 (comment)

Summary

  • Android NDK fails to link android log library when using BFD linker https://github.com/android/ndk/issues/556
  • BFD linker is default for arm64-v8a
  • Using gold linker solves this issue
  • However, gold linker emits broken debug information for AArch64

During ruy library upgade, I met this linking error.

/ndk/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld: warning: liblog.so, needed by libonert_core.so, not found (try using -rpath or -rpath-link)

Android Linking Dependency

  • onert_core -> cker -> ruy -> cpuinfo -> clog -> log

When building onert_core, it is looking for android log library and produces warning.

I found similar cases (https://github.com/opencv/opencv/issues/17282, https://github.com/android/ndk/issues/1088, and https://github.com/facebookincubator/profilo/commit/3ee6e6fe84264dccfdb40323e07fd4ac6883ae27) and solution for those cases is using gold linker.

Gold linker is default linker for arm32 but not for aarch64. It produces broken debug info for AArch64.

Issue 70838247: Gold emits broken debug information for AArch64. AArch64 still uses BFD by default.

https://github.com/android/ndk/blob/694195780dddc3695c72c047bdf4afe79fc4f982/Changelogs/Changelog-r20.md

I'm not sure which linker should we use. Can we use the golder linker for android?

/cc @hseok-oh @wateret @chunseoklee @YongseopKim

typissue

Most helpful comment

@chunseoklee Yes I have. It builds and runs well with LLD linker.

LLD will be used as default linker at NDK r22. https://android.googlesource.com/platform/ndk/+/master/docs/Roadmap.md#default-to-lld-and-llvm-binutils
This issue will be resolved when we use NDK r22 for android build.

All 3 comments

From NDK r20, it provides LLD (LLVM Linker) as new linker option.

AOSP has switched to using LLD by default and the NDK will follow (timeline unknown).

https://github.com/android/ndk/blob/master/Changelogs/Changelog-r21.md

Maybe we can move on to LLD instead of gold linker.

Maybe we can move on to LLD instead of gold linker.

Have you tested ?

@chunseoklee Yes I have. It builds and runs well with LLD linker.

LLD will be used as default linker at NDK r22. https://android.googlesource.com/platform/ndk/+/master/docs/Roadmap.md#default-to-lld-and-llvm-binutils
This issue will be resolved when we use NDK r22 for android build.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hasw7569 picture hasw7569  路  4Comments

seanshpark picture seanshpark  路  3Comments

mhs4670go picture mhs4670go  路  3Comments

KimDongEon picture KimDongEon  路  4Comments

jinevening picture jinevening  路  3Comments