fix(build): build xxHash objects with PIC for MllmRT#683
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR enables position-independent code compilation for the xxHash library's object library target by setting the ChangesPosition-Independent Code Configuration
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Summary
This PR builds the xxHash object library with position-independent code so it can be safely linked into
MllmRT.MllmRTis a shared library and linksxxHash::xxhash. On Linux x86_64, the current build may fail when linkinglibMllmRT.sobecausexxhash_staticis created from$<TARGET_OBJECTS:xxhash_impl>, while thexxhash_implobjects 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
MllmRTlink step and fail with: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.txtbuilds the xxHash sources through thexxhash_implobject target, then createsxxhash_staticfrom those object files: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_CODEonxxhash_impl, the target that actually compilesxxhash.candxxh_x86dispatch.c.Validation
git diff --checkcmake -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=OFFcmake --build build-xxhash-pic --target MllmRT -j2Summary by CodeRabbit