Skip to content

riscv: link libgcc for jemalloc's __ffsdi2 - #180

Open
kali wants to merge 1 commit into
tikv:mainfrom
kali:riscv-link-libgcc
Open

riscv: link libgcc for jemalloc's __ffsdi2#180
kali wants to merge 1 commit into
tikv:mainfrom
kali:riscv-link-libgcc

Conversation

@kali

@kali kali commented Sep 7, 2026

Copy link
Copy Markdown

Base rv64gc has no count-trailing-zeros instruction, so gcc lowers the ffs in bit_util.h to a __ffsdi2 libgcc call. rust's compiler_builtins ships the rest of the *di2 family but not that one, so linking a static riscv64 binary fails with undefined reference to `__ffsdi2'.

Name libgcc for riscv as is already done for android, guarded on a gnu-like compiler so a clang/compiler-rt toolchain is left alone.

Summary by CodeRabbit

  • Bug Fixes
    • Improved builds for RISC-V targets using GNU-like compilers by ensuring the required compiler support library is linked.
    • Resolved linker failures on base RV64GC systems lacking the Zbb extension.

Base rv64gc has no count-trailing-zeros instruction, so gcc lowers the
ffs in bit_util.h to a __ffsdi2 libgcc call. rust's compiler_builtins
ships the rest of the *di2 family but not that one, so linking a static
riscv64 binary fails with undefined reference to `__ffsdi2'.

Name libgcc for riscv as is already done for android, guarded on a
gnu-like compiler so a clang/compiler-rt toolchain is left alone.

Signed-off-by: Mathieu Poumeyrol <kali@zoy.org>
@ti-chi-bot

ti-chi-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

Welcome @kali! It looks like this is your first PR to tikv/jemallocator 🎉

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: 1828cedd-21f9-486d-89a9-9feebbad9df2

📥 Commits

Reviewing files that changed from the base of the PR and between 0e91291 and 3db58f2.

📒 Files selected for processing (1)
  • jemalloc-sys/build.rs

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The RISC-V build script now links gcc when it detects a GNU-like compiler. This supplies __ffsdi2 for rv64gc builds while retaining the existing atomic linkage.

Changes

RISC-V linker configuration

Layer / File(s) Summary
GNU libgcc linkage
jemalloc-sys/build.rs
The RISC-V branch checks compiler.is_like_gnu() and links gcc when the condition is true.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to 3db58

GNU RISC-V builds now link libgcc to resolve the missing __ffsdi2 symbol for base rv64gc targets, without changing Clang/compiler-rt linkage. No current merge-blocking risk is identified.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: linking libgcc for jemalloc's RISC-V __ffsdi2 dependency.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant