mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #3359] [Engine] Builds failing on Linux for strata-vision-hip (latest) #1364
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#1364
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @antropiq on GitHub (Oct 20, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3359
Hi All,
I did a local fix using Strata (on another machine!). Here is the diagnostic conversation flow:
To summarize:
this line:
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
needs to be added to tools/vision/CMakeLists.txt
Step to reproduce
Compiling the picture reader for your AMD GPU (a few minutes, once) ...
And then ...
/usr/bin/ld: llama/ggml/src/ggml-hip/libggml-hip.a(ggml-cuda.cu.o): réadressage R_X86_64_32 vers « .rodata.str1.1 » ne peut pas être utilisé en créant un objet PIE; recompilez avec -fPIE
/usr/bin/ld : impossible de fixer les tailles des sections dynamiques : mauvaise valeur
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
(the build stopped - trying it once more)
/usr/bin/ld: llama/ggml/src/ggml-hip/libggml-hip.a(ggml-cuda.cu.o): réadressage R_X86_64_32 vers « .rodata.str1.1 » ne peut pas être utilisé en créant un objet PIE; recompilez avec -fPIE
/usr/bin/ld : impossible de fixer les tailles des sections dynamiques : mauvaise valeur
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
assistant
Let me re-examine the repo from its reverted state, focusing on that exact path (vision → HIP →
ggml-cuda.cu.o).Now let me look at the exact call site and the centralcmake_build().Let me look at the vision CMake project and how it pulls in llama.cpp.Let me compare with the engine's HIP path (which apparently links fine) to see how it handles PIC.Thellama.cppcheckout isn't on this machine (setup.py downloads it), so let me verify the pin and check which tests assert the exact command line.Let me verify against the actual pinned llama.cpp sources and check which tests assert on these commands.Let me check the AMD tests for any assertion on the vision-HIPdefslist, and confirm the engine build's ordering (PIC set before the ggml subdirectory).Let me fetch the exact pinned llama.cpp sources to verify precisely which target lacks PIC.Let me verify how CMake handles PIC for the HIP language, since that determines which fix actually works.The engine HIP build works on the same machine — let me confirm why, since that's the key to the right fix.Now I have the key asymmetry. Let me verify two final things: how the engine build getsggml-hip, and whether CMake applies-fPICto HIP-language sources.Let me check the repo's docs/changelog for prior HIP/PIE history and confirm nothing else overrides PIC.Let me verify the crux: whether CMake applies-fPICto HIP-language targets at all.Confirmed the mechanism. Let me check two final details — CMake's Linux default for PIC, and whether llama.cpp's own HIP path normally sets it.Let me verify at the CMake-source level whether the PIC flag is applied to HIP-language sources, and inspect llama.cpp's backend helper.I have the root cause confirmed. Let me verify one last thing — whether CMake's PIC flag actually applies to HIP-language sources.Let me confirm no test asserts on the visiondefslist, so you know which change is safest.One more check — the standalone packaging script that builds the same target:One last but critical verification — whether CMake's PIC machinery actually reaches HIP-language sources (a known CMake gap):One crucial detail to verify: whether CMake's PIC machinery actually reaches HIP-language sources (this decides which fix works).Final verification — that CMake's PIC flag actually reaches HIP-language sources:Let me pin down CMake's default for static libraries — this is the crux of the diagnosis.I now have the mechanism fully confirmed. Let me capture the exact text of the other invocation sites so my line references are precise.I've traced it fully. The diagnosis you asked me to confirm is exactly right, and there's a specific reason it hits only the picture reader and never the engine. Here it is.Why the engine builds fine but
strata-vision-hipdoes notBoth go through the same
cmake_build(). The difference is in the CMake project each one configures:build-hip)build-vision-hip)CMakeLists.txttools/vision/CMakeLists.txt— a separate top-level project (project(strata_vision C CXX), line 14)CMakeLists.txt:104-106→include(cmake/hip_backend.cmake)cmake/hip_backend.cmake:91-92—# HIP's link step produces a PIE; make Strata and ggml objects PIC for the ROCm linker./set(CMAKE_POSITION_INDEPENDENT_CODE ON)— set beforeadd_subdirectory(.../ggml)atCMakeLists.txt:1525/1536ggml-hipbuilt?GGML_HIPis never set in the engine build (grepshowsGGML_HIPappears only intools/vision/CMakeLists.txt:64)tools/vision/CMakeLists.txt:64So
tools/vision/CMakeLists.txtis the only place in the repo that buildsggml-hip, and it is also the only place that omits the PIC setting the engine build uses for exactly this purpose.hip_backend.cmake:91is, in effect, the fix already written down — it just never reaches the vision project.It compounds:
tools/vision/CMakeLists.txt:31forcesBUILD_SHARED_LIBS OFF, and llama.cpp only turns on PIC for its ggml targets insideif (BUILD_SHARED_LIBS)(ggml/src/CMakeLists.txt, pinned commit3cf0325):CMake only defaults
POSITION_INDEPENDENT_CODEto true for SHARED/MODULE libraries (cmTarget.cxx), never for static ones or executables. Solibggml-hip.ais built non-PIC, whilestrata-visionis anadd_executablethat Debian's gcc links as PIE by default — your link line has no-no-pie, which confirms this. HenceR_X86_64_32 → .rodata.str1.1.(The
.cuhost objects just happen to be the ones clang emits with an absolute 32-bit relocation; the.cppobjects in the same archives aren't guaranteed PIC either, which is why patching onlyggml-hipcan move the error tolibllama.aorlibmtmd.a. Fix it project-wide.)The change to make
Primary fix —
tools/vision/CMakeLists.txt. Insert one line at the end of the existing HIP block (lines 65-70), i.e. beforeadd_subdirectory(${LLAMA_DIR} llama ...)on line 72. Ordering matters:CMAKE_POSITION_INDEPENDENT_CODEis a variable inherited by subdirectories, so it must be set before the llama.cpp tree is added.This covers every route to this target —
setup.py,packaging/build_hip_linux.sh:63, andtools/hip/build_windows.bat:100.Optional belt-and-braces —
setup.py, theconfline insidecmake_build()(function at line 4764, the line at 4775-4776). This is where the command in your log is assembled:Keep it before
*defsso per-backend defs can still override. Note thatsetup.pyalone would not coverpackaging/build_hip_linux.shortools/hip/build_windows.bat, which configurebuild-vision-hipindependently — so I'd treat the CMakeLists edit as the real fix.tools/test_setup_pins.py:383is the only test that asserts on this command's shape, and it only checkscommands[0][:4], so it stays green either way.Two things that will otherwise bite you on that machine
1. You must delete
build-vision-hip/— otherwise you will re-run the build and see the identical failure. Ninja rebuilds on timestamp, not on command-line changes.cmake_build()re-runscmake(regeneratingbuild.ninjawith the new flags) but the existingllama/ggml/src/ggml-hip/*.ofiles are untouched and newer than nothing, so Ninja jumps straight to relinking and fails again. That's also exactly what your second attempt showed ([1/1] Linking ...). Andsetup.pywill happily reconfigure the stale cache:If you also touched
setup.py, bump the stamp check too —build_vision_hip()(setup.py:3906) andbuild_engine_hip()(3814) skip the compile whenengine/BUILD.jsonstill matches (vision_src/vision_archs). The link failure meansstrata-vision-hipwas never copied intoengine/, so it should re-run; if it saysengine already built for this PC, deleteengine/BUILD.jsontoo.2. Verify the flag actually landed, before waiting out the compile:
Non-zero (and you can confirm the specific rule with
ninja -t commands -C build-vision-hip llama/ggml/src/ggml-hip/CMakeFiles/ggml-hip.dir/__/ggml-cuda/ggml-cuda.cu.o, which should contain-fPIC). CMake does apply PIC to HIP-language sources —Compiler/Clang-HIP.cmake→__compiler_clang(HIP)→__compiler_gnu(HIP), which definesCMAKE_HIP_COMPILE_OPTIONS_PIC = -fPIC— so setting the property is sufficient; you do not need to smuggle-fPICinto-DCMAKE_HIP_FLAGS.If you want a zero-source-edit probe to confirm the diagnosis on that machine before committing anything, configure once by hand and check:
(Repo state here is clean —
git statusempty, no*.bak,setup.pyat4775still has the originalconfline.)@github-actions[bot] commented on GitHub (Oct 20, 2026):
Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:
Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment
/reopen.Details: CONTRIBUTING.md
@github-actions[bot] commented on GitHub (Oct 20, 2026):
Thanks, this follows the format now.
@pjsgsy commented on GitHub (Oct 20, 2026):
Thank you. This fixed the same issues I was having.
@Niko1221 commented on GitHub (Oct 21, 2026):
Thanks, the one line was right. The picture reader for AMD (
strata-vision-hip) is now built position independent (only in the HIP build, nothing changes for the other readers). It's in 0.2.2 now. If you can, please try it and let us know whether pictures work.