What

Some times ago,there were numberous github actions errors in my Rust Hybrid Project,but I don’t have time to go through it。Just took time to look at it today,I found it was caused by -lgcc linker. However, I haven’t pushed to this repository for long time, what would be the root cause?

1
2
note: ld: error: unable to find library -lgcc
          clang-12: error: linker command failed with exit code 1 (use -v to see invocation)

error link

Why

Although there is no clue, but the error is so obvious that it is not very difficult to find. So I looked for it from two directions, one is the Rust release notes, and the other is the update of the Github Actions environment.

The first is the Rust release notes. I searched and found nothing related to the update of Android and libgcc. Then change the direction, see what updates Github Actions has, and find the Github official document, this does not clearly say what version, just the LTS version. Then look again, there is a more detailed document. Rust is the latest version 1.62.1, and the NDK version is R25 by default. Is there a problem with the NDK version?

I followed the vines, combined these two information and searched again, and I found Issue finally, it turned out that libgcc was removed after NDK in r23, but Rust relies on this for providing missing builtins on Android.

How

It’s so easy to fix the issue when we know the root cause. Downgrade the NDK version will resolve this issue, we cannot use latest Rust version due to they don’t officially merge the fix to the stable release.

1
2
3
4
5
6
7
8
- uses: nttld/setup-ndk@v1
  id: setup-ndk
  with:
    ndk-version: r22b
    add-to-path: true
- name: your build
  env:
    ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}

Success Pipeline

Perfect❤️