Skip to content

fix(jemalloc-sys): pin --libdir to avoid distro site-script lib64 redirect - #181

Open
rtyler wants to merge 2 commits into
tikv:mainfrom
buoyant-data:fix/lib64-libdir-mismatch
Open

rtyler wants to merge 2 commits into
tikv:mainfrom
buoyant-data:fix/lib64-libdir-mismatch

Conversation

@rtyler

@rtyler rtyler commented Sep 7, 2026 •

Copy link
Copy Markdown

This was a 🦜 generated fix to a build error that has been buggin' the heck out of me in delta-io/delta-rs when using aarch64 machines.

Some Linux distributions ship an autoconf site-script (/usr/share/site/) that silently rewrites the configured libdir from ${prefix}/lib to ${prefix}/lib64 for 64-bit hosts (e.g. the OpenSUSE aarch64 site script). jemalloc is compiled via ./configure inside the build script, so its static libraries end up in $OUT_DIR/lib64. However, build.rs hard-codes the link-search path as $OUT_DIR/lib, so cargo can't find libjemalloc_pic.a and the build fails with:

error: could not find native static library jemalloc_pic,
perhaps an -L flag is missing?

Fix: pass --libdir=${out_dir}/lib explicitly to configure. This overrides any site-script redirect and keeps the installed path consistent with the search path already emitted by build.rs.

Reproduces on: OpenSUSE Leap 16 aarch64 (site script at /usr/share/site/aarch64-unknown-linux-gnu).

Summary by CodeRabbit

  • Bug Fixes
    • Ensured jemalloc’s static libraries are installed in the directory used by the build system, preventing configuration scripts from redirecting them elsewhere.

…irect

Some Linux distributions ship an autoconf site-script
(/usr/share/site/<triple>) that silently rewrites the configured libdir
from `${prefix}/lib` to `${prefix}/lib64` for 64-bit hosts (e.g. the
OpenSUSE aarch64 site script).  jemalloc is compiled via `./configure`
inside the build script, so its static libraries end up in
`$OUT_DIR/lib64`.  However, build.rs hard-codes the link-search path as
`$OUT_DIR/lib`, so cargo can't find `libjemalloc_pic.a` and the build
fails with:

  error: could not find native static library `jemalloc_pic`,
         perhaps an -L flag is missing?

Fix: pass `--libdir=${out_dir}/lib` explicitly to configure.  This
overrides any site-script redirect and keeps the installed path
consistent with the search path already emitted by build.rs.

Reproduces on: OpenSUSE Leap 16 aarch64 (site script at
/usr/share/site/aarch64-unknown-linux-gnu).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: R Tyler Croy <rtyler@buoyantdata.com>
@coderabbitai

coderabbitai Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 21c8a707-ae4c-47d8-b903-ea8cd48b8df0

📥 Commits

Reviewing files that changed from the base of the PR and between a181911 and 7310887.

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

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


📝 Walkthrough

Walkthrough

The jemalloc configure command now sets libdir to <OUT_DIR>/lib. This aligns the install directory with the existing Cargo link-search path and prevents configure site scripts from redirecting static libraries elsewhere.

Changes

jemalloc build configuration

Layer / File(s) Summary
Set library installation path
jemalloc-sys/build.rs
The configure command now sets libdir to <OUT_DIR>/lib.

Priority: ⬇️ Low

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

Change: Bug fix

Suggested reviewers: kali

Merge Risk: ⚪ Minimal · up to 73108

The library installation directory is aligned with the build’s search path, and no material merge risk is evident.

Architecture Summary

Architecture risk: 🔵 Low · up to 73108

The change affects 1 system.

Changed systems: jemalloc-sys

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — jemalloc-sys (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in jemalloc-sys/build.rs: The configure command now pins the library installation directory to <OUT_DIR>/lib; previously it left libdir to configure defaults or site-script overrides.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: pinning jemalloc's --libdir to prevent distribution site scripts from redirecting libraries to lib64.

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.

@ti-chi-bot

ti-chi-bot Bot commented Sep 7, 2026

Copy link
Copy Markdown

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

@rtyler
rtyler marked this pull request as ready for review September 26, 2026 13:28
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