Skip to content

Commit 5136c6d

Browse files
authored
[Tools][Docker] Update Dockerfiles and Docker guide (#123841)
Fixes #123669 - Update Dockerfiles to work with the LLVM trunk - Adapt Documentation accordingly - Fix duplicate `-c` flag
1 parent fbd86d0 commit 5136c6d

File tree

6 files changed

+43
-49
lines changed

6 files changed

+43
-49
lines changed

llvm/docs/Docker.rst

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can find a number of sources to build docker images with LLVM components in
99
images for their own use, or as a starting point for someone who wants to write
1010
their own Dockerfiles.
1111

12-
We currently provide Dockerfiles with ``debian10`` and ``nvidia-cuda`` base images.
12+
We currently provide Dockerfiles with ``debian12`` and ``nvidia-cuda`` base images.
1313
We also provide an ``example`` image, which contains placeholders that one would need
1414
to fill out in order to produce Dockerfiles for a new docker image.
1515

@@ -72,13 +72,13 @@ checkout from git and provide a list of CMake arguments to use during when
7272
building LLVM inside docker container.
7373

7474
Here's a very simple example of getting a docker image with clang binary,
75-
compiled by the system compiler in the debian10 image:
75+
compiled by the system compiler in the debian12 image:
7676

7777
.. code-block:: bash
7878
7979
./llvm/utils/docker/build_docker_image.sh \
80-
--source debian10 \
81-
--docker-repository clang-debian10 --docker-tag "staging" \
80+
--source debian12 \
81+
--docker-repository clang-debian12 --docker-tag "staging" \
8282
-p clang -i install-clang -i install-clang-resource-headers \
8383
-- \
8484
-DCMAKE_BUILD_TYPE=Release
@@ -93,51 +93,45 @@ this command will do that:
9393
# LLVM_TARGETS_TO_BUILD=Native is to reduce stage1 compile time.
9494
# Options, starting with BOOTSTRAP_* are passed to stage2 cmake invocation.
9595
./build_docker_image.sh \
96-
--source debian10 \
97-
--docker-repository clang-debian10 --docker-tag "staging" \
96+
--source debian12 \
97+
--docker-repository clang-debian12 --docker-tag "staging" \
9898
-p clang -i stage2-install-clang -i stage2-install-clang-resource-headers \
9999
-- \
100100
-DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
101101
-DBOOTSTRAP_CMAKE_BUILD_TYPE=Release \
102102
-DCLANG_ENABLE_BOOTSTRAP=ON -DCLANG_BOOTSTRAP_TARGETS="install-clang;install-clang-resource-headers"
103103
104-
This will produce a new image ``clang-debian10:staging`` from the latest
104+
This will produce a new image ``clang-debian12:staging`` from the latest
105105
upstream revision.
106106
After the image is built you can run bash inside a container based on your image
107107
like this:
108108

109109
.. code-block:: bash
110110
111-
docker run -ti clang-debian10:staging bash
111+
docker run -ti clang-debian12:staging bash
112112
113113
Now you can run bash commands as you normally would:
114114

115115
.. code-block:: bash
116116
117117
root@80f351b51825:/# clang -v
118-
clang version 5.0.0 (trunk 305064)
118+
clang version 19.1.7 (trunk 524462)
119+
Target: x86_64-unknown-linux-gnu
119120
Target: x86_64-unknown-linux-gnu
120121
Thread model: posix
121122
InstalledDir: /bin
122-
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8
123-
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.8.4
124-
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
125-
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9.2
126-
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.9
127-
Candidate multilib: .;@m64
128-
Selected multilib: .;@m64
129123
130124
131125
Which image should I choose?
132126
============================
133-
We currently provide two images: Debian10-based and nvidia-cuda-based. They
127+
We currently provide two images: Debian12-based and nvidia-cuda-based. They
134128
differ in the base image that they use, i.e. they have a different set of
135129
preinstalled binaries. Debian8 is very minimal, nvidia-cuda is larger, but has
136130
preinstalled CUDA libraries and allows to access a GPU, installed on your
137131
machine.
138132

139133
If you need a minimal linux distribution with only clang and libstdc++ included,
140-
you should try Debian10-based image.
134+
you should try Debian12-based image.
141135

142136
If you want to use CUDA libraries and have access to a GPU on your machine,
143137
you should choose nvidia-cuda-based image and use `nvidia-docker
@@ -150,20 +144,20 @@ If you have a different use-case, you could create your own image based on
150144
``example/`` folder.
151145

152146
Any docker image can be built and run using only the docker binary, i.e. you can
153-
run debian10 build on Fedora or any other Linux distribution. You don't need to
147+
run debian12 build on Fedora or any other Linux distribution. You don't need to
154148
install CMake, compilers or any other clang dependencies. It is all handled
155149
during the build process inside Docker's isolated environment.
156150

157151
Stable build
158152
============
159153
If you want a somewhat recent and somewhat stable build, use the
160154
``branches/google/stable`` branch, i.e. the following command will produce a
161-
Debian10-based image using the latest ``google/stable`` sources for you:
155+
Debian12-based image using the latest ``google/stable`` sources for you:
162156

163157
.. code-block:: bash
164158
165159
./llvm/utils/docker/build_docker_image.sh \
166-
-s debian10 --d clang-debian10 -t "staging" \
160+
-s debian12 --d clang-debian12 -t "staging" \
167161
--branch branches/google/stable \
168162
-p clang -i install-clang -i install-clang-resource-headers \
169163
-- \

llvm/utils/docker/build_docker_image.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Available options:
2323
General:
2424
-h|--help show this help message
2525
Docker-specific:
26-
-s|--source image source dir (i.e. debian10, nvidia-cuda, etc)
26+
-s|--source image source dir (i.e. debian12, nvidia-cuda, etc)
2727
-d|--docker-repository docker repository for the image
2828
-t|--docker-tag docker tag for the image
2929
Checkout arguments:
@@ -38,7 +38,7 @@ Available options:
3838
-p|--llvm-project Add the project to a list LLVM_ENABLE_PROJECTS, passed to
3939
CMake.
4040
Can be specified multiple times.
41-
-c|--checksums name of a file, containing checksums of llvm checkout.
41+
--checksums name of a file, containing checksums of llvm checkout.
4242
Script will fail if checksums of the checkout do not
4343
match.
4444
Build-specific:
@@ -51,18 +51,18 @@ Required options: --source and --docker-repository, at least one
5151
All options after '--' are passed to CMake invocation.
5252
5353
For example, running:
54-
$ build_docker_image.sh -s debian10 -d mydocker/debian10-clang -t latest \
54+
$ build_docker_image.sh -s debian12 -d mydocker/debian12-clang -t latest \
5555
-p clang -i install-clang -i install-clang-resource-headers
5656
will produce two docker images:
57-
mydocker/debian10-clang-build:latest - an intermediate image used to compile
57+
mydocker/debian12-clang-build:latest - an intermediate image used to compile
5858
clang.
59-
mydocker/clang-debian10:latest - a small image with preinstalled clang.
59+
mydocker/clang-debian12:latest - a small image with preinstalled clang.
6060
Please note that this example produces a not very useful installation, since it
6161
doesn't override CMake defaults, which produces a Debug and non-boostrapped
6262
version of clang.
6363
6464
To get a 2-stage clang build, you could use this command:
65-
$ ./build_docker_image.sh -s debian10 -d mydocker/clang-debian10 -t "latest" \
65+
$ ./build_docker_image.sh -s debian12 -d mydocker/clang-debian12 -t "latest" \
6666
-p clang -i stage2-install-clang -i stage2-install-clang-resource-headers \
6767
-- \
6868
-DLLVM_TARGETS_TO_BUILD=Native -DCMAKE_BUILD_TYPE=Release \
@@ -110,7 +110,7 @@ while [[ $# -gt 0 ]]; do
110110
CMAKE_ENABLED_PROJECTS="$CMAKE_ENABLED_PROJECTS;$PROJ"
111111
shift 2
112112
;;
113-
-c|--checksums)
113+
--checksums)
114114
shift
115115
CHECKSUMS_FILE="$1"
116116
shift
@@ -160,7 +160,7 @@ if [ $SEEN_INSTALL_TARGET -eq 0 ]; then
160160
exit 1
161161
fi
162162

163-
SOURCE_DIR=$(dirname $0)
163+
SOURCE_DIR=$(dirname "$0")
164164
if [ ! -d "$SOURCE_DIR/$IMAGE_SOURCE" ]; then
165165
echo "No sources for '$IMAGE_SOURCE' were found in $SOURCE_DIR"
166166
exit 1

llvm/utils/docker/debian10/Dockerfile renamed to llvm/utils/docker/debian12/Dockerfile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#===- llvm/utils/docker/debian10/build/Dockerfile -------------------------===//
1+
#===- llvm/utils/docker/debian12/build/Dockerfile -------------------------===//
22
#
33
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
# See https://llvm.org/LICENSE.txt for license information.
55
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
66
#
77
#===----------------------------------------------------------------------===//
88
# Stage 1. Check out LLVM source code and run the build.
9-
FROM launcher.gcr.io/google/debian10:latest as builder
10-
LABEL maintainer "LLVM Developers"
9+
FROM launcher.gcr.io/google/debian12:latest AS builder
10+
LABEL maintainer="LLVM Developers"
1111
# Install build dependencies of llvm.
1212
# First, Update the apt's source list and include the sources of the packages.
1313
RUN grep deb /etc/apt/sources.list | \
@@ -19,8 +19,8 @@ RUN apt-get update && \
1919
rm -rf /var/lib/apt/lists/*
2020
# Install a newer ninja release. It seems the older version in the debian repos
2121
# randomly crashes when compiling llvm.
22-
RUN wget "https://github.com/ninja-build/ninja/releases/download/v1.8.2/ninja-linux.zip" && \
23-
echo "d2fea9ff33b3ef353161ed906f260d565ca55b8ca0568fa07b1d2cab90a84a07 ninja-linux.zip" \
22+
RUN wget "https://github.com/ninja-build/ninja/releases/download/v1.12.1/ninja-linux.zip" && \
23+
echo "6f98805688d19672bd699fbbfa2c2cf0fc054ac3df1f0e6a47664d963d530255 ninja-linux.zip" \
2424
| sha256sum -c && \
2525
unzip ninja-linux.zip -d /usr/local/bin && \
2626
rm ninja-linux.zip
@@ -37,11 +37,11 @@ RUN /tmp/scripts/build_install_llvm.sh --to /tmp/clang-install ${buildscript_arg
3737

3838

3939
# Stage 2. Produce a minimal release image with build results.
40-
FROM launcher.gcr.io/google/debian10:latest
41-
LABEL maintainer "LLVM Developers"
40+
FROM launcher.gcr.io/google/debian12:latest
41+
LABEL maintainer="LLVM Developers"
4242
# Install packages for minimal useful image.
4343
RUN apt-get update && \
44-
apt-get install -y --no-install-recommends libstdc++-7-dev binutils && \
44+
apt-get install -y --no-install-recommends binutils && \
4545
rm -rf /var/lib/apt/lists/*
4646
# Copy build results of stage 1 to /usr/local.
4747
COPY --from=builder /tmp/clang-install/ /usr/local/

llvm/utils/docker/example/Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
# Stage 1. Check out LLVM source code and run the build.
1212
# FIXME: Replace 'ubuntu' with your base image
13-
FROM ubuntu as builder
13+
FROM ubuntu AS builder
1414
# FIXME: Change maintainer name
15-
LABEL maintainer "Maintainer <maintainer@email>"
15+
LABEL maintainer="Maintainer <maintainer@email>"
1616
# FIXME: Install llvm/clang build dependencies here. Including compiler to
1717
# build stage1, cmake, subversion, ninja, etc.
1818

@@ -31,7 +31,7 @@ RUN /tmp/scripts/build_install_llvm.sh --to /tmp/clang-install ${buildscript_arg
3131
# FIXME: Replace 'ubuntu' with your base image.
3232
FROM ubuntu
3333
# FIXME: Change maintainer name.
34-
LABEL maintainer "Maintainer <maintainer@email>"
34+
LABEL maintainer="Maintainer <maintainer@email>"
3535
# FIXME: Install all packages you want to have in your release container.
3636
# A minimal useful installation should include at least libstdc++ and binutils.
3737

llvm/utils/docker/nvidia-cuda/Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#
77
#===----------------------------------------------------------------------===//
88
# Stage 1. Check out LLVM source code and run the build.
9-
FROM nvidia/cuda:8.0-devel as builder
10-
LABEL maintainer "LLVM Developers"
9+
FROM nvidia/cuda:12.6.3-devel-ubuntu24.04 AS builder
10+
LABEL maintainer="LLVM Developers"
1111
# Install llvm build dependencies.
1212
RUN apt-get update && \
13-
apt-get install -y --no-install-recommends ca-certificates cmake python \
13+
apt-get install -y --no-install-recommends ca-certificates cmake 2to3 python-is-python3 \
1414
subversion ninja-build git && \
1515
rm -rf /var/lib/apt/lists/*
1616

@@ -26,8 +26,8 @@ RUN /tmp/scripts/build_install_llvm.sh --to /tmp/clang-install ${buildscript_arg
2626

2727

2828
# Stage 2. Produce a minimal release image with build results.
29-
FROM nvidia/cuda:8.0-devel
30-
LABEL maintainer "LLVM Developers"
29+
FROM nvidia/cuda:12.6.3-devel-ubuntu24.04
30+
LABEL maintainer="LLVM Developers"
3131
# Copy clang installation into this container.
3232
COPY --from=builder /tmp/clang-install/ /usr/local/
3333
# C++ standard library and binutils are already included in the base package.

llvm/utils/docker/scripts/checkout.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Checkout git sources into /tmp/clang-build/src. Used inside a docker container.
1818
Available options:
1919
-h|--help show this help message
2020
-b|--branch git branch to checkout, i.e. 'main',
21-
'release/10.x'
21+
'release/19.x'
2222
(default: 'main')
2323
-r|--revision git revision to checkout
2424
-c|--cherrypick revision to cherry-pick. Can be specified multiple times.
@@ -83,7 +83,7 @@ function apply_cherrypicks() {
8383
# This function is always called on a sorted list of cherrypicks.
8484
for CHERRY_REV in $CHERRYPICKS; do
8585
echo "Cherry-picking $CHERRY_REV into $CHECKOUT_DIR"
86-
EMAIL="[email protected]" git cherry-pick $CHERRY_REV
86+
EMAIL="[email protected]" git cherry-pick "$CHERRY_REV"
8787
done
8888

8989
popd
@@ -97,7 +97,7 @@ mkdir -p "$CLANG_BUILD_DIR/src"
9797
CHECKOUT_DIR="$CLANG_BUILD_DIR/src"
9898

9999
echo "Checking out https://github.com/llvm/llvm-project.git to $CHECKOUT_DIR"
100-
git clone -b $LLVM_BRANCH --single-branch \
100+
git clone -b "$LLVM_BRANCH" --single-branch \
101101
"https://github.com/llvm/llvm-project.git" \
102102
"$CHECKOUT_DIR"
103103

@@ -114,7 +114,7 @@ CHECKSUMS_FILE="/tmp/checksums/checksums.txt"
114114

115115
if [ -f "$CHECKSUMS_FILE" ]; then
116116
echo "Validating checksums for LLVM checkout..."
117-
python "$(dirname $0)/llvm_checksum/llvm_checksum.py" -c "$CHECKSUMS_FILE" \
117+
python "$(dirname "$0")/llvm_checksum/llvm_checksum.py" -c "$CHECKSUMS_FILE" \
118118
--partial --multi_dir "$CLANG_BUILD_DIR/src"
119119
else
120120
echo "Skipping checksumming checks..."

0 commit comments

Comments
 (0)