blob: 20696949c8659e7111c0aecdadb465770926509e [file] [log] [blame]
Baranov Victor08c057e2025-09-27 23:39:35 +03001FROM docker.io/library/ubuntu:24.04 AS base
Tom Stellarddf4c5d52024-12-10 06:31:41 -08002ENV LLVM_SYSROOT=/opt/llvm
3
Baranov Victor08c057e2025-09-27 23:39:35 +03004FROM base AS stage1-toolchain
Aiden Grossman4b06e832026-03-03 12:26:02 -08005ENV LLVM_VERSION=22.1.0
Tom Stellarddf4c5d52024-12-10 06:31:41 -08006
7RUN apt-get update && \
8 apt-get install -y \
9 wget \
10 gcc \
11 g++ \
12 cmake \
13 ninja-build \
14 python3 \
15 git \
Aiden Grossmane68d18c2025-01-20 11:50:21 -080016 curl \
George Burgess IV78d7dd22025-03-26 17:38:43 -060017 zlib1g-dev && \
18 apt-get clean && \
19 rm -rf /var/lib/apt/lists/*
Tom Stellarddf4c5d52024-12-10 06:31:41 -080020
George Burgess IV78d7dd22025-03-26 17:38:43 -060021RUN curl -O -L https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-$LLVM_VERSION.tar.gz && \
22 tar -xf llvmorg-$LLVM_VERSION.tar.gz && \
23 rm -f llvmorg-$LLVM_VERSION.tar.gz
Tom Stellarddf4c5d52024-12-10 06:31:41 -080024
25WORKDIR /llvm-project-llvmorg-$LLVM_VERSION
26
Tom Stellarddf4c5d52024-12-10 06:31:41 -080027RUN cmake -B ./build -G Ninja ./llvm \
28 -C ./clang/cmake/caches/BOLT-PGO.cmake \
29 -DBOOTSTRAP_LLVM_ENABLE_LLD=ON \
30 -DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
31 -DPGO_INSTRUMENT_LTO=Thin \
32 -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
33 -DCMAKE_INSTALL_PREFIX="$LLVM_SYSROOT" \
34 -DLLVM_ENABLE_PROJECTS="bolt;clang;lld;clang-tools-extra" \
Aiden Grossman339f58d2025-04-12 05:21:26 +000035 -DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format;scan-build;llvm-symbolizer" \
Tom Stellarddf4c5d52024-12-10 06:31:41 -080036 -DCLANG_DEFAULT_LINKER="lld"
37
38RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution
39
Baranov Victor08c057e2025-09-27 23:39:35 +030040FROM base AS ci-container
George Burgess IV3ce92e12025-03-03 09:47:42 -070041
Tom Stellarddf4c5d52024-12-10 06:31:41 -080042COPY --from=stage1-toolchain $LLVM_SYSROOT $LLVM_SYSROOT
Aiden Grossman17519142024-12-16 20:30:01 +000043
Tom Stellarddf4c5d52024-12-10 06:31:41 -080044# Need to install curl for hendrikmuhs/ccache-action
45# Need nodejs for some of the GitHub actions.
46# Need perl-modules for clang analyzer tests.
47# Need git for SPIRV-Tools tests.
Nikita Popovc1236422026-03-04 15:57:56 +010048# Need binutils-dev instead of binutils to build the linker LTO plugin.
Tom Stellarddf4c5d52024-12-10 06:31:41 -080049RUN apt-get update && \
Aiden Grossman17519142024-12-16 20:30:01 +000050 DEBIAN_FRONTEND=noninteractive apt-get install -y \
Nikita Popovc1236422026-03-04 15:57:56 +010051 binutils-dev \
Tom Stellarddf4c5d52024-12-10 06:31:41 -080052 cmake \
53 curl \
54 git \
55 libstdc++-11-dev \
56 ninja-build \
57 nodejs \
58 perl-modules \
Aiden Grossman17519142024-12-16 20:30:01 +000059 python3-psutil \
Aiden Grossman91ab10e2025-01-08 17:21:40 -080060 sudo \
Aiden Grossman17519142024-12-16 20:30:01 +000061 # These are needed by the premerge pipeline. Pip is used to install
Aiden Grossman0f3c94a2025-07-25 08:38:13 -070062 # dependent python packages. File and tzdata are used for tests.
Aiden Grossmand8c43e62025-08-06 15:54:35 +000063 # Having a symlink from python to python3 enables code sharing between
64 # the Linux and Windows pipelines.
Aiden Grossman17519142024-12-16 20:30:01 +000065 python3-pip \
Aiden Grossman17519142024-12-16 20:30:01 +000066 file \
Aiden Grossmand8c43e62025-08-06 15:54:35 +000067 tzdata \
68 python-is-python3 && \
George Burgess IV78d7dd22025-03-26 17:38:43 -060069 apt-get clean && \
70 rm -rf /var/lib/apt/lists/*
Tom Stellarddf4c5d52024-12-10 06:31:41 -080071
Aiden Grossmanfcb7ed62025-07-17 10:15:11 -070072# We need sccache for caching. We cannot use the apt repository version because
73# it is too old and has bugs related to features we require (particularly GCS
74# caching), so we manually install it here.
75# TODO(boomanaiden154): We should return to installing this from the apt
76# repository once a version containing the necessary bug fixes is available.
Tom Stellard21351482025-08-26 21:35:11 -070077RUN curl -L "https://github.com/mozilla/sccache/releases/download/v0.10.0/sccache-v0.10.0-$(arch)-unknown-linux-musl.tar.gz" > /tmp/sccache.tar.gz && \
78 echo $( [ $(arch) = 'x86_64' ] && echo "1fbb35e135660d04a2d5e42b59c7874d39b3deb17de56330b25b713ec59f849b" || echo "d6a1ce4acd02b937cd61bc675a8be029a60f7bc167594c33d75732bbc0a07400") /tmp/sccache.tar.gz | sha256sum -c && \
Aiden Grossmanfcb7ed62025-07-17 10:15:11 -070079 tar xzf /tmp/sccache.tar.gz -O --wildcards '*/sccache' > '/usr/local/bin/sccache' && \
80 rm /tmp/sccache.tar.gz && \
81 chmod +x /usr/local/bin/sccache
82
Tom Stellarddf4c5d52024-12-10 06:31:41 -080083ENV LLVM_SYSROOT=$LLVM_SYSROOT
84ENV PATH=${LLVM_SYSROOT}/bin:${PATH}
Aiden Grossmand0b19cf2025-08-15 21:31:17 +000085ENV CC=clang
86ENV CXX=clang++
Aiden Grossmanb86a22a2024-12-16 21:22:34 +000087
88# Create a new user to avoid test failures related to a lack of expected
89# permissions issues in some tests. Set the user id to 1001 as that is the
90# user id that Github Actions uses to perform the checkout action.
91RUN useradd gha -u 1001 -m -s /bin/bash
Aiden Grossman91ab10e2025-01-08 17:21:40 -080092
93# Also add the user to passwordless sudoers so that we can install software
94# later on without having to rebuild the container.
95RUN adduser gha sudo
96RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
97
Aiden Grossmanb86a22a2024-12-16 21:22:34 +000098USER gha
Aiden Grossmand35d7f4b2025-01-20 11:53:25 -080099WORKDIR /home/gha
100
Baranov Victor08c057e2025-09-27 23:39:35 +0300101FROM ci-container AS ci-container-agent
Aiden Grossmand35d7f4b2025-01-20 11:53:25 -0800102
Aiden Grossman52f32d72026-03-02 17:15:37 -0800103ENV GITHUB_RUNNER_VERSION=2.332.0
Aiden Grossmand35d7f4b2025-01-20 11:53:25 -0800104
105RUN mkdir actions-runner && \
106 cd actions-runner && \
107 curl -O -L https://github.com/actions/runner/releases/download/v$GITHUB_RUNNER_VERSION/actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz && \
108 tar xzf ./actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz && \
109 rm ./actions-runner-linux-x64-$GITHUB_RUNNER_VERSION.tar.gz
Aiden Grossmanb86a22a2024-12-16 21:22:34 +0000110