Skip to content

Commit 709cba2

Browse files
iavclaude
andcommitted
extension: kernel-version-toolchain for compiler in artifact version
Add extension that includes compiler identifier (e.g., gcc13.3, clang18.1) in kernel artifact version string using the new artifact_kernel_version_parts hook. Enable with: ENABLE_EXTENSIONS="kernel-version-toolchain" This ensures kernel cache invalidation when the toolchain changes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f970035 commit 709cba2

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Add compiler (gcc/clang) identifier to kernel artifact version string.
2+
# This ensures cache invalidation when the toolchain changes.
3+
# Enable with: ENABLE_EXTENSIONS="kernel-version-toolchain"
4+
5+
function artifact_kernel_version_parts__add_toolchain() {
6+
# Determine compiler binary
7+
declare kernel_compiler_bin="${KERNEL_COMPILER}gcc"
8+
if [[ "${KERNEL_COMPILER}" == "clang" ]]; then
9+
kernel_compiler_bin="clang"
10+
fi
11+
12+
# Get compiler version (major.minor only)
13+
declare toolchain_id="unknown"
14+
if command -v "${kernel_compiler_bin}" &> /dev/null; then
15+
declare full_version
16+
full_version="$(${kernel_compiler_bin} -dumpfullversion -dumpversion 2>/dev/null || echo "")"
17+
if [[ -n "${full_version}" ]]; then
18+
# Extract major.minor, drop patch version
19+
declare short_version
20+
short_version="$(echo "${full_version}" | cut -d'.' -f1-2)"
21+
# Build identifier: gcc13.3 or clang18.1
22+
if [[ "${KERNEL_COMPILER}" == "clang" ]]; then
23+
toolchain_id="clang${short_version}"
24+
else
25+
toolchain_id="gcc${short_version}"
26+
fi
27+
fi
28+
fi
29+
30+
display_alert "Extension: ${EXTENSION}: Adding toolchain to kernel version" "${toolchain_id}" "debug"
31+
32+
# Add to version parts
33+
artifact_version_parts["T"]="${toolchain_id}"
34+
artifact_version_part_order+=("T")
35+
}

0 commit comments

Comments
 (0)