-
Notifications
You must be signed in to change notification settings - Fork 398
/
Dockerfile_ubuntu_apt
62 lines (54 loc) · 2.33 KB
/
Dockerfile_ubuntu_apt
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
# =============================================================================
# An Ubuntu docker file for llvm-tutor that installs LLVM via apt. Clones and
# builds llvm-tutor, runs all tests. It uses the precompiled LLVM packages from
# Ubuntu.
#
# USAGE:
# ```bash
# wget https://raw.githubusercontent.com/banach-space/llvm-tutor/main/Dockerfile_ubuntu_apt
# docker build -t=llvm-tutor:llvm-18 .
# docker run --rm -it --hostname=llvm-tutor llvm-tutor:llvm-18 /bin/bash
# ```
# =============================================================================
FROM ubuntu:22.04
ENV LLVM_DIR /usr/lib/llvm-18/
ENV TUTOR_DIR /llvm-tutor
# 1. INSTALL DEPENDENCIES
# As `tzdata` gets installed automatically (AFAIK, Python depends on it), it
# will interrupt the set-up with a question about the time-zone to use. However,
# this is a non-interactive sessions and that won't work. Work around it by
# setting the time-zone here.
ENV TZ=Europe/London
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
RUN apt-get update && apt-get install -y \
git \
cmake \
ninja-build \
build-essential \
python3-minimal python3-pip\
wget \
libzstd-dev \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
RUN apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main"
RUN apt-get update
RUN apt-get install -y llvm-18 llvm-18-dev llvm-18-tools clang-18
RUN apt-get install -y python3-setuptools
# 2. INSTALL LIT
RUN pip3 install lit
# 3. CLONE LLVM-TUTOR
RUN git clone https://github.com/banach-space/llvm-tutor $TUTOR_DIR
# 4. BUILD AND RUN HELLO-WORLD
RUN mkdir -p $TUTOR_DIR/hello-world-build \
&& cd $TUTOR_DIR/hello-world-build \
&& cmake -G Ninja -DLT_LLVM_INSTALL_DIR=$LLVM_DIR ../HelloWorld \
&& ninja
RUN cd $TUTOR_DIR/hello-world-build && /usr/bin/clang-18 -S -O1 -emit-llvm ../inputs/input_for_hello.c -o input_for_hello.ll
RUN cd $TUTOR_DIR/hello-world-build && /usr/bin/opt-18 -load-pass-plugin ./libHelloWorld.so -passes=hello-world -disable-output input_for_hello.ll 2>&1 | grep "(llvm-tutor) Hello from: foo"
# 5. BUILD AND RUN LLVM-TUTOR
RUN mkdir -p $TUTOR_DIR/build \
&& cd $TUTOR_DIR/build \
&& cmake -DLT_LLVM_INSTALL_DIR=$LLVM_DIR ../ \
&& make -j $(nproc --all) \
&& lit test/