git: b01beecef8b6 - 2026Q1 - devel/spirv-llvm-translator: unbreak llvm12 flavor with clang 21

From: Jan Beich <jbeich_at_FreeBSD.org>
Date: Fri, 20 Feb 2026 15:04:33 UTC
The branch 2026Q1 has been updated by jbeich:

URL: https://cgit.FreeBSD.org/ports/commit/?id=b01beecef8b6fb192a6fb9830f9fd8a6435fb83d

commit b01beecef8b6fb192a6fb9830f9fd8a6435fb83d
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2026-02-19 12:31:30 +0000
Commit:     Jan Beich <jbeich@FreeBSD.org>
CommitDate: 2026-02-20 15:04:22 +0000

    devel/spirv-llvm-translator: unbreak llvm12 flavor with clang 21
    
    With clang 21 the llvm12 flavor of devel/spirv-llvm-translator fails to
    build, with errors similar to:
    
        In file included from /wrkdirs/usr/ports/devel/spirv-llvm-translator/work-llvm12/SPIRV-LLVM-Translator-12.0.1/lib/SPIRV/OCLTypeToSPIRV.cpp:44:
        In file included from /wrkdirs/usr/ports/devel/spirv-llvm-translator/work-llvm12/SPIRV-LLVM-Translator-12.0.1/lib/SPIRV/OCLUtil.h:42:
        In file included from /wrkdirs/usr/ports/devel/spirv-llvm-translator/work-llvm12/SPIRV-LLVM-Translator-12.0.1/lib/SPIRV/SPIRVInternal.h:43:
        In file included from /wrkdirs/usr/ports/devel/spirv-llvm-translator/work-llvm12/SPIRV-LLVM-Translator-12.0.1/lib/SPIRV/libSPIRV/SPIRVEnum.h:44:
        In file included from /wrkdirs/usr/ports/devel/spirv-llvm-translator/work-llvm12/SPIRV-LLVM-Translator-12.0.1/lib/SPIRV/libSPIRV/SPIRVOpCode.h:45:
        /wrkdirs/usr/ports/devel/spirv-llvm-translator/work-llvm12/SPIRV-LLVM-Translator-12.0.1/lib/SPIRV/libSPIRV/spirv_internal.hpp:120:31: error: constexpr variable 'FunctionControlOptNoneINTELMask' must be initialized by a constant expression
          120 | constexpr FunctionControlMask FunctionControlOptNoneINTELMask =
              |                               ^
          121 |     static_cast<FunctionControlMask>(IFunctionControlOptNoneINTELMask);
              |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /wrkdirs/usr/ports/devel/spirv-llvm-translator/work-llvm12/SPIRV-LLVM-Translator-12.0.1/lib/SPIRV/libSPIRV/spirv_internal.hpp:121:5: note: integer value 65536 is outside the valid range of values [0, 15] for the enumeration type 'FunctionControlMask'
          121 |     static_cast<FunctionControlMask>(IFunctionControlOptNoneINTELMask);
              |     ^
    
    This is because clang 21 no longer allows enum values outside of the
    valid range. Upstream spirv refactored a lot in this area, so the llvm13
    flavor and later compile fine with clang 21.
    
    Fix it by explicitly making the underlying type for the two affected
    enums uint32_t.
    
    PR:             293293
    MFH:            2026Q1
    (cherry picked from commit d50aa610760e499062d3f050b4402e97531fe376)
---
 .../files.llvm12/patch-clang21                     | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/devel/spirv-llvm-translator/files.llvm12/patch-clang21 b/devel/spirv-llvm-translator/files.llvm12/patch-clang21
new file mode 100644
index 000000000000..8b28d7caeb26
--- /dev/null
+++ b/devel/spirv-llvm-translator/files.llvm12/patch-clang21
@@ -0,0 +1,34 @@
+In file included from lib/SPIRV/OCLTypeToSPIRV.cpp:44:
+In file included from lib/SPIRV/OCLUtil.h:42:
+In file included from lib/SPIRV/SPIRVInternal.h:43:
+In file included from lib/SPIRV/libSPIRV/SPIRVEnum.h:44:
+In file included from lib/SPIRV/libSPIRV/SPIRVOpCode.h:45:
+lib/SPIRV/libSPIRV/spirv_internal.hpp:120:31: error: constexpr variable 'FunctionControlOptNoneINTELMask' must be initialized by a constant expression
+  120 | constexpr FunctionControlMask FunctionControlOptNoneINTELMask =
+      |                               ^
+  121 |     static_cast<FunctionControlMask>(IFunctionControlOptNoneINTELMask);
+      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+lib/SPIRV/libSPIRV/spirv_internal.hpp:121:5: note: integer value 65536 is outside the valid range of values [0, 15] for the enumeration type 'FunctionControlMask'
+  121 |     static_cast<FunctionControlMask>(IFunctionControlOptNoneINTELMask);
+      |     ^
+
+--- lib/SPIRV/libSPIRV/spirv.hpp.orig	2024-03-21 14:16:00 UTC
++++ lib/SPIRV/libSPIRV/spirv.hpp
+@@ -742,7 +742,7 @@ enum FunctionControlShift {
+     FunctionControlMax = 0x7fffffff,
+ };
+ 
+-enum FunctionControlMask {
++enum FunctionControlMask : uint32_t {
+     FunctionControlMaskNone = 0,
+     FunctionControlInlineMask = 0x00000001,
+     FunctionControlDontInlineMask = 0x00000002,
+@@ -805,7 +805,7 @@ enum MemoryAccessShift {
+     MemoryAccessMax = 0x7fffffff,
+ };
+ 
+-enum MemoryAccessMask {
++enum MemoryAccessMask : uint32_t {
+     MemoryAccessMaskNone = 0,
+     MemoryAccessVolatileMask = 0x00000001,
+     MemoryAccessAlignedMask = 0x00000002,