fix(rocDecode): Runtime environment variable cleanup#8869
fix(rocDecode): Runtime environment variable cleanup#8869jeffqjiangNew wants to merge 7 commits into
Conversation
On TheRock installs, running a sample directly failed with "radeonsi_drv_video.so has no function __vaDriverInit_1_0". librocdecode.so links the vendored libva (librocm_sysdeps_va.so.2, VA 1.22), but the samples link system FFmpeg which drags in system libva (VA 1.14). Because the FFmpeg libs preceded librocdecode.so in DT_NEEDED order, system libva won the unversioned vaInitialize and dlopened TheRock's driver with the wrong init symbol. CTest masked this by injecting LD_PRELOAD of the vendored libva. Fix: in each sample CMakeLists.txt, on TheRock installs, link the vendored libva as a forced early direct dependency (-Wl,--no-as-needed) so it wins symbol resolution. It then self-locates its VA driver via its compiled-in default path, so neither LD_PRELOAD nor LIBVA_DRIVERS_PATH is needed. - samples/*/CMakeLists.txt: force vendored libva first in link order - test/CMakeLists.txt: drop now-redundant VA LD_PRELOAD/LIBVA_DRIVERS_PATH injection (ASAN preload retained) - docs: remove LD_PRELOAD/LIBVA_DRIVERS_PATH run instructions (ROCM_PATH kept) Verified: default (6/6) and extended FFmpeg-demuxer (4/4) CTest suites pass in a clean environment with no LD_PRELOAD or LIBVA_DRIVERS_PATH set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
❌ PR Check — Action Required
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🚫 Please fix the failed policies before requesting reviews. The following policy checks failed:
The |
There was a problem hiding this comment.
Pull request overview
This PR aims to eliminate the runtime libva loader conflict seen on TheRock-installed stacks by removing the LD_PRELOAD/LIBVA_DRIVERS_PATH workaround and instead forcing sample executables to link the TheRock-provided libva early so it wins global symbol resolution.
Changes:
- Removed TheRock-specific environment-variable injection for CTest runs in
projects/rocdecode/test. - Updated multiple sample
CMakeLists.txtfiles to prepend libva libraries (viafind_package(Libva)) before other link dependencies. - Updated rocDecode documentation and changelog to remove the LD_PRELOAD/LIBVA_DRIVERS_PATH instructions and note the new behavior.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| projects/rocdecode/test/CMakeLists.txt | Removes TheRock LD_PRELOAD/LIBVA_DRIVERS_PATH environment workaround for tests. |
| projects/rocdecode/samples/videoToSequence/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/videoDecodeRGB/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/videoDecodeRaw/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/videoDecodePicFiles/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/videoDecodePerf/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/videoDecodeMultiFiles/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/videoDecodeMem/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/videoDecodeBatch/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/videoDecode/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/samples/rocdecDecode/CMakeLists.txt | Attempts to force early libva linkage for TheRock builds. |
| projects/rocdecode/docs/tutorials/rocDecode-samples.rst | Removes environment-variable workaround instructions from sample-running docs. |
| projects/rocdecode/docs/how-to/using-rocDecode-videodecode-sample.rst | Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only. |
| projects/rocdecode/docs/how-to/using-rocDecode-video-decoder.rst | Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only. |
| projects/rocdecode/docs/how-to/using-rocDecode-rocdecdecoder.rst | Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only. |
| projects/rocdecode/docs/how-to/using-rocDecode-ffmpeg.rst | Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only. |
| projects/rocdecode/docs/how-to/using-rocDecode-bitstream.rst | Removes LD_PRELOAD/LIBVA_DRIVERS_PATH instructions; keeps ROCM_PATH only. |
| projects/rocdecode/CHANGELOG.md | Adds a changelog entry about resolving the vendored libva link issue. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
AryanSalmanpour
left a comment
There was a problem hiding this comment.
@jeffqjiangNew 9 rocdecode CTESTs are failing with the current PR.
https://github.com/ROCm/rocm-systems/actions/runs/29769363209/job/88449819570?pr=8869
The following tests FAILED:
7 - video_decode-HEVC (Failed)
8 - video_decode-AVC (Failed)
9 - video_decode-AV1 (Failed)
10 - video_decode-VP9 (Failed)
11 - video_decodePerf-HEVC (Failed)
12 - video_decodeBatch (Failed)
13 - video_decodeRGB-HEVC (Failed)
14 - video_decodeMem-HEVC (Failed)
15 - video_decodeRGB-Resize (Failed)
…e CTest failures in CI.
… as the first DT_NEEDED instead of linking libva; the app no longer links libva at all.
Motivation
This PR resolves the libva load issue with the sample apps and removes the environment variable workaround.
Technical Details
Running a sample app linked to FFmpeg libs on an installed TheRock stack can result in a runtime libva error.
rocDeocde core library links to the vendor libva which comes with the TheRock stack. FFmpeg links to the system libva. These two libva copies can have different versions and difference function symbols. Since the sample app links to FFmpeg libs before rocDecode lib, the system libva enters the global scope first and gets loaded. It then tries to open a VA driver version which is not in the TheRock stack.
Currently we set both LD_PRELOAD and LIBVA_DRIVERS_PATH env vars to force loading the vendor libva copy.
In each sample's CMakeLists.txt, immediately before
target_link_libraries(${PROJECT_NAME} ${LINK_LIBRARY_LIST}), prepend the vendor libva as a forced early direct dependency.Issue Tracking
AICV-192
Test Plan
Remove both LD_PRELOAD and LIBVA_DRIVERS_PATH env vars and run a FFmpeg linked sample app.
Test Result
The sample app runs fine.
Submission Checklist