Skip to content

fix(build): build xxHash objects with PIC for MllmRT#683

Open
kkkzbh wants to merge 1 commit into
UbiquitousLearning:mainfrom
kkkzbh:codex/fix-xxhash-pic
Open

fix(build): build xxHash objects with PIC for MllmRT#683
kkkzbh wants to merge 1 commit into
UbiquitousLearning:mainfrom
kkkzbh:codex/fix-xxhash-pic

Conversation

@kkkzbh

@kkkzbh kkkzbh commented Jun 12, 2026

Copy link
Copy Markdown

Summary

This PR builds the xxHash object library with position-independent code so it can be safely linked into MllmRT.

MllmRT is a shared library and links xxHash::xxhash. On Linux x86_64, the current build may fail when linking libMllmRT.so because xxhash_static is created from $<TARGET_OBJECTS:xxhash_impl>, while the xxhash_impl objects are not compiled with PIC.

Background

I found this while investigating the official x86 Qwen3-0.6B C++ runner/build path. The x86 build can reach the MllmRT link step and fail with:

/usr/bin/ld.bfd: lib/libxxhash_static.a(xxhash.c.o): relocation R_X86_64_32S against `.rodata` can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld.bfd: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status

Other x86 backend findings from that investigation are intentionally kept out of scope. This PR only fixes the xxHash PIC linkage issue.

Root Cause

third_party/xxHash/CMakeLists.txt builds the xxHash sources through the xxhash_impl object target, then creates xxhash_static from those object files:

add_library(xxhash_impl OBJECT ${_src})
add_library(xxhash_static STATIC $<TARGET_OBJECTS:xxhash_impl>)

Setting PIC on the static archive target is not enough here, because the object files are already produced by xxhash_impl.

Fix

Enable POSITION_INDEPENDENT_CODE on xxhash_impl, the target that actually compiles xxhash.c and xxh_x86dispatch.c.

Validation

  • git diff --check
  • cmake -S . -B build-xxhash-pic -G Ninja -DCMAKE_BUILD_TYPE=Release -DHWY_ENABLE_TESTS=OFF -DHWY_ENABLE_EXAMPLES=OFF -DHWY_ENABLE_CONTRIB=OFF -DMLLM_CPU_BACKEND_COMPILE_OPTIONS="-march=native" -DMLLM_KERNEL_USE_THREADS=ON -DMLLM_KERNEL_THREADS_VENDOR_OPENMP=ON -DMLLM_KERNEL_USE_THREADS_VENDOR_MLLM=OFF
  • cmake --build build-xxhash-pic --target MllmRT -j2

Summary by CodeRabbit

  • Chores
    • Updated internal build configuration for improved code compatibility.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 90b587e0-4d31-4c36-9d45-96cd46b04aba

📥 Commits

Reviewing files that changed from the base of the PR and between b9c3070 and d061406.

📒 Files selected for processing (1)
  • third_party/xxHash/CMakeLists.txt

📝 Walkthrough

Walkthrough

This PR enables position-independent code compilation for the xxHash library's object library target by setting the POSITION_INDEPENDENT_CODE property to ON in its CMake configuration.

Changes

Position-Independent Code Configuration

Layer / File(s) Summary
Enable PIC for xxhash_impl
third_party/xxHash/CMakeLists.txt
xxhash_impl object library is configured to build with position-independent code via set_target_properties.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A single line, so neat and small,
Makes hashes dance without a wall,
Position-independent now they stand,
Built with care by rabbit's hand,
Flexibility in every byte! 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: enabling position-independent code compilation for xxHash objects to fix a linking issue with MllmRT.
Description check ✅ Passed The description provides comprehensive context including summary, background, root cause analysis, fix explanation, and validation steps, exceeding the minimal template requirement.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@kkkzbh kkkzbh marked this pull request as ready for review June 12, 2026 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant