Files
RedBear-OS/local/recipes/dev/libclc/recipe.toml
T
vasilito a9e1c34e27 round 11: libclc.pc verify + redbear-passwd [source] + sessiond can_* probe + dnsd no hardcoded upstreams + stale redbear-kde-session refs
Round 11 audit cleanup. Six fixes across six files:

1. local/recipes/system/redbear-passwd/recipe.toml — CRITICAL: was
   missing the [source] block entirely. The recipe had only [package]
   and [build] with template=cargo, which the cookbook cannot fetch.
   Added [source] path = "source" so the cookbook locates the local
   Rust crate. Also added a one-line description.

2. local/recipes/dev/libclc/recipe.toml — MEDIUM: the build script
   installs via cmake but never verifies that libclc.pc (Mesa's
   pkg-config dependency) and the .bc bitcode files actually landed.
   Without these, Mesa's 3D driver cook fails opaquely with
   'Dependency libclc not found (tried pkg-config)'. Added three
   post-install test -f checks that fail the build with a precise
   error pointing at the missing path.

3. local/recipes/system/redbear-sessiond/source/src/manager.rs — HIGH:
   the D-Bus login1 can_power_off / can_reboot / can_suspend methods
   were returning 'yes' unconditionally — the archetype lie-grade-ok
   pattern (probe says success, then the real action fails because
   /scheme/sys/kstop is missing). Replaced with a kstop_writable()
   probe that fs::metadata()s the path. Used metadata() rather than
   an actual write because writing 'shutdown'/'reset'/'s3' to
   /scheme/sys/kstop would trigger the action. The actual power_off/
   reboot/suspend methods still report granular errors when the
   write is refused.

4. local/recipes/system/redbear-dnsd/source/src/transport.rs — MEDIUM:
   UpstreamConfig::default() hardcoded 8.8.8.8 + 1.1.1.1 as fallback
   upstream DNS. Hardcoding third-party DNS bypasses netcfg integration
   and leaks user queries without consent on first boot. Replaced with
   an empty Vec — main() reads the upstream list from netcfg before
   any query is dispatched; upstream queries SERVFAIL until netcfg
   populates the list (honest default).

5. local/docs/GREETER-LOGIN-IMPLEMENTATION-PLAN.md — MEDIUM: 16
   references to the non-existent binary 'redbear-kde-session' (now
   'redbear-session-launch'). Global s/redbear-kde-session/redbear-
   session-launch/g. Also updated two 'redbear-kde' profile-name
   references to reflect the 2026-07-24 retirement and the current
   'redbear-full' ownership of the desktop path.

6. local/docs/DBUS-INTEGRATION-PLAN.md — LOW: 7 references to
   'redbear-kde-session' renamed to 'redbear-session-launch' (same
   binary rename).

6 files changed, +68/-28.

Note: Mesa 04-sys-ioccom-stub-header.patch migration to relibc proper
(sys/ioccom.h with Linux-style IOC encoding) is deferred — the
patch is a genuine gap-filler (relibc's sys/ioctl.h has the basic
macros but sys/ioccom.h is the BSD include path DRM UAPI expects).
That work belongs in the relibc fork with a prefix rebuild and
should be coordinated with the operator's prefix-staleness policy.
2026-07-27 20:08:25 +09:00

158 lines
6.8 KiB
TOML

