| 1 |
# ===----------------------------------------------------------------------===## |
| 2 |
# |
| 3 |
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
# See https://llvm.org/LICENSE.txt for license information. |
| 5 |
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
# |
| 7 |
# ===----------------------------------------------------------------------===## |
| 8 |
# |
| 9 |
# This file defines the base image we use for Linux testing using Github Actions. |
| 10 |
# From the root of the monorepo, this image can be built with: |
| 11 |
# |
| 12 |
# $ docker build --file libcxx/utils/ci/docker/linux-builder-base.dockerfile \ |
| 13 |
# --build-arg GCC_HEAD_VERSION=<version> \ |
| 14 |
# --build-arg LLVM_HEAD_VERSION=<version> . |
| 15 |
# |
| 16 |
# This image also gets built on every push to `main` that modifies these Docker |
| 17 |
# files, and can be found at ghcr.io/libcxx/libcxx-linux-builder-base . |
| 18 |
|
| 19 |
FROM docker.io/library/ubuntu:noble |
| 20 |
|
| 21 |
# Changing this file causes a rebuild of the image in a GitHub action. However, it does not cause |
| 22 |
# the CI runners to switch to that image automatically, that must be done by updating the image used |
| 23 |
# by the libc++ self-hosted runners in llvm-zorg. The date uses the ISO format YYYY-MM-DD. |
| 24 |
RUN echo "Last forced update executed on 2026-01-07." |
| 25 |
|
| 26 |
# Make sure apt-get doesn't try to prompt for stuff like our time zone, etc. |
| 27 |
ENV DEBIAN_FRONTEND=noninteractive |
| 28 |
|
| 29 |
# populated in the docker-compose file |
| 30 |
ARG GCC_HEAD_VERSION |
| 31 |
ENV GCC_HEAD_VERSION=${GCC_HEAD_VERSION} |
| 32 |
|
| 33 |
# populated in the docker-compose file |
| 34 |
ARG LLVM_HEAD_VERSION |
| 35 |
ENV LLVM_HEAD_VERSION=${LLVM_HEAD_VERSION} |
| 36 |
|
| 37 |
# Install sudo and setup passwordless sudo. |
| 38 |
RUN <<EOF |
| 39 |
apt-get update || true |
| 40 |
apt-get install -y sudo || true |
| 41 |
echo "ALL ALL = (ALL) NOPASSWD: ALL" | tee /etc/sudoers || true |
| 42 |
EOF |
| 43 |
|
| 44 |
# Installing tzdata before other packages avoids the time zone prompts. |
| 45 |
# These prompts seem to ignore DEBIAN_FRONTEND=noninteractive. |
| 46 |
RUN sudo apt-get update \ |
| 47 |
&& sudo apt-get install -y \ |
| 48 |
tzdata |
| 49 |
|
| 50 |
# Install various tools used by the build or the test suite |
| 51 |
RUN sudo apt-get update \ |
| 52 |
&& sudo apt-get install -y \ |
| 53 |
bash \ |
| 54 |
bzip2 \ |
| 55 |
ccache \ |
| 56 |
curl \ |
| 57 |
gdb \ |
| 58 |
git \ |
| 59 |
gpg \ |
| 60 |
language-pack-en \ |
| 61 |
language-pack-fr \ |
| 62 |
language-pack-ja \ |
| 63 |
language-pack-ru \ |
| 64 |
language-pack-zh-hans \ |
| 65 |
libedit-dev \ |
| 66 |
libncurses5-dev \ |
| 67 |
libpython3-dev \ |
| 68 |
libxml2-dev \ |
| 69 |
lsb-release \ |
| 70 |
make \ |
| 71 |
ninja-build \ |
| 72 |
python3 \ |
| 73 |
python3-dev \ |
| 74 |
python3-packaging \ |
| 75 |
python3-setuptools \ |
| 76 |
python3-psutil \ |
| 77 |
software-properties-common \ |
| 78 |
swig \ |
| 79 |
unzip \ |
| 80 |
uuid-dev \ |
| 81 |
wget \ |
| 82 |
xz-utils \ |
| 83 |
&& sudo rm -rf /var/lib/apt/lists/* |
| 84 |
|
| 85 |
# These two locales are not enabled by default so generate them |
| 86 |
RUN <<EOF |
| 87 |
set -e |
| 88 |
printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" | sudo tee -a /etc/locale.gen |
| 89 |
sudo mkdir /usr/local/share/i1en/ |
| 90 |
printf "fr_CA ISO-8859-1\ncs_CZ ISO-8859-2" | sudo tee -a /usr/local/share/i1en/SUPPORTED |
| 91 |
sudo locale-gen |
| 92 |
EOF |
| 93 |
|
| 94 |
# Install Clang <latest>, <latest-1> and ToT, which are the ones we support. |
| 95 |
# We also install <latest-2> because we need to support the "latest-1" of the |
| 96 |
# current LLVM release branch, which is effectively the <latest-2> of the |
| 97 |
# tip-of-trunk LLVM. For example, after branching LLVM 14 but before branching |
| 98 |
# LLVM 15, we still need to have Clang 12 in this Docker image because the LLVM |
| 99 |
# 14 release branch CI uses it. The tip-of-trunk CI will never use Clang 12, |
| 100 |
# though. |
| 101 |
RUN <<EOF |
| 102 |
set -e |
| 103 |
sudo apt-get update |
| 104 |
wget https://apt.llvm.org/llvm.sh -O /tmp/llvm.sh |
| 105 |
chmod +x /tmp/llvm.sh |
| 106 |
sudo /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 3)) all # for CI transitions |
| 107 |
sudo /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 2)) all # previous release |
| 108 |
sudo /tmp/llvm.sh $(($LLVM_HEAD_VERSION - 1)) all # latest release |
| 109 |
sudo /tmp/llvm.sh $LLVM_HEAD_VERSION all # current ToT |
| 110 |
sudo rm -rf /var/lib/apt/lists/* |
| 111 |
EOF |
| 112 |
|
| 113 |
# Install the most recent GCC, like clang install the previous version as a transition. |
| 114 |
RUN <<EOF |
| 115 |
set -e |
| 116 |
sudo git clone https://github.com/compiler-explorer/infra.git /tmp/ce-infra |
| 117 |
(cd /tmp/ce-infra && sudo make ce) |
| 118 |
# Current ToT, we do not guarantee any support in our support matrix. |
| 119 |
sudo /tmp/ce-infra/bin/ce_install --enable nightly install compilers/c++/nightly/gcc trunk |
| 120 |
sudo ln -s /opt/compiler-explorer/gcc-snapshot/bin/gcc /usr/bin/gcc-$GCC_HEAD_VERSION |
| 121 |
sudo ln -s /opt/compiler-explorer/gcc-snapshot/bin/g++ /usr/bin/g++-$GCC_HEAD_VERSION |
| 122 |
# The latest release. |
| 123 |
sudo /tmp/ce-infra/bin/ce_install install compilers/c++/x86/gcc $((GCC_HEAD_VERSION - 1)).1.0 |
| 124 |
sudo ln -s /opt/compiler-explorer/gcc-$((GCC_HEAD_VERSION - 1)).1.0/bin/gcc /usr/bin/gcc-$((GCC_HEAD_VERSION - 1)) |
| 125 |
sudo ln -s /opt/compiler-explorer/gcc-$((GCC_HEAD_VERSION - 1)).1.0/bin/g++ /usr/bin/g++-$((GCC_HEAD_VERSION - 1)) |
| 126 |
# For CI transitions. |
| 127 |
sudo /tmp/ce-infra/bin/ce_install install compilers/c++/x86/gcc $((GCC_HEAD_VERSION - 2)).1.0 |
| 128 |
sudo ln -s /opt/compiler-explorer/gcc-$((GCC_HEAD_VERSION - 2)).1.0/bin/gcc /usr/bin/gcc-$((GCC_HEAD_VERSION - 2)) |
| 129 |
sudo ln -s /opt/compiler-explorer/gcc-$((GCC_HEAD_VERSION - 2)).1.0/bin/g++ /usr/bin/g++-$((GCC_HEAD_VERSION - 2)) |
| 130 |
sudo rm -rf /tmp/ce-infra |
| 131 |
EOF |
| 132 |
|
| 133 |
RUN <<EOF |
| 134 |
# Install a recent CMake |
| 135 |
set -e |
| 136 |
wget https://github.com/Kitware/CMake/releases/download/v3.24.4/cmake-3.24.4-linux-x86_64.sh -O /tmp/install-cmake.sh |
| 137 |
sudo bash /tmp/install-cmake.sh --prefix=/usr --exclude-subdir --skip-license |
| 138 |
rm /tmp/install-cmake.sh |
| 139 |
EOF |