Skip to content

Skip OpenCL 3.1 PCM generation when prebuilt clang lacks CL3.1 support - #814

Merged
wenju-he merged 1 commit into
intel:mainfrom
wenju-he:fix-cl31-oot-build
Jul 22, 2026
Merged

Skip OpenCL 3.1 PCM generation when prebuilt clang lacks CL3.1 support#814
wenju-he merged 1 commit into
intel:mainfrom
wenju-he:fix-cl31-oot-build

Conversation

@wenju-he

Copy link
Copy Markdown
Contributor

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM), which doesn't have the CL3.1 clang patches from patches/clang applied (those only apply when building clang from source in-tree). This made opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in '-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/ packaging the CL3.1 PCM variants when unsupported, gating the runtime resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so GetHeaders() doesn't fail looking for a PCM that was never built.

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@wenju-he
wenju-he enabled auto-merge (squash) July 22, 2026 07:02
@wenju-he
wenju-he requested a review from cdai2 July 22, 2026 07:02
@wenju-he
wenju-he merged commit 9363ff5 into intel:main Jul 22, 2026
4 checks passed
@wenju-he
wenju-he deleted the fix-cl31-oot-build branch July 22, 2026 12:11
wenju-he added a commit to wenju-he/opencl-clang that referenced this pull request Jul 22, 2026
…ks CL3.1 support (intel#814)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit to wenju-he/opencl-clang that referenced this pull request Jul 23, 2026
…ks CL3.1 support (intel#814)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit that referenced this pull request Jul 23, 2026
…ks CL3.1 support (#814) (#820)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit that referenced this pull request Jul 23, 2026
…ks CL3.1 support (#814) (#819)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit that referenced this pull request Jul 23, 2026
…ks CL3.1 support (#814) (#818)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit that referenced this pull request Jul 24, 2026
…ks CL3.1 support (#814) (#823)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit that referenced this pull request Jul 24, 2026
…ks CL3.1 support (#814) (#826)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit that referenced this pull request Jul 24, 2026
…ks CL3.1 support (#814) (#825)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit that referenced this pull request Jul 24, 2026
…ks CL3.1 support (#814) (#824)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
wenju-he added a commit that referenced this pull request Jul 24, 2026
…ks CL3.1 support (#814) (#822)

The out-of-tree build uses a prebuilt/system clang (USE_PREBUILT_LLVM),
which doesn't have the CL3.1 clang patches from patches/clang applied
(those only apply when building clang from source in-tree). This made
opencl-c-31-spir.pcm generation fail with "invalid value 'CL3.1' in
'-cl-std=CL3.1'".

Probe the resolved clang for -cl-std=CL3.1 support and skip generating/
packaging the CL3.1 PCM variants when unsupported, gating the runtime
resource list in opencl_clang.cpp with OPENCL_CLANG_NO_CL31_PCM so
GetHeaders() doesn't fail looking for a PCM that was never built.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
(cherry picked from commit 9363ff5)

This fixes out-of-tree build.
Comment thread cl_headers/CMakeLists.txt
@@ -80,20 +80,32 @@ set(OPTS -cl-ext=+all,-cl_khr_fp64,-__opencl_c_fp64)
create_pcm(opencl-c-12-spir.pcm cl12spir opencl-c-base.h "${SPIR_TRIPLE};${CL12};${OPTS}" "${DEPS}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was a condition in line 65 missed? I am having currently some trouble with CL3.1 in NixOS.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line 65 is set(CL31 "-cl-std=CL3.1") and CL31 isn't used if CLANG_SUPPORTS_CL31 is false.
Could you paste the error? Is CLANG_SUPPORTS_CL31 true or false?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#880 will fix out-of-tree build in opencl-clang main branch

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah, that just sets the var 🤦🏼

I figured the issue out in NixOS. Since we have no full git tree, the patching would not work as the exit code of git for rev-prase would be 128. That is handled in newer versions of opencl-clang and logged, but for the time being I just turned one condition to always true. We only consume opencl-clang throuch intel-graphics-compierl.

That's the PR if you are interested NixOS/nixpkgs#555838

And igc still uses the 170 branch, so we are stuck to that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it right that NixOS extract llvm-project release from a tarball file and there is not .git folder in llvm-project folder?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please check if #881 works for you? After the PR, opencl-clang can apply patch without requiring .git folder being existing.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it right that NixOS extract llvm-project release from a tarball file and there is not .git folder in llvm-project folder?

Yep. I tried fetching the git tree, but I could not get a stable hash of that download, so it failed CI, obviously.

I try to look at the patch in the next days.

@wenju-he wenju-he Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I try to look at the patch in the next days.

great. My local testing shows opencl-clang applied its clang/llvm patch successfully in llvm-project-17.0.6.src folder (no .git subfolder) extracted from llvm-project-17.0.6.src.tar.xz

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.

3 participants