| Baranov Victor | 08c057e | 2025-09-27 23:39:35 +0300 | [diff] [blame] | 1 | FROM docker.io/library/ubuntu:24.04 AS base |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 2 | ENV LLVM_SYSROOT=/opt/llvm |
| 3 | |
| Baranov Victor | 08c057e | 2025-09-27 23:39:35 +0300 | [diff] [blame] | 4 | FROM base AS stage1-toolchain |
| Aiden Grossman | 4b06e83 | 2026-03-03 12:26:02 -0800 | [diff] [blame] | 5 | ENV LLVM_VERSION=22.1.0 |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 6 | |
| 7 | RUN apt-get update && \ |
| 8 | apt-get install -y \ |
| 9 | wget \ |
| 10 | gcc \ |
| 11 | g++ \ |
| 12 | cmake \ |
| 13 | ninja-build \ |
| 14 | python3 \ |
| 15 | git \ |
| Aiden Grossman | e68d18c | 2025-01-20 11:50:21 -0800 | [diff] [blame] | 16 | curl \ |
| George Burgess IV | 78d7dd2 | 2025-03-26 17:38:43 -0600 | [diff] [blame] | 17 | zlib1g-dev && \ |
| 18 | apt-get clean && \ |
| 19 | rm -rf /var/lib/apt/lists/* |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 20 | |
| George Burgess IV | 78d7dd2 | 2025-03-26 17:38:43 -0600 | [diff] [blame] | 21 | RUN 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 Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 24 | |
| 25 | WORKDIR /llvm-project-llvmorg-$LLVM_VERSION |
| 26 | |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 27 | RUN 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 Grossman | 339f58d | 2025-04-12 05:21:26 +0000 | [diff] [blame] | 35 | -DLLVM_DISTRIBUTION_COMPONENTS="lld;compiler-rt;clang-format;scan-build;llvm-symbolizer" \ |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 36 | -DCLANG_DEFAULT_LINKER="lld" |
| 37 | |
| 38 | RUN ninja -C ./build stage2-clang-bolt stage2-install-distribution && ninja -C ./build install-distribution |
| 39 | |
| Baranov Victor | 08c057e | 2025-09-27 23:39:35 +0300 | [diff] [blame] | 40 | FROM base AS ci-container |
| George Burgess IV | 3ce92e1 | 2025-03-03 09:47:42 -0700 | [diff] [blame] | 41 | |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 42 | COPY --from=stage1-toolchain $LLVM_SYSROOT $LLVM_SYSROOT |
| Aiden Grossman | 1751914 | 2024-12-16 20:30:01 +0000 | [diff] [blame] | 43 | |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 44 | # 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 Popov | c123642 | 2026-03-04 15:57:56 +0100 | [diff] [blame] | 48 | # Need binutils-dev instead of binutils to build the linker LTO plugin. |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 49 | RUN apt-get update && \ |
| Aiden Grossman | 1751914 | 2024-12-16 20:30:01 +0000 | [diff] [blame] | 50 | DEBIAN_FRONTEND=noninteractive apt-get install -y \ |
| Nikita Popov | c123642 | 2026-03-04 15:57:56 +0100 | [diff] [blame] | 51 | binutils-dev \ |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 52 | cmake \ |
| 53 | curl \ |
| 54 | git \ |
| 55 | libstdc++-11-dev \ |
| 56 | ninja-build \ |
| 57 | nodejs \ |
| 58 | perl-modules \ |
| Aiden Grossman | 1751914 | 2024-12-16 20:30:01 +0000 | [diff] [blame] | 59 | python3-psutil \ |
| Aiden Grossman | 91ab10e | 2025-01-08 17:21:40 -0800 | [diff] [blame] | 60 | sudo \ |
| Aiden Grossman | 1751914 | 2024-12-16 20:30:01 +0000 | [diff] [blame] | 61 | # These are needed by the premerge pipeline. Pip is used to install |
| Aiden Grossman | 0f3c94a | 2025-07-25 08:38:13 -0700 | [diff] [blame] | 62 | # dependent python packages. File and tzdata are used for tests. |
| Aiden Grossman | d8c43e6 | 2025-08-06 15:54:35 +0000 | [diff] [blame] | 63 | # Having a symlink from python to python3 enables code sharing between |
| 64 | # the Linux and Windows pipelines. |
| Aiden Grossman | 1751914 | 2024-12-16 20:30:01 +0000 | [diff] [blame] | 65 | python3-pip \ |
| Aiden Grossman | 1751914 | 2024-12-16 20:30:01 +0000 | [diff] [blame] | 66 | file \ |
| Aiden Grossman | d8c43e6 | 2025-08-06 15:54:35 +0000 | [diff] [blame] | 67 | tzdata \ |
| 68 | python-is-python3 && \ |
| George Burgess IV | 78d7dd2 | 2025-03-26 17:38:43 -0600 | [diff] [blame] | 69 | apt-get clean && \ |
| 70 | rm -rf /var/lib/apt/lists/* |
| Tom Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 71 | |
| Aiden Grossman | fcb7ed6 | 2025-07-17 10:15:11 -0700 | [diff] [blame] | 72 | # 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 Stellard | 2135148 | 2025-08-26 21:35:11 -0700 | [diff] [blame] | 77 | RUN 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 Grossman | fcb7ed6 | 2025-07-17 10:15:11 -0700 | [diff] [blame] | 79 | 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 Stellard | df4c5d5 | 2024-12-10 06:31:41 -0800 | [diff] [blame] | 83 | ENV LLVM_SYSROOT=$LLVM_SYSROOT |
| 84 | ENV PATH=${LLVM_SYSROOT}/bin:${PATH} |
| Aiden Grossman | d0b19cf | 2025-08-15 21:31:17 +0000 | [diff] [blame] | 85 | ENV CC=clang |
| 86 | ENV CXX=clang++ |
| Aiden Grossman | b86a22a | 2024-12-16 21:22:34 +0000 | [diff] [blame] | 87 | |
| 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. |
| 91 | RUN useradd gha -u 1001 -m -s /bin/bash |
| Aiden Grossman | 91ab10e | 2025-01-08 17:21:40 -0800 | [diff] [blame] | 92 | |
| 93 | # Also add the user to passwordless sudoers so that we can install software |
| 94 | # later on without having to rebuild the container. |
| 95 | RUN adduser gha sudo |
| 96 | RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers |
| 97 | |
| Aiden Grossman | b86a22a | 2024-12-16 21:22:34 +0000 | [diff] [blame] | 98 | USER gha |
| Aiden Grossman | d35d7f4b | 2025-01-20 11:53:25 -0800 | [diff] [blame] | 99 | WORKDIR /home/gha |
| 100 | |
| Baranov Victor | 08c057e | 2025-09-27 23:39:35 +0300 | [diff] [blame] | 101 | FROM ci-container AS ci-container-agent |
| Aiden Grossman | d35d7f4b | 2025-01-20 11:53:25 -0800 | [diff] [blame] | 102 | |
| Aiden Grossman | 52f32d7 | 2026-03-02 17:15:37 -0800 | [diff] [blame] | 103 | ENV GITHUB_RUNNER_VERSION=2.332.0 |
| Aiden Grossman | d35d7f4b | 2025-01-20 11:53:25 -0800 | [diff] [blame] | 104 | |
| 105 | RUN 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 Grossman | b86a22a | 2024-12-16 21:22:34 +0000 | [diff] [blame] | 110 | |