-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
64 lines (54 loc) · 2.18 KB
/
Dockerfile
File metadata and controls
64 lines (54 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# ============================================================
# Builder stage: build & install LLVM + MLIR
# ============================================================
FROM debian:bookworm AS builder
ARG DEBIAN_FRONTEND=noninteractive
ARG LLVM_VERSION=21.1.4
ARG CMAKE_BUILD_PARALLEL_LEVEL=24
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates git build-essential python3 pkg-config \
cmake ninja-build clang lld zlib1g-dev libtinfo-dev libxml2-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /src
RUN git clone --depth=1 --branch "llvmorg-${LLVM_VERSION}" https://github.com/llvm/llvm-project.git
WORKDIR /src/llvm-project
RUN cmake -S llvm -B build -G Ninja \
-DLLVM_ENABLE_PROJECTS="mlir" \
-DLLVM_TARGETS_TO_BUILD="Native;NVPTX;AMDGPU" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DMLIR_ENABLE_CMAKE_PACKAGE=ON \
-DLLVM_ENABLE_ZLIB=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DLLVM_USE_LINKER=lld \
-DCMAKE_INSTALL_PREFIX=/opt/llvm-mlir \
&& cmake --build build \
&& cmake --install build
# ============================================================
# Runtime stage: tools + installed MLIR, non-root entrypoint
# ============================================================
FROM debian:bookworm
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates git build-essential python3 pkg-config \
cmake ninja-build clang lld zlib1g-dev libxml2-dev \
gosu \
&& rm -rf /var/lib/apt/lists/*
# Installed LLVM/MLIR
COPY --from=builder /opt/llvm-mlir /opt/llvm-mlir
# Workspace
WORKDIR /work
# Add entrypoint script
COPY --chown=root:root entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh
# Helpful defaults for downstream builds; entrypoint also exports these.
ENV CMAKE_PREFIX_PATH=/opt/llvm-mlir
ENV LD_LIBRARY_PATH=/opt/llvm-mlir/lib
ENV PATH=/opt/llvm-mlir/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
ENV CC=clang
ENV CXX=clang++
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
CMD ["bash"]