package/llvm-project/libclc: fix build with llvm 23
PATCH v2 1/3 package/llvm-project/libclc: fix build with llvm 23
Buildroot commit 5f79161e4a8756acdb25c8500de9b2dee663f2ac bumped the llvm packages from 22.1.8 to 23.1.0 causing configure errors with the libclc package:
-- Check for working CLC compiler: /usr/bin/gcc
CMake Error at cmake/modules/CMakeTestCLCCompiler.cmake:29 (message):
The CLC compiler
/usr/bin/gcc
is not able to compile a simple OpenCL test program.
Output:
gcc: error: unrecognized command-line option
'--target=spirv64-unknown-unknown'
Update various configure options to switch to clang.
Fixes was inspired by Arch Linux:
https://gitlab.archlinux.org/archlinux/packaging/packages/libclc/-/commit/ca75c4b19c76ae856a368d070d914b12f71203a5#line_9b9baac1e_A56
'spirv64-unknown-unknown' is needed both for the host and target build, see LibreELEC commit for a similar fix:
https://github.com/LibreELEC/LibreELEC.tv/commit/04c2de1c89b4946e822d1a977b918802ce4222e8
Fixes:
https://autobuild.buildroot.net/results/3fc/3fcdcb71be590b090df2f765c68aeaecc44dd215/
---
v2: updated patch description (Thomas)
removed post install hooks, instead a fix for mesa was added to this series
package/llvm-project/libclc/libclc.mk | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
package/llvm-project/libclc/libclc.mk +8 -3
@@ -36,13 +36,18 @@ LIBCLC_CONF_OPTS = \ -DCMAKE_EXE_LINKER_FLAGS="$(HOST_LDFLAGS)" \ -DCMAKE_SHARED_LINKER_FLAGS="$(HOST_LDFLAGS)" \ -DCMAKE_MODULE_LINKER_FLAGS="$(HOST_LDFLAGS)" \ - -DCMAKE_C_COMPILER="$(CMAKE_HOST_C_COMPILER)" \ - -DCMAKE_CXX_COMPILER="$(CMAKE_HOST_CXX_COMPILER)" \ + -DCMAKE_C_COMPILER="$(HOST_DIR)/bin/clang" \ + -DCMAKE_CXX_COMPILER="$(HOST_DIR)/bin/clang" \ -DLLVM_CMAKE_DIR="$(HOST_DIR)/lib/cmake/llvm" \ + -DLIBCLC_TARGET=spirv64-unknown-unknown \ -DLIBCLC_CUSTOM_LLVM_TOOLS_BINARY_DIR="$(HOST_DIR)/bin" HOST_LIBCLC_CONF_OPTS = \ - -DLIBCLC_TARGETS_TO_BUILD=spirv64-mesa3d- + -DCMAKE_C_COMPILER_FORCED=ON \ + -DCMAKE_CXX_COMPILER_FORCED=ON \ + -DCMAKE_C_COMPILER="$(HOST_DIR)/bin/clang" \ + -DCMAKE_CXX_COMPILER="$(HOST_DIR)/bin/clang" \ + -DLIBCLC_TARGET=spirv64-unknown-unknown $(eval $(cmake-package)) $(eval $(host-cmake-package))
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 2/3 package/llvm-project/libclc: apply mesa-libclc patch set
https://gitlab.freedesktop.org/karolherbst/mesa-libclc/-/commits/llvm_23
https://gitlab.freedesktop.org/karolherbst/mesa-libclc/-/blob/llvm_23/README.md
"This is a fork of LLVM's libclc applying some fixes of a known good
state. [...]
Alternatively to using this fork distributions can patch their own libclc project with the commits titled with "libclc: ..."
Needed for mesa3d >= 26.2.0:
https://lists.freedesktop.org/archives/mesa-announce/2026-August/000863.html
"One important note for packagers is that there is now a Mesa community maintained libclc fork that is verified to pass the OpenCL CTS with Mesa/Rusticl, and will fix bugs after an upstream libclc major release branch goes EoL. The Mesa build system will pick it up when available, and fall back to upstream libclc if not. This libclc fork is not verified for any other usages or users of libclc outside of Mesa."
This patch adds the mesa-libclc to our libclc package instead of adding a new mesa-libclc package.
Please note that these patches also fix the build of mesa3d 26.1.8, the problem is currently hidden by the configure error in libclc fixed by the previous patch of this series.
Quoting configure log:
Run-time dependency mesa-libclc found: NO (tried pkg-config and cmake)
Message: mesa-libclc not found. Build will fall back to upstream libclc,
however this is not recommended for most use cases.
Run-time dependency libclc found: NO (tried pkg-config and cmake)
output/build/mesa3d-26.1.8/meson.build:958:14: ERROR: Dependency "libclc"
not found (tried pkg-config and cmake)
---
v2: no changes
...disable-use-of-SPV_KHR_fma-extension.patch | 36 ++ ...0002-libclc-restore-old-fma-behavior.patch | 65 ++ ...libclc-add-__clc_mesa_libclc_version.patch | 49 ++ ...le-fp16-version-of-atan2-and-atan2pi.patch | 56 ++ ...c-Revert-libclc-Update-remquo-187998.patch | 595 ++++++++++++++++++ ...bclc-Update-hypot-implementation-185.patch | 171 +++++ ...vert-libclc-Update-trigpi-functions-.patch | 173 +++++ ...a-precision-issues-due-to-lack-of-fm.patch | 80 +++ .../libclc/0009-revert-10644a1-v3.patch | 37 ++ 9 files changed, 1262 insertions(+) create mode 100644 package/llvm-project/libclc/0001-libclc-disable-use-of-SPV_KHR_fma-extension.patch create mode 100644 package/llvm-project/libclc/0002-libclc-restore-old-fma-behavior.patch create mode 100644 package/llvm-project/libclc/0003-libclc-add-__clc_mesa_libclc_version.patch create mode 100644 package/llvm-project/libclc/0004-libclc-disable-fp16-version-of-atan2-and-atan2pi.patch create mode 100644 package/llvm-project/libclc/0005-libclc-Revert-libclc-Update-remquo-187998.patch create mode 100644 package/llvm-project/libclc/0006-libclc-Revert-libclc-Update-hypot-implementation-185.patch create mode 100644 package/llvm-project/libclc/0007-libclc-Partly-revert-libclc-Update-trigpi-functions-.patch create mode 100644 package/llvm-project/libclc/0008-libclc-fix-tgamma-precision-issues-due-to-lack-of-fm.patch create mode 100644 package/llvm-project/libclc/0009-revert-10644a1-v3.patch
package/llvm-project/libclc/0001-libclc-disable-use-of-SPV_KHR_fma-extension.patch new file +36 -0
@@ -0,0 +1,36 @@ +From 0fdefef847d704b0162cacdbafe01350f4531a61 Mon Sep 17 00:00:00 2001 +From: Karol Herbst <[email protected]> +Date: Wed, 22 Jul 2026 13:36:59 +0200 +Subject: [PATCH] libclc: disable use of SPV_KHR_fma extension + +Upstream: https://gitlab.freedesktop.org/karolherbst/mesa-libclc/-/commit/0fdefef847d704b0162cacdbafe01350f4531a61 + +Signed-off-by: Bernd Kuhls <[email protected]> +--- + libclc/cmake/modules/AddLibclc.cmake | 3 +-- + 1 file changed, 1 insertion(+), 2 deletions(-) + +diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake +index d84101f..82aa563 100644 +--- a/libclc/cmake/modules/AddLibclc.cmake ++++ b/libclc/cmake/modules/AddLibclc.cmake +@@ -165,7 +165,7 @@ function(libclc_add_library target_name) + if(LIBCLC_USE_SPIRV_BACKEND) + add_custom_command(OUTPUT ${builtins_lib} + COMMAND ${CMAKE_CLC_COMPILER} -c --target=${ARG_TRIPLE} +- -mllvm --spirv-ext=+SPV_KHR_fma ++ -mllvm + -x ir -o ${builtins_lib} ${linked_bc} + DEPENDS ${linked_bc} + ) +@@ -173,7 +173,6 @@ function(libclc_add_library target_name) + add_custom_command(OUTPUT ${builtins_lib} + COMMAND ${llvm-spirv_exe} + --spirv-max-version=1.1 +- --spirv-ext=+SPV_KHR_fma + -o ${builtins_lib} ${linked_bc} + DEPENDS ${linked_bc} + ) +-- +2.47.3 +
package/llvm-project/libclc/0002-libclc-restore-old-fma-behavior.patch new file +65 -0
65 lines not on this page · raw message
package/llvm-project/libclc/0003-libclc-add-__clc_mesa_libclc_version.patch new file +49 -0
49 lines not on this page · raw message
package/llvm-project/libclc/0004-libclc-disable-fp16-version-of-atan2-and-atan2pi.patch new file +56 -0
56 lines not on this page · raw message
package/llvm-project/libclc/0005-libclc-Revert-libclc-Update-remquo-187998.patch new file +595 -0
595 lines not on this page · raw message
package/llvm-project/libclc/0006-libclc-Revert-libclc-Update-hypot-implementation-185.patch new file +171 -0
171 lines not on this page · raw message
package/llvm-project/libclc/0007-libclc-Partly-revert-libclc-Update-trigpi-functions-.patch new file +173 -0
173 lines not on this page · raw message
package/llvm-project/libclc/0008-libclc-fix-tgamma-precision-issues-due-to-lack-of-fm.patch new file +80 -0
80 lines not on this page · raw message
package/llvm-project/libclc/0009-revert-10644a1-v3.patch new file +37 -0
@@ -0,0 +1,37 @@ +Restore libclc.pc + +Revert the upstream removal of libclc.pc +https://github.com/llvm/llvm-project/pull/185654 + +which is needed by mesa3d to detect libclc. + +Upstream: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40601#note_3639151 + +Downloaded from +https://aur.archlinux.org/cgit/aur.git/tree/revert-10644a1-v3.patch?h=libclc-minimal-git + +Signed-off-by: Bernd Kuhls <[email protected]> + +diff -uraN llvm-project/libclc/CMakeLists.txt llvm-project.new/libclc/CMakeLists.txt +--- llvm-project/libclc/CMakeLists.txt 2026-06-05 23:42:11.119610382 +0200 ++++ llvm-project.new/libclc/CMakeLists.txt 2026-06-05 23:43:45.639449958 +0200 +@@ -123,6 +123,9 @@ + endif() + endforeach() + ++configure_file( libclc.pc.in libclc.pc @ONLY ) ++install( FILES ${CMAKE_CURRENT_BINARY_DIR}/libclc.pc DESTINATION "${CMAKE_INSTALL_DATADIR}/pkgconfig" ) ++ + # Determine the clang target triple. + set(clang_triple ${LIBCLC_TARGET}) + +diff -uraN llvm-project/libclc/libclc.pc.in llvm-project.new/libclc/libclc.pc.in +--- llvm-project/libclc/libclc.pc.in 1970-01-01 01:00:00.000000000 +0100 ++++ llvm-project.new/libclc/libclc.pc.in 2026-06-05 23:21:12.849811269 +0200 +@@ -0,0 +1,6 @@ ++libexecdir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_DATADIR@/clc ++ ++Name: libclc ++Description: Library requirements of the OpenCL C programming language ++Version: @PROJECT_VERSION@ ++Libs: -L${libexecdir}
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 3/3 package/mesa3d: fix rusticl runtime error with llvm-23
In reply to Bernd Kuhlsmesa3d searches a wrong path for libclc files caused by the bump of llvm to 23.1.0 with buildroot commit 5f79161e4a8756acdb25c8500de9b2dee663f2ac
This patch adds three upstream commits backported from the 26.3 branch, for details see upstream PR:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/44624
Fixes tests.package.test_mesa3d.TestMesa3DRusticl.test_run:
Libclc failed to load. Please make sure it is installed and provides
spirv-mesa3d-.spv and/or spirv64-mesa3d-.spv
---
Gitlab pipelines passed:
check-*:
https://gitlab.com/bkuhls/buildroot/-/pipelines/2974000376
tests.package.test_mesa3d:
https://gitlab.com/bkuhls/buildroot/-/pipelines/2974000282
...do-not-compare-sys_path-against-NULL.patch | 133 ++++++++++++++++++ ...d_libclc-turn-sys_path-into-an-array.patch | 113 +++++++++++++++ ...load_libclc-add-llvm-23-libclc-paths.patch | 46 ++++++ 3 files changed, 292 insertions(+) create mode 100644 package/mesa3d/0006-nir-load_libclc-do-not-compare-sys_path-against-NULL.patch create mode 100644 package/mesa3d/0007-nir-load_libclc-turn-sys_path-into-an-array.patch create mode 100644 package/mesa3d/0008-nir-load_libclc-add-llvm-23-libclc-paths.patch
package/mesa3d/0006-nir-load_libclc-do-not-compare-sys_path-against-NULL.patch new file +133 -0
@@ -0,0 +1,133 @@ +From f5011f50a7e9c3f8dc208e16a4bd3aadbd6fdae8 Mon Sep 17 00:00:00 2001 +From: Karol Herbst <[email protected]> +Date: Tue, 22 Sep 2026 13:53:43 +0200 +Subject: [PATCH] nir/load_libclc: do not compare sys_path against NULL + +sys_path will become an array and the NULL checks were all a bit awkward +because all the code was already guarded with DYNAMIC_LIBCLC_PATH anyway +and most likely constant folded away. + +Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/44624> + +Upstream: https://gitlab.freedesktop.org/mesa/mesa/-/commit/1219dc3f7fe83b1f7f200190bf02a86ab57b3d4f + +[Bernd: backported to 26.1.8] +Signed-off-by: Bernd Kuhls <[email protected]> +--- + src/compiler/clc/nir_load_libclc.c | 84 ++++++++++++++---------------- + 1 file changed, 39 insertions(+), 45 deletions(-) + +diff --git a/src/compiler/clc/nir_load_libclc.c b/src/compiler/clc/nir_load_libclc.c +index 4cb92bdb257..46beaf51cdf 100644 +--- a/src/compiler/clc/nir_load_libclc.c ++++ b/src/compiler/clc/nir_load_libclc.c +@@ -145,20 +145,18 @@ map_clc_data(struct clc_data *clc) + } + + #ifdef DYNAMIC_LIBCLC_PATH +- if (clc->file->sys_path != NULL) { +- if (clc->size % SPIRV_WORD_SIZE != 0) { +- fprintf(stderr, "File length isn't a multiple of the word size\n"); +- return false; +- } +- +- clc->data = mmap(NULL, clc->size, PROT_READ, MAP_PRIVATE, clc->fd, 0); +- if (clc->data == MAP_FAILED) { +- fprintf(stderr, "Failed to mmap libclc SPIR-V: %m\n"); +- return false; +- } ++ if (clc->size % SPIRV_WORD_SIZE != 0) { ++ fprintf(stderr, "File length isn't a multiple of the word size\n"); ++ return false; ++ } + +- return true; ++ clc->data = mmap(NULL, clc->size, PROT_READ, MAP_PRIVATE, clc->fd, 0); ++ if (clc->data == MAP_FAILED) { ++ fprintf(stderr, "Failed to mmap libclc SPIR-V: %m\n"); ++ return false; + } ++ ++ return true; + #endif + + return true; +@@ -175,12 +173,10 @@ close_clc_data(struct clc_data *clc) + } + + #ifdef DYNAMIC_LIBCLC_PATH +- if (clc->file->sys_path != NULL) { +- if (clc->data) +- munmap((void *)clc->data, clc->size); +- clc->data = NULL; +- close(clc->fd); +- } ++ if (clc->data) ++ munmap((void *)clc->data, clc->size); ++ clc->data = NULL; ++ close(clc->fd); + #endif + } + +@@ -198,33 +194,31 @@ open_clc_data(struct clc_data *clc, unsigned ptr_bit_size) + } + + #ifdef DYNAMIC_LIBCLC_PATH +- if (clc->file->sys_path != NULL) { +- int fd = open(clc->file->sys_path, O_RDONLY); +- if (fd < 0) +- return false; +- +- struct stat stat; +- int ret = fstat(fd, &stat); +- if (ret < 0) { +- fprintf(stderr, "fstat failed on %s: %m\n", clc->file->sys_path); +- close(fd); +- return false; +- } +- +- clc->fd = fd; +- clc->size = stat.st_size; +- +- if (!map_clc_data(clc)) { +- return false; +- } +- +- blake3_hasher ctx; +- _mesa_blake3_init(&ctx); +- _mesa_blake3_update(&ctx, clc->data, clc->size); +- _mesa_blake3_final(&ctx, clc->cache_key); +- +- return true; +- } ++ int fd = open(clc->file->sys_path, O_RDONLY); ++ if (fd < 0) ++ return false; ++ ++ struct stat stat; ++ int ret = fstat(fd, &stat); ++ if (ret < 0) { ++ fprintf(stderr, "fstat failed on %s: %m\n", clc->file->sys_path); ++ close(fd); ++ return false; ++ } ++ ++ clc->fd = fd; ++ clc->size = stat.st_size; ++ ++ if (!map_clc_data(clc)) { ++ return false; ++ } ++ ++ blake3_hasher ctx; ++ _mesa_blake3_init(&ctx); ++ _mesa_blake3_update(&ctx, clc->data, clc->size); ++ _mesa_blake3_final(&ctx, clc->cache_key); ++ ++ return true; + #endif + + return false; +-- +2.47.3 +
package/mesa3d/0007-nir-load_libclc-turn-sys_path-into-an-array.patch new file +113 -0
113 lines not on this page · raw message
package/mesa3d/0008-nir-load_libclc-add-llvm-23-libclc-paths.patch new file +46 -0
46 lines not on this page · raw message
Signature · 6 lines
2.47.3 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 22 lines · Bernd Kuhls
Buildroot commit
5f79161e4a8756acdb25c8500de9b2dee663f2acbumped the llvm packages from 22.1.8 to 23.1.0 causing configure errors with the libclc package:-- Check for working CLC compiler:
/usr/bin/gcc
CMake Error at cmake/modules/CMakeTestCLCCompiler.cmake:29 (message):
The CLC compiler
/usr/bin/gccis not able to compile a simple OpenCL test program.
Output:
gcc: error: unrecognized command-line option
'--target=spirv64-unknown-unknown'Update various configure options to switch to clang.
Fixes was inspired by Arch Linux:
https://gitlab.archlinux.org/archlinux/packaging/packages/libclc/-/commit/ca75c4b19c76ae856a368d070d914b12f71203a5#line_9b9baac1e_A56
Quoted 8 lines
'spirv64-unknown-unknown' is needed both for the host and target build, see LibreELEC commit for a similar fix:
https://github.com/LibreELEC/LibreELEC.tv/commit/04c2de1c89b4946e822d1a977b918802ce4222e8Fixes:
https://autobuild.buildroot.net/results/3fc/3fcdcb71be590b090df2f765c68aeaecc44dd215/Signed-off-by Bernd Kuhls <[email protected]>
Series applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot