Skip to content

LLVM 23 support#1194

Draft
pvelesko wants to merge 9 commits into
mainfrom
llvm-23
Draft

LLVM 23 support#1194
pvelesko wants to merge 9 commits into
mainfrom
llvm-23

Conversation

@pvelesko

@pvelesko pvelesko commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

pvelesko added 7 commits June 7, 2026 15:02
CHIPUninitializeCallOnce accessed PerThreadDefaultQueue (a thread_local
unique_ptr) from an atexit handler. TLS destruction order relative to
atexit is implementation-defined; with clang 23 the unique_ptr is
already destroyed, causing a SEGFAULT on the dangling pointer. Remove
the per-thread queue sync since TLS destruction handles cleanup.
The chipstar OS component in spirv64v1.X-unknown-chipstar triples was
added in LLVM 23, so gate HAVE_CLANG_NEW_OFFLOAD_DRIVER on LLVM 23+
instead of 22+. Use conditional RTDEVLIB_TRIPLE variables instead of
hardcoded chipstar triples in rtdevlib compilation so LLVM 22 falls
back to the plain spirv64 triple.
configure_llvm.sh: support version 23 by cloning from CHIP-SPV/llvm-project
and CHIP-SPV/SPIRV-LLVM-Translator (chipStar-llvm-23 branches) with patches
pre-applied, skipping the patch application step.

New test-llvm23.yml workflow runs on PR and workflow_dispatch with both
translator and native variants on Linux (5 test combos) and macOS (PoCL).
Commit 0947b0e fixed two occurrences but missed line 136. LLVM 23
removed Constant::isZeroValue(); use isNullValue() which is equivalent.
The constant_fold_lgamma_r test targets amdgcn-amd-amdhsa and requires
ROCm device libraries. It is not applicable to SPIR-V builds and always
fails with "cannot find ROCm device library". Exclude it via
CTestCustom.cmake.
processOptions() appends per-compilation diagnostics (e.g. the
"warning: ignored option" messages for unrecognized flags) to the
program log, but it ran inside compile(), which is skipped on an HIPRTC
output-cache hit. As a result the program log depended on cache state:
the first compilation of a program warned about an ignored option, but a
subsequent identical compilation served from cache produced an empty
log. TestHiprtcOptions failed on a warm cache for exactly this reason.

Hoist option processing into hiprtcCompileProgram ahead of the cache
lookup so the diagnostics are recorded on every path, and pass the
already-processed options into compile().
The promoteInt validity check converted the post-link bitcode to SPIR-V
with llvm-spirv, which isn't built when LLVM uses the in-tree SPIR-V
backend (native build). Fall back to 'clang --target=spirv64*-unknown-
chipstar -x ir' when llvm-spirv is unavailable, and pass CLANG into the
test environment from CMake.
pvelesko added 2 commits June 7, 2026 19:52
LLVM 23 (current main) removed the LLVM_ENABLE_PROJECTS=openmp build
mode, so configuring the fork with "clang;openmp;clang-tools-extra"
fails with 'Support for the LLVM_ENABLE_PROJECTS=openmp build mode has
been removed'. chipStar does not use OpenMP (no libomp/-fopenmp/OpenMP::
references anywhere), so drop it from the build entirely rather than
migrating it to LLVM_ENABLE_RUNTIMES.
The LLVM 23 CI built the separate 'chipStar-llvm-23' fork branch, which
had drifted from the LLVM PR (#186972) head 'chipstar-native-spirv' and
was missing the rebase onto current main plus the in-tree-backend /
llvm-spirv-fallback / RDC fixes. That caused the native (hipDeviceLink
RDC: undefined __hip_fatbin) and translator (hipspv-link: -spirv-ext on
a host-only LLVM) build failures.

Point the LLVM 23 build at 'chipstar-native-spirv' so CI builds the same
LLVM as the PR. Validated locally via configure_llvm.sh for both
variants (assertions ON): native L0 1174/1174 + OCL 1175/1175 with
hipTestDeviceLink passing, translator 1175/1175.
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