Skip to content

Ruff fails to build in Termux on Android 14, unable to find -lgcc #17527

Description

@bdegreve

Summary

When trying to build Ruff in Termux on Android, it fails with the error unable to find library -lgcc

First, the following message is repeated many times:

'+fpmr' is not a recognized feature for this target (ignoring feature)

To finally conclude with:

...
'+fpmr' is not a recognized feature for this target (ignoring feature)
'+fpmr' is not a recognized feature for this target (ignoring feature)
error: linking with `cc` failed: exit status: 1
  |
  = note:  "cc" "<sysroot>/tmp/rustc7xXo1P/symbols.o" "<2201 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/tmp/rustc7xXo1P/{libtikv_jemalloc_sys-*,libzstd_sys-*}.rlib" "<sysroot>/lib/rustlib/aarch64-linux-android/lib/{libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc" "-ldl" "-llog" "-lunwind" "-ldl" "-lm" "-lc" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/data/data/com.termux/files/home/ruff/target/release/build/zstd-sys-8e4a345f2fc1e8e3/out" "-L" "/data/data/com.termux/files/home/ruff/target/release/build/tikv-jemalloc-sys-c141053eefecffab/out/build/lib" "-L" "/data/data/com.termux/files/home/ruff/target/release/build/tikv-jemalloc-sys-c141053eefecffab/out" "-o" "/data/data/com.termux/files/home/ruff/target/release/deps/ruff-b7c7594f40f7712c" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-Wl,-O1" "-Wl,--strip-debug" "-nodefaultlibs"
  = note: some arguments are omitted. use `--verbose` to show all linker arguments
  = note: ld.lld: error: unable to find library -lgcc
          cc: error: linker command failed with exit code 1 (use -v to see invocation)

I've found a similar issue reported to termux about vim-clap [1],
which was resolved upstream by disabling tikv-jemallocator on Android [2].

When duplicating that resolution by also disabling tikv-jemallocator in Ruff, cargo build --release will succeed, and running cargo run -p ruff -- check /path/to/file.py --no-cache also succeeds.

I don't know if that's the best solution, or even an acceptable (I'm not familiar with the Rust nor Android ecosystem), but I can create a PR with my changes for consideration.

I know there's a pre-built termux package that I can install with pkg install ruff, but I'd like to install ruff as part of a venv, for which it needs to be able to build from source.

Steps to reproduce in Termux:

pkg install build-essential rust
git clone https://github.com/astral-sh/ruff.git
cd ruff
cargo build --release

Environment:

  • TERMUX_VERSION=0.118.1
  • Android version: 14
  • Kernel build information: Linux localhost 5.15.153-android13-3-29539737 #1 SMP PREEMPT Fri Feb 14 18:09:51 KST 2025 aarch64 Android
  • Device: Samsung Galaxy Tab S9 FE (SM-X510)
  • SUPPORTED_ABIS: arm64-v8a,armeabi-v7a,armeabi
  • cargo: 1.86.0 (adf9b6ad1 2025-02-28)
  • ruff: main branch, g1918c6162

[1] termux/termux-packages#20063
[2] liuchengxu/vim-clap#1079

Version

ruff 0.11.6 (1918c61 2025-04-18)

Activity

  1. added a commit that references this issue on Apr 22, 2025
    d9c2b71
  2. MichaReiser commented on Apr 23, 2025

    @MichaReiser
    Member

    Thanks for the nice write up. Disabling jemalloc is an option, but it will result in a slower version of Ruff. I'd have to do some more research but jemalloc at least claims that android is supported. But maybe only if gcc is installed (which doesn't seem to be the case anymore for newer andorid ndks?)

  3. added
    cliRelated to the command-line interface of Ruff or ty
    on Apr 23, 2025
  4. bdegreve commented on Apr 23, 2025

    @bdegreve
    Author

    I've found this stating libgcc is indeed no longer available: https://blog.rust-lang.org/2023/01/09/android-ndk-update-r25/
    But I'm honestly unsure what that means for tikv-jemallocator.

    In meantime, I could try that workaround that the blog post mentions, and and redirect libgcc.a to libunwind.a. I'll keep you posted on how that goes...

  5. bdegreve commented on Apr 23, 2025

    @bdegreve
    Author

    @MichaReiser I'm happy to report that the workaround metiond in that blog post works. Ruff correctly builds, and pip install ruff now also works (pip needs to build it from source on Termux)

  6. laguill commented on Apr 26, 2025

    @laguill

    Hi @bdegreve,

    Can you elaborate a bit more how you did to solve this issue ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliRelated to the command-line interface of Ruff or ty

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions