Skip to content

Commit 2d0543d

Browse files
committed
build(devcontainer): pin LLVM tooling to version 23
Pin the local LLVM devcontainer Feature to version 23 to avoid silent toolchain drift across rebuilds. Update the installer to prefer a versioned apt.llvm.org suite when it exists, while falling back to the generic suite for current tip versions that do not yet have a dedicated per-version suite. Fail early when the requested clang-format, clangd, or clang-tidy packages are not available from the selected repository.
1 parent a2a292d commit 2d0543d

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
]
1414
},
1515
"features": {
16-
"./features/llvm": {}
16+
"./features/llvm": {
17+
"version": "23"
18+
}
1719
},
1820
"remoteEnv": {
1921
"CODEX_HOME": "${containerWorkspaceFolder}/.codex"

.devcontainer/features/llvm/install.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ LLVM_REQUESTED_VERSION="${VERSION:-latest}"
77

88
. /etc/os-release
99

10+
LLVM_DIST="llvm-toolchain-${VERSION_CODENAME}"
11+
1012
apt-get update -y
1113
apt-get install -y --no-install-recommends \
1214
ca-certificates \
@@ -17,9 +19,17 @@ install -d -m 0755 /etc/apt/keyrings
1719

1820
wget -qO /etc/apt/keyrings/apt.llvm.org.asc https://apt.llvm.org/llvm-snapshot.gpg.key
1921

20-
# Use the generic apt.llvm.org suite.
22+
# Use a pinned per-version suite when available. Fall back to the generic
23+
# suite for the current tip version, which may not have a dedicated suite yet.
24+
if [ "${LLVM_REQUESTED_VERSION}" != "latest" ] && [ -n "${LLVM_REQUESTED_VERSION}" ]; then
25+
VERSIONED_DIST="llvm-toolchain-${VERSION_CODENAME}-${LLVM_REQUESTED_VERSION}"
26+
if wget -q --spider "https://apt.llvm.org/${VERSION_CODENAME}/dists/${VERSIONED_DIST}/InRelease"; then
27+
LLVM_DIST="${VERSIONED_DIST}"
28+
fi
29+
fi
30+
2131
cat > /etc/apt/sources.list.d/llvm.list <<EOF
22-
deb [signed-by=/etc/apt/keyrings/apt.llvm.org.asc] https://apt.llvm.org/${VERSION_CODENAME}/ llvm-toolchain-${VERSION_CODENAME} main
32+
deb [signed-by=/etc/apt/keyrings/apt.llvm.org.asc] https://apt.llvm.org/${VERSION_CODENAME}/ ${LLVM_DIST} main
2333
EOF
2434

2535
apt-get update -y
@@ -42,8 +52,20 @@ else
4252
fi
4353

4454
echo "Using LLVM version: ${LLVM_VERSION}"
55+
echo "Using LLVM APT suite: ${LLVM_DIST}"
56+
57+
for pkg in "clang-format-${LLVM_VERSION}" "clangd-${LLVM_VERSION}" "clang-tidy-${LLVM_VERSION}"; do
58+
POLICY_OUTPUT="$(apt-cache policy "${pkg}")"
59+
if ! printf '%s\n' "${POLICY_OUTPUT}" | grep -Fq "apt.llvm.org/${VERSION_CODENAME}" \
60+
|| ! printf '%s\n' "${POLICY_OUTPUT}" | grep -Fq "${LLVM_DIST}/main"; then
61+
echo "ERROR: ${pkg} is not available from the expected repository: apt.llvm.org/${VERSION_CODENAME} ${LLVM_DIST}/main." >&2
62+
printf '%s\n' "${POLICY_OUTPUT}" >&2
63+
exit 1
64+
fi
65+
done
4566

4667
apt-get install -y --no-install-recommends \
68+
-t "${LLVM_DIST}" \
4769
clang-format-${LLVM_VERSION} \
4870
clangd-${LLVM_VERSION} \
4971
clang-tidy-${LLVM_VERSION}

0 commit comments

Comments
 (0)