f26371ae30
libclc was vendored at recipes/dev/llvm21/source/libclc/ as a
build artifact of the llvm21 fork. This promoted it from an
implicit Mesa dependency (the CLC bitcode Mesa consumes) to a
first-class local project, mirroring how tlc, redbear-*, cub, etc.
are organized per local/AGENTS.md.
Local layout follows the existing in-house pattern:
recipes/dev/libclc -> ../../local/recipes/dev/libclc
local/recipes/dev/libclc/recipe.toml
local/recipes/dev/libclc/source/ (vendored from llvm-project)
The recipe builds libclc as a host-side CMake project using the
cookbook-sysroot clang21 binary (not the cross-compiler) to compile
OpenCL kernels to .bc bitcode. Output targets are amdgcn, amdgcn-amdhsa,
r600, generic, and spirv — the union that Mesa's clc tool consumes
for the iris/radeonsi/llvmpipe drivers. ptx-nvidiacl and clspv are
excluded because they don't map onto any Mesa hardware driver.
The recipe also wires the cookbook's native-cmake generation with
an override that points CMAKE_C_COMPILER etc. at the cookbook
sysroot's clang-21 binary. This is needed because libclc must
run on the build host (output is bitcode, not a Redox binary),
and the cookbook's default cross-toolchain would link the build
against relibc instead of host glibc.
libclc.pc is installed at usr/lib/pkgconfig/, satisfying Mesa's
dependency('libclc') lookup. The .bc files are installed under
usr/share/clc/, which is what the libclc.pc libexecdir pointer
(libexecdir=<prefix>/share/clc) expects.
This is the prerequisite for re-enabling iris, radeonsi, and the
Intel Vulkan driver in the Mesa recipe (Phase 4-6 of
local/docs/3D-DRIVER-PLAN.md). With libclc available in the
cross-sysroot, mesa's meson '-Dwith_clc -> dependency(libclc)'
resolves and the gallium drivers compile.
68 lines
2.3 KiB
Markdown
68 lines
2.3 KiB
Markdown
# libclc
|
|
|
|
libclc is an open source implementation of the library
|
|
requirements of the OpenCL C programming language, as specified by the
|
|
OpenCL 1.1 Specification. The following sections of the specification
|
|
impose library requirements:
|
|
|
|
* 6.1: Supported Data Types
|
|
* 6.2.3: Explicit Conversions
|
|
* 6.2.4.2: Reinterpreting Types Using as_type() and as_typen()
|
|
* 6.9: Preprocessor Directives and Macros
|
|
* 6.11: Built-in Functions
|
|
* 9.3: Double Precision Floating-Point
|
|
* 9.4: 64-bit Atomics
|
|
* 9.5: Writing to 3D image memory objects
|
|
* 9.6: Half Precision Floating-Point
|
|
|
|
libclc is intended to be used with the Clang compiler's OpenCL frontend.
|
|
|
|
libclc is designed to be portable and extensible. To this end, it provides
|
|
generic implementations of most library requirements, allowing the target
|
|
to override the generic implementation at the granularity of individual
|
|
functions.
|
|
|
|
libclc currently supports PTX, AMDGPU, SPIRV and CLSPV targets, but support for
|
|
more targets is welcome.
|
|
|
|
## Compiling and installing
|
|
|
|
(in the following instructions you can use `make` or `ninja`)
|
|
|
|
For an in-tree build, Clang must also be built at the same time:
|
|
```
|
|
$ cmake <path-to>/llvm-project/llvm/CMakeLists.txt -DLLVM_ENABLE_PROJECTS="libclc;clang" \
|
|
-DCMAKE_BUILD_TYPE=Release -G Ninja
|
|
$ ninja
|
|
```
|
|
Then install:
|
|
```
|
|
$ ninja install
|
|
```
|
|
Note you can use the `DESTDIR` Makefile variable to do staged installs.
|
|
```
|
|
$ DESTDIR=/path/for/staged/install ninja install
|
|
```
|
|
To build out of tree, or in other words, against an existing LLVM build or install:
|
|
```
|
|
$ cmake <path-to>/llvm-project/libclc/CMakeLists.txt -DCMAKE_BUILD_TYPE=Release \
|
|
-G Ninja -DLLVM_DIR=$(<path-to>/llvm-config --cmakedir)
|
|
$ ninja
|
|
```
|
|
Then install as before.
|
|
|
|
In both cases this will include all supported targets. You can choose which
|
|
targets are enabled by passing `-DLIBCLC_TARGETS_TO_BUILD` to CMake. The default
|
|
is `all`.
|
|
|
|
In both cases, the LLVM used must include the targets you want libclc support for
|
|
(`AMDGPU` and `NVPTX` are enabled in LLVM by default). Apart from `SPIRV` where you do
|
|
not need an LLVM target but you do need the
|
|
[llvm-spirv tool](https://github.com/KhronosGroup/SPIRV-LLVM-Translator) available.
|
|
Either build this in-tree, or place it in the directory pointed to by
|
|
`LLVM_TOOLS_BINARY_DIR`.
|
|
|
|
## Website
|
|
|
|
https://libclc.llvm.org/
|