Skip to content

Commit

Permalink
CI: Make LLVM version selection more fine-grained
Browse files Browse the repository at this point in the history
ubuntu-22.04 includes LLVM 14, but ubuntu-20.04 does not. As such, we cannot
always install LLVM 14, but rather, we must choose which LLVM version to
install based on which Ubuntu version we are using.

While I am in town, this patch also factors out the LLVM version into a single
`LINUX_LLVM_VER` environment variable and uses it everywhere so that we do not
have to remember to update quite so many locations in the future. (I also do
something similar with `MACOS_LLVM_VER`.)
  • Loading branch information
RyanGlScott committed Sep 23, 2024
1 parent 9ab5237 commit c301fea
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/Dockerfile-crux-llvm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ RUN apt-get update && \
# Crux dependencies \
pkg-config zlib1g-dev \
# LLVM toolchain
#
# If you update the version numbers below, make sure to update the
# value of LINUX_LLVM_VER in .github/ci.sh (in the install_llvm()
# function).
clang-14 llvm-14-tools \
# Miscellaneous
locales unzip wget
Expand Down
26 changes: 20 additions & 6 deletions .github/ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,27 @@ test() {

install_llvm() {
if [[ "$RUNNER_OS" = "Linux" ]]; then
sudo apt-get update -q && sudo apt-get install -y clang-14 llvm-14-tools
echo "LLVM_LINK=llvm-link-14" >> "$GITHUB_ENV"
echo "LLVM_AS=llvm-as-14" >> "$GITHUB_ENV"
echo "CLANG=clang-14" >> "$GITHUB_ENV"
# Different Ubuntu versions include different LLVM versions in the package
# manager, so we select the appropriate LLVM version below.
#
# If you update the value of LINUX_LLVM_VER below, make sure to also update
# the corresponding LLVM version in .github/Dockerfile-crux-llvm.
if [[ "$BUILD_TARGET_OS" = "ubuntu-22.04" ]]; then
LINUX_LLVM_VER=14
elif [[ "$BUILD_TARGET_OS" = "ubuntu-20.04" ]]; then
LINUX_LLVM_VER=12
else
echo "Don't know what LLVM version to use for $LINUX_LLVM_VER."
exit 1
fi
sudo apt-get update -q && sudo apt-get install -y "clang-$LINUX_LLVM_VER" "llvm-$LINUX_LLVM_VER-tools"
echo "LLVM_LINK=llvm-link-$LINUX_LLVM_VER" >> "$GITHUB_ENV"
echo "LLVM_AS=llvm-as-$LINUX_LLVM_VER" >> "$GITHUB_ENV"
echo "CLANG=clang-$LINUX_LLVM_VER" >> "$GITHUB_ENV"
elif [[ "$RUNNER_OS" = "macOS" ]]; then
brew install llvm@14
echo "$(brew --prefix)/opt/llvm@14/bin" >> "$GITHUB_PATH"
MACOS_LLVM_VER=14
brew install "llvm@$MACOS_LLVM_VER"
echo "$(brew --prefix)/opt/llvm@$MACOS_LLVM_VER/bin" >> "$GITHUB_PATH"
elif [[ "$RUNNER_OS" = "Windows" ]]; then
choco install llvm
else
Expand Down

0 comments on commit c301fea

Please sign in to comment.