|
| 1 | +ARG LLVM_IMAGE=ghcr.io/ftsrg/cir-demo-llvm:latest |
| 2 | + |
| 3 | +# Allow copying LLVM from the prebuilt llvm image into this image. This way you |
| 4 | +# can build the LLVM image locally (tag it with the same name) and then build |
| 5 | +# the backend image on your machine without running the costly LLVM build in CI. |
| 6 | +FROM ${LLVM_IMAGE} AS llvm |
| 7 | + |
1 | 8 | FROM node:25-trixie |
2 | 9 |
|
3 | 10 | WORKDIR /app |
4 | 11 |
|
| 12 | +# Copy LLVM installation from the llvm image |
| 13 | + |
5 | 14 | RUN wget 'https://github.com/ftsrg/theta/releases/latest/download/Theta.zip' -O /app/Theta.zip \ |
6 | 15 | && unzip /app/Theta.zip \ |
7 | 16 | && rm /app/Theta.zip \ |
8 | 17 | && sed -i 's/export JAVA_VERSION=17/export JAVA_VERSION=21/g' /app/Theta/theta-start.sh |
9 | 18 |
|
10 | 19 | # copy package and source |
11 | 20 | COPY backend /app/backend |
| 21 | +COPY --from=llvm /opt/cir /app/backend/bin |
12 | 22 |
|
13 | 23 | WORKDIR /app/backend |
14 | 24 | RUN npm install --production |
15 | 25 |
|
16 | 26 | ENV DEBIAN_FRONTEND=noninteractive |
17 | 27 | RUN apt-get update \ |
18 | 28 | && apt-get install -y --no-install-recommends ca-certificates libstdc++6 \ |
19 | | - build-essential cmake ninja-build pkg-config python3 git \ |
| 29 | + build-essential cmake ninja-build pkg-config python3 git \ |
20 | 30 | openjdk-21-jdk-headless libgomp1 libmpfr-dev \ |
21 | | - clang lld |
22 | | - |
23 | | -# Build LLVM/ClangIR if backend/bin doesn't exist |
24 | | -# This checks if bin directory exists in the COPY context, and if not, builds LLVM |
25 | | -RUN if [ ! -d /app/backend/bin ]; then \ |
26 | | - cd /tmp && \ |
27 | | - git clone --depth=1 https://github.com/llvm/clangir.git && \ |
28 | | - cmake -S clangir/llvm -B build -GNinja \ |
29 | | - -DCLANG_ENABLE_CIR=ON \ |
30 | | - -DLLVM_ENABLE_PROJECTS="clang;mlir" \ |
31 | | - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ |
32 | | - -DLLVM_TARGETS_TO_BUILD=host \ |
33 | | - -DCMAKE_CXX_COMPILER=clang++ \ |
34 | | - -DCMAKE_C_COMPILER=clang \ |
35 | | - -DLLVM_USE_LINKER=lld \ |
36 | | - -DBUILD_SHARED_LIBS=ON \ |
37 | | - -DCMAKE_INSTALL_PREFIX=/app/backend/bin \ |
38 | | - -DLLVM_FORCE_VC_REVISION=$(head -c7 /tmp/clangir/.git/refs/heads/main)-zorn && \ |
39 | | - cmake --build build -j$(nproc) && \ |
40 | | - cmake --install build && \ |
41 | | - cd / && rm -rf /tmp/clangir /tmp/build; \ |
42 | | - fi |
| 31 | + && rm -rf /var/lib/apt/lists/* |
43 | 32 |
|
44 | 33 | # Build the xcfa-mapper C++ tool so the backend can call it. We copy the |
45 | 34 | # source tree and invoke CMake to produce the binary at xcfa-mapper/build/xcfa-mapper |
|
0 commit comments