diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp index dda4a63ac45..c95ed657038 100644 --- a/src/compiler/clc/clc_helpers.cpp +++ b/src/compiler/clc/clc_helpers.cpp @@ -1228,10 +1228,17 @@ clc_link_spirv_binaries(const struct clc_linker_args *args, context.SetMessageConsumer(msgconsumer); spvtools::LinkerOptions options; options.SetAllowPartialLinkage(args->create_library); + #if defined(HAS_SPIRV_LINK_LLVM_WORKAROUND) && LLVM_VERSION_MAJOR >= 17 + options.SetAllowPtrTypeMismatch(true); + #endif options.SetCreateLibrary(args->create_library); std::vector linkingResult; spv_result_t status = spvtools::Link(context, binaries, &linkingResult, options); if (status != SPV_SUCCESS) { + #if !defined(HAS_SPIRV_LINK_LLVM_WORKAROUND) && LLVM_VERSION_MAJOR >= 17 + clc_warning(logger, "SPIRV-Tools doesn't contain https://github.com/KhronosGroup/SPIRV-Tools/pull/5534\n"); + clc_warning(logger, "Please update in order to prevent spurious linking failures\n"); + #endif return -1; } diff --git a/src/compiler/clc/meson.build b/src/compiler/clc/meson.build index 10248ebf5c0..bd558d25566 100644 --- a/src/compiler/clc/meson.build +++ b/src/compiler/clc/meson.build @@ -82,6 +82,19 @@ else endif endif +has_spirv_link_workaround = cpp.has_member( + 'spvtools::LinkerOptions', + 'SetAllowPtrTypeMismatch(true)', + prefix : [ + '#include ', + ], + dependencies : dep_spirv_tools, +) + +if has_spirv_link_workaround + _libmesaclc_c_args += ['-DHAS_SPIRV_LINK_LLVM_WORKAROUND=1'] +endif + _libmesaclc = static_library( 'libmesaclc', files_libmesaclc,