forked from onnx/onnx-mlir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile.llvm-project
103 lines (96 loc) · 4.64 KB
/
Dockerfile.llvm-project
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# By default, use ubuntu:jammy, remember to change Jenkins build script as well
ARG BASE_IMAGE="ubuntu:jammy"
FROM ${BASE_IMAGE}
# Label the image for various checking and cleanup
ARG LLVM_PROJECT_SHA1
ARG LLVM_PROJECT_SHA1_DATE
ARG LLVM_PROJECT_DOCKERFILE_SHA1
ARG ONNX_MLIR_PR_NUMBER
ARG ONNX_MLIR_PR_NUMBER2
LABEL llvm_project_sha1=${LLVM_PROJECT_SHA1}
LABEL llvm_project_sha1_date=${LLVM_PROJECT_SHA1_DATE}
LABEL llvm_project_dockerfile_sha1=${LLVM_PROJECT_DOCKERFILE_SHA1}
LABEL onnx_mlir_pr_number=${ONNX_MLIR_PR_NUMBER}
LABEL onnx_mlir_pr_number2=${ONNX_MLIR_PR_NUMBER2}
ARG NPROC=4
ARG WORK_DIR=/workdir
WORKDIR ${WORK_DIR}
# Install tools needed
RUN distro=$(cat /etc/os-release|grep -Po '(?<=^ID=").*(?=")|(?<=^ID=)[^"].*[^"]') \
&& TZ="America/New_York" \
&& if [ "${distro}" = "debian" ] || [ "${distro}" = "ubuntu" ]; then \
DEBIAN_FRONTEND=noninteractive && \
apt-get update -qq && \
apt-get install -qq -y --no-install-recommends tzdata && \
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
dpkg-reconfigure -f noninteractive tzdata && \
apt-get install -qq -y --no-install-recommends \
autoconf automake ca-certificates clang cmake cppcheck \
curl default-jdk-headless gcc g++ git libncurses-dev \
libtool make maven ninja-build openjdk-11-jdk-headless \
python3 python3-dev python3-distutils python3-numpy \
python3-pip python3-pytest-xdist python3-setuptools \
python3-typing-extensions zlib1g-dev && \
rm -rf /var/lib/apt/lists/* && \
ln -sf /usr/bin/pytest-3 /usr/bin/pytest; \
elif [ "${distro}" = "rhel" ] || [ "${distro}" = "fedora" ]; then \
ln -sf /usr/share/zoneinfo/${TZ} /etc/localtime && \
([ -x /usr/bin/microdnf ] && microdnf install -y yum) && \
RHEL_VERSION=$(grep CPE_NAME /etc/os-release | cut -d':' -f5) && \
yum install -q -y \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-${RHEL_VERSION}.noarch.rpm && \
yum update -q -y && \
yum install -q -y \
autoconf automake ca-certificates clang cmake diffutils \
file java-11-openjdk-devel java-11-openjdk-headless \
gcc gcc-c++ git libtool make ncurses-devel \
python39 python39-devel python39-numpy python39-pip \
python39-setuptools python39-wheel tzdata-java zlib-devel && \
# Use same versions as those in ubuntu:jammy
pip3 install -q \
Cython pytest==6.2.5 pytest-forked==1.4.0 \
pytest-xdist==2.5.0 typing-extensions==3.10.0.2 && \
rm -rf /var/cache/dnf/* && \
# Install ninja
git clone -b v1.10.2 https://github.com/ninja-build/ninja.git && \
cd ninja && mkdir -p build && cd build && \
cmake .. && \
make -j${NPROC} install && \
cd ${WORK_DIR} && rm -rf ninja; \
fi \
&& ln -sf /usr/bin/python3 /usr/bin/python
# Install protobuf
ARG PROTOBUF_VERSION=3.20.3
RUN git clone -b v${PROTOBUF_VERSION} --recursive https://github.com/protocolbuffers/protobuf.git \
&& cd protobuf && ./autogen.sh \
&& ./configure --enable-static=no \
&& make -j${NPROC} install && ldconfig \
&& cd python && python3 setup.py install --cpp_implementation \
&& cd ../.. && rm -rf protobuf
# Install jsoniter
ARG JSONITER_VERSION=0.9.23
RUN JSONITER_URL=https://repo1.maven.org/maven2/com/jsoniter/jsoniter/${JSONITER_VERSION} \
&& JSONITER_FILE=jsoniter-${JSONITER_VERSION}.jar \
&& curl -s ${JSONITER_URL}/${JSONITER_FILE} -o /usr/share/java/${JSONITER_FILE}
# Clone and build llvm-project and run tests
ARG BUILD_SHARED_LIBS=OFF
RUN git clone -n https://github.com/llvm/llvm-project.git \
&& cd llvm-project \
&& git checkout ${LLVM_PROJECT_SHA1} \
&& mkdir -p build && cd build \
# Build with clang since gcc on ppc64le doesn't support __builtin_thread_pointer
&& CC=clang CXX=clang++ \
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_TARGETS_TO_BUILD="host" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS} \
&& cmake --build . --parallel ${NPROC} -- ${MAKEFLAGS} \
&& (cmake --build . --parallel ${NPROC} --target check-mlir || \
[ "$(uname -m)" = "s390x" ]) \
&& rm -rf /tmp/* \
&& echo "llvm-project commit $(git rev-parse HEAD) successfully built"
LABEL llvm_project_successfully_built=yes