Skip to content

cmake: order HIP device compiles after the pass plugin link - #1526

Open
pvelesko wants to merge 2 commits into
mainfrom
2026-08-29-github-1488-pass-plugin-build-order
Open

cmake: order HIP device compiles after the pass plugin link#1526
pvelesko wants to merge 2 commits into
mainfrom
2026-08-29-github-1488-pass-plugin-build-order

Conversation

@pvelesko

Copy link
Copy Markdown
Collaborator

Under the Ninja generator a dependency on a library target only orders a consumer's object compiles after that library's objects, not after its link, so add_dependencies(CHIP LLVMHipPasses) let test TUs compile while lib/libLLVMHipSpvPasses.so was being relinked and their device link failed with file too short or invalid ELF header. The in-tree toolchain (LLVMHipPasses, devicelib_bc, hipcc.bin) now goes through a utility target, hip_device_toolchain, which Ninja waits on completely; CHIP and the catch object libraries (KERNELS, Main_Object) depend on it, so every target that compiles HIP code against the build tree is ordered after the plugin link. TestFix1488PassPluginBuildOrder walks the Ninja graph for one object per registration path (runtime glob, add_hip_test, catch) and fails on main.

Fixes #1488

TestFix1488PassPluginBuildOrder walks the Ninja build graph and asserts
that objects compiled from HIP sources are ordered after
lib/libLLVMHipSpvPasses.so, the pass plugin clang loads through
--hip-path. It probes one object per registration path: the Test* glob
in tests/runtime, add_hip_test(), and the catch suite.

Today all three fail: add_dependencies(CHIP LLVMHipPasses) only orders a
consumer's object compiles after the plugin's objects, not after its
link, and the catch tree has no dependency on the plugin at all.
Route the in-tree toolchain (LLVMHipPasses, devicelib_bc, hipcc.bin)
through a utility target, hip_device_toolchain, and make CHIP and the
catch object libraries depend on it.

Under the Ninja generator a dependency on a library target only orders a
consumer's object compiles after that library's objects, not after its
link, so add_dependencies(CHIP LLVMHipPasses) let test TUs compile while
lib/libLLVMHipSpvPasses.so was being relinked and their device link
failed with "file too short" or "invalid ELF header". A utility target
is waited on completely, and every target that compiles HIP code against
the build tree reaches it through CHIP, or through KERNELS/Main_Object
in the catch tree, which sets hipcc.bin as its compiler and never links
CHIP.

Fixes #1488
@pvelesko

Copy link
Copy Markdown
Collaborator Author

/run-aurora-ci

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.

Tests compiled by in-tree hipcc race the libLLVMHipSpvPasses.so relink on incremental builds

1 participant