[package]
name = "libclc"
# Red Bear OS internal libclc. Upstream is llvm-project's libclc
# (https://github.com/llvm/llvm-project/tree/main/libclc). The source
# is vendored from the same revision as llvm21 (redox-2025-10-03).
# The version follows the Red Bear OS branch per local/AGENTS.md.
version = "0.3.1"
description = "libclc — Red Bear OS port of the OpenCL C library requirements (amdgcn, r600, spirv, generic targets). Provides the .bc bitcode files Mesa's clc tool consumes for hardware GPU drivers (iris, radeonsi, llvmpipe)."
[source]
# Vendored from the same revision as llvm21 / clang21.
git = "https://gitlab.redox-os.org/redox-os/llvm-project.git"
upstream = "https://github.com/llvm/llvm-project.git"
branch = "redox-2025-10-03"
path_in_repo = "libclc"
shallow_clone = true
[build]
template = "custom"
# Build depends on the HOST clang (built by clang21) and the
# LLVMConfig.cmake (provided by llvm21's install).
dependencies = [
"clang21",
"llvm21",
]
dev-dependencies = [
"clang21.dev",
"llvm21.dev",
]
script = '''
DYNAMIC_INIT
ARCH="$(echo "${TARGET}" | cut -d - -f1)"
# libclc is built with the HOST clang (not the cross-compiler):
# it produces .bc bitcode files that are architecture-independent
# for the GPU targets Mesa cares about (amdgcn, r600, spirv,
# generic). The output is then consumed at runtime by Mesa's clc
# tool via the dependency('libclc') pkg-config lookup.
# Save the cross-compile environment so we can use the HOST
# toolchain (Clang) to compile OpenCL kernels to bitcode.
_SAVED_LDFLAGS="${LDFLAGS:-}"
_SAVED_CFLAGS="${CFLAGS:-}"
_SAVED_CXXFLAGS="${CXXFLAGS:-}"
_SAVED_CPPFLAGS="${CPPFLAGS:-}"
unset LDFLAGS CFLAGS CXXFLAGS CPPFLAGS
# Generate a NATIVE toolchain file. We can't use cookbook_cmake
# because that targets the cross sysroot; libclc needs the host.
generate_cookbook_cmake_file "${COOKBOOK_HOST_TARGET}" "" "/usr" native_libclc.cmake
# Override the CMAKE_CXX_COMPILER etc. to point at the HOST clang
# that comes from the cookbook sysroot (clang21 build). The cookbook
# sysroot contains both the host Clang binary and the LLVM tools
# that libclc needs to find via LLVM_DIR.
cat >> native_libclc.cmake <<'NATIVE_EOF'
set(CMAKE_C_COMPILER "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE)
set(CMAKE_CXX_COMPILER "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE)
set(CMAKE_ASM_COMPILER "${COOKBOOK_SYSROOT}/bin/clang-21" CACHE FILEPATH "" FORCE)
set(CMAKE_AR "${COOKBOOK_SYSROOT}/bin/llvm-ar" CACHE FILEPATH "" FORCE)
set(CMAKE_NM "${COOKBOOK_SYSROOT}/bin/llvm-nm" CACHE FILEPATH "" FORCE)
set(CMAKE_RANLIB "${COOKBOOK_SYSROOT}/bin/llvm-ranlib" CACHE FILEPATH "" FORCE)
set(CMAKE_C_FLAGS_INIT "" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS_INIT "" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_INIT "" CACHE STRING "" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS_INIT "" CACHE STRING "" FORCE)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM "BYPASS" CACHE STRING "" FORCE)
set(LLVM_DIR "${COOKBOOK_SYSROOT}/lib/cmake/llvm" CACHE PATH "" FORCE)
set(LIBCLC_STANDALONE_BUILD TRUE CACHE BOOL "" FORCE)
NATIVE_EOF
# Run cmake with the host-native toolchain. LIBCLC_TARGETS_TO_BUILD
# is the list of GPU targets Mesa consumes. The target-name syntax
# in upstream libclc is `<triple>--` (double-dash suffix for the
# unspecified-ABI variant) plus the Mesa-specific `amdgcn-mesa-mesa3d`
# for the Mesa3D frontend. Targets not consumed by Mesa (ptx-nvidiacl
# for NVIDIA, clspv for Vulkan-SPIR-V) are excluded. The full set
# covers all gallium drivers Mesa 26.1.4 supports via the clc tool:
# r600 -> r600 (Southern Islands / Evergreen)
# amdgcn-- -> GCN GFX6..GFX12 (default-ABI)
# amdgcn--amdhsa -> GCN with HSA runtime
# amdgcn-mesa-mesa3d -> GCN via the Mesa3D-specific path
# The `spirv` target is handled by Mesa's own clc tool (not libclc
# bitcode); libclc's spirv files are used for mesa's SPIR-V codegen
# in clc, but the .bc files themselves are produced by Mesa's clc.
COOKBOOK_CMAKE_FLAGS+=(
-DCMAKE_TOOLCHAIN_FILE="$(realpath native_libclc.cmake)"
-DCMAKE_BUILD_TYPE=Release
-DLLVM_DIR="${COOKBOOK_SYSROOT}/lib/cmake/llvm"
-DLIBCLC_STANDALONE_BUILD=TRUE
-DLIBCLC_TARGETS_TO_BUILD="r600--;amdgcn--;amdgcn--amdhsa;amdgcn-mesa-mesa3d"
-DENABLE_RUNTIME_SUBNORMAL=OFF
-DCMAKE_INSTALL_PREFIX="${COOKBOOK_STAGE}/usr"
-DCMAKE_INSTALL_LIBDIR=lib
-DCMAKE_INSTALL_INCLUDEDIR=include
-DCMAKE_INSTALL_DATADIR=share
-DLLVM_TARGETS_TO_BUILD="$ARCH"
-G Ninja
-Wno-dev
)
# Restore the cross-compile environment (libclc install is the only
# step that uses the host toolchain; if subsequent install steps
# are added to the recipe, they'd want the cross env).
export LDFLAGS="$_SAVED_LDFLAGS"
export CFLAGS="$_SAVED_CFLAGS"
export CXXFLAGS="$_SAVED_CXXFLAGS"
export CPPFLAGS="$_SAVED_CPPFLAGS"
# Source dir is the path_in_repo subdir of the cloned llvm-project. This
# cookbook does not extract path_in_repo into COOKBOOK_SOURCE — it clones the
# whole llvm-project there — so CMake was pointed at the repo root and failed
# with "source directory does not appear to contain CMakeLists.txt". Descend
# into the libclc subdir when the whole repo was cloned (mirrors how the clang21
# recipe does COOKBOOK_SOURCE/clang); if path_in_repo already left the subdir at
# the root, use it as-is.
if [ -f "${COOKBOOK_SOURCE}/libclc/CMakeLists.txt" ]; then
COOKBOOK_SOURCE="${COOKBOOK_SOURCE}/libclc"
fi
"${COOKBOOK_CMAKE}" "${COOKBOOK_SOURCE}" "${COOKBOOK_CMAKE_FLAGS[@]}"
"${COOKBOOK_NINJA}" -j"${COOKBOOK_MAKE_JOBS}"
DESTDIR="${COOKBOOK_STAGE}/stage" "${COOKBOOK_NINJA}" install
# Move installed files from $COOKBOOK_STAGE/stage to $COOKBOOK_STAGE.
# The DESTDIR install above places everything under
# $COOKBOOK_STAGE/stage; flatten the extra stage dir.
if [ -d "${COOKBOOK_STAGE}/stage" ]; then
cp -a "${COOKBOOK_STAGE}/stage/." "${COOKBOOK_STAGE}/"
rm -rf "${COOKBOOK_STAGE}/stage"
fi
# Mesa's clc tool expects the .bc files at <libexecdir>/clc where
# libexecdir is <prefix>/share/clc (per the libclc.pc.in template).
# The cmake install above places them at $COOKBOOK_STAGE/usr/share/clc
# which is the right path; no further action needed.
if [ ! -f "${COOKBOOK_STAGE}/usr/lib/pkgconfig/libclc.pc" ]; then
echo "libclc: ERROR — install did not produce libclc.pc" >&2
echo "libclc: expected at ${COOKBOOK_STAGE}/usr/lib/pkgconfig/libclc.pc" >&2
echo "libclc: check that upstream libclc CMakeLists.txt installs pkgconfig files" >&2
exit 1
fi
if [ ! -d "${COOKBOOK_STAGE}/usr/share/clc" ]; then
echo "libclc: ERROR — install did not produce .bc files under usr/share/clc" >&2
exit 1
fi
if ! ls "${COOKBOOK_STAGE}/usr/share/clc"/*.bc >/dev/null 2>&1; then
echo "libclc: ERROR — usr/share/clc contains no .bc bitcode files" >&2
exit 1
fi
'''
[[optional-packages]]
name = "dev"
files = [
"usr/include/**",
]