|
1 | | -# Choose your LLVM version |
2 | | -ARG LLVM_VERSION=17 |
3 | | -ARG UBUNTU_VERSION=24.04 |
4 | | -ARG DISTRO_BASE=ubuntu${UBUNTU_VERSION} |
5 | | -ARG BUILD_BASE=ubuntu:${UBUNTU_VERSION} |
6 | | -ARG LIBRARIES=/opt/trailofbits |
| 1 | +# Dockerfile for building remill with specific LLVM versions from apt.llvm.org |
| 2 | +# This approach supports newer LLVM versions (19, 22, etc.) |
7 | 3 |
|
| 4 | +ARG LLVM_VERSION=22 |
| 5 | +ARG UBUNTU_VERSION=24.04 |
8 | 6 |
|
9 | | -# Run-time dependencies go here |
10 | | -FROM ${BUILD_BASE} as base |
| 7 | +FROM ubuntu:${UBUNTU_VERSION} AS builder |
11 | 8 |
|
12 | | -# Build-time dependencies go here |
13 | | -# See here for full list of those dependencies |
14 | | -# https://github.com/lifting-bits/cxx-common/blob/master/docker/Dockerfile.ubuntu.vcpkg |
15 | | -FROM ghcr.io/lifting-bits/cxx-common/vcpkg-builder-ubuntu-v2:${UBUNTU_VERSION} as deps |
16 | | -ARG UBUNTU_VERSION |
17 | 9 | ARG LLVM_VERSION |
18 | | -ARG LIBRARIES |
| 10 | +ARG DEBIAN_FRONTEND=noninteractive |
19 | 11 |
|
20 | | -RUN apt-get update && \ |
21 | | - apt-get install -qqy python3 python3-pip libc6-dev wget liblzma-dev zlib1g-dev curl git build-essential ninja-build libselinux1-dev libbsd-dev ccache pixz xz-utils make rpm && \ |
22 | | - if [ "$(uname -m)" = "x86_64" ]; then dpkg --add-architecture i386 && apt-get update && apt-get install -qqy gcc-multilib g++-multilib zip zlib1g-dev:i386; fi && \ |
23 | | - rm -rf /var/lib/apt/lists/* |
| 12 | +# Install build dependencies |
| 13 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 14 | + lsb-release \ |
| 15 | + wget \ |
| 16 | + software-properties-common \ |
| 17 | + gnupg \ |
| 18 | + cmake \ |
| 19 | + ninja-build \ |
| 20 | + python-is-python3 \ |
| 21 | + python3-pip \ |
| 22 | + python3-setuptools \ |
| 23 | + python3-venv \ |
| 24 | + git \ |
| 25 | + ca-certificates \ |
| 26 | + && rm -rf /var/lib/apt/lists/* |
24 | 27 |
|
25 | | -# Source code build |
26 | | -FROM deps as build |
27 | | -ARG LLVM_VERSION |
| 28 | +# Install LLVM from apt.llvm.org |
| 29 | +RUN wget https://apt.llvm.org/llvm.sh && \ |
| 30 | + chmod +x llvm.sh && \ |
| 31 | + ./llvm.sh ${LLVM_VERSION} && \ |
| 32 | + apt-get install -y --no-install-recommends llvm-${LLVM_VERSION}-dev && \ |
| 33 | + rm -rf /var/lib/apt/lists/* llvm.sh |
| 34 | + |
| 35 | +# Set environment variables for build |
| 36 | +ENV LLVM_VERSION=${LLVM_VERSION} |
| 37 | +ENV CC=clang-${LLVM_VERSION} |
| 38 | +ENV CXX=clang++-${LLVM_VERSION} |
28 | 39 |
|
29 | 40 | WORKDIR /remill |
30 | | -COPY ./ ./ |
31 | 41 |
|
32 | | -RUN git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" && git config --global user.name "github-actions[bot]" |
| 42 | +# Copy source code |
| 43 | +COPY . . |
| 44 | + |
| 45 | +# Configure git (needed for version detection) |
| 46 | +RUN git config --global user.email "docker@remill.local" && \ |
| 47 | + git config --global user.name "Docker Build" && \ |
| 48 | + git config --global --add safe.directory /remill |
| 49 | + |
| 50 | +# Get LLVM prefix |
| 51 | +RUN echo "LLVM_PREFIX=$(llvm-config-${LLVM_VERSION} --prefix)" > /tmp/llvm_env |
| 52 | + |
| 53 | +# Build dependencies (XED, etc.) |
| 54 | +RUN . /tmp/llvm_env && \ |
| 55 | + cmake -G Ninja -S dependencies -B dependencies/build \ |
| 56 | + -DUSE_EXTERNAL_LLVM=ON \ |
| 57 | + "-DCMAKE_PREFIX_PATH=${LLVM_PREFIX}" && \ |
| 58 | + cmake --build dependencies/build |
33 | 59 |
|
34 | | -RUN ./scripts/build.sh \ |
35 | | - --llvm-version ${LLVM_VERSION} \ |
36 | | - --prefix /opt/trailofbits \ |
37 | | - --extra-cmake-args "-DCMAKE_BUILD_TYPE=Release" \ |
38 | | - --disable-package |
| 60 | +# Setup Python venv for tests |
| 61 | +RUN python3 -m venv /opt/venv && \ |
| 62 | + /opt/venv/bin/pip install --no-cache-dir scripts/diff_tester_export_insns |
39 | 63 |
|
40 | | -RUN pip3 install ./scripts/diff_tester_export_insns |
| 64 | +# Build remill |
| 65 | +RUN . /tmp/llvm_env && \ |
| 66 | + . /opt/venv/bin/activate && \ |
| 67 | + cmake -G Ninja -B build \ |
| 68 | + "-DCMAKE_PREFIX_PATH=${LLVM_PREFIX};/remill/dependencies/install" \ |
| 69 | + "-DCMAKE_INSTALL_PREFIX=/opt/remill" \ |
| 70 | + -DCMAKE_BUILD_TYPE=Release && \ |
| 71 | + cmake --build build |
41 | 72 |
|
42 | | -# NOTE: At time of writing, tests only pass on x86_64 architecture |
43 | | -RUN cd remill-build && \ |
44 | | - cmake --build . --target test_dependencies -- -j $(nproc) && \ |
45 | | - CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --verbose --target test -- -j $(nproc) || [ "$(uname -m)" != "x86_64" ] && \ |
46 | | - cmake --build . --target install |
| 73 | +# Run tests |
| 74 | +RUN cmake --build build --target test_dependencies && \ |
| 75 | + env CTEST_OUTPUT_ON_FAILURE=1 cmake --build build --target test |
| 76 | + |
| 77 | +# Install |
| 78 | +RUN cmake --install build |
| 79 | + |
| 80 | +# Runtime image |
| 81 | +FROM ubuntu:${UBUNTU_VERSION} AS runtime |
47 | 82 |
|
48 | | -# Small installation image |
49 | | -FROM base as install |
50 | 83 | ARG LLVM_VERSION |
| 84 | +ARG DEBIAN_FRONTEND=noninteractive |
| 85 | + |
| 86 | +# Install runtime dependencies |
| 87 | +RUN apt-get update && apt-get install -y --no-install-recommends \ |
| 88 | + wget \ |
| 89 | + gnupg \ |
| 90 | + lsb-release \ |
| 91 | + software-properties-common \ |
| 92 | + ca-certificates \ |
| 93 | + && wget https://apt.llvm.org/llvm.sh \ |
| 94 | + && chmod +x llvm.sh \ |
| 95 | + && ./llvm.sh ${LLVM_VERSION} \ |
| 96 | + && apt-get install -y --no-install-recommends llvm-${LLVM_VERSION} \ |
| 97 | + && rm -rf /var/lib/apt/lists/* llvm.sh |
| 98 | + |
| 99 | +# Copy remill installation |
| 100 | +COPY --from=builder /opt/remill /opt/remill |
| 101 | + |
| 102 | +# Set environment |
| 103 | +ENV LLVM_VERSION=${LLVM_VERSION} |
| 104 | +ENV PATH="/opt/remill/bin:${PATH}" |
| 105 | + |
| 106 | +# Create entrypoint script |
| 107 | +RUN echo '#!/bin/sh\nexec remill-lift-'${LLVM_VERSION}' "$@"' > /usr/local/bin/entrypoint.sh && \ |
| 108 | + chmod +x /usr/local/bin/entrypoint.sh |
51 | 109 |
|
52 | | -COPY --from=build /opt/trailofbits /opt/trailofbits |
53 | | -COPY scripts/docker-lifter-entrypoint.sh /opt/trailofbits |
54 | | -ENV LLVM_VERSION=llvm${LLVM_VERSION} \ |
55 | | - PATH=/opt/trailofbits/bin |
56 | | -ENTRYPOINT ["/opt/trailofbits/docker-lifter-entrypoint.sh"] |
| 110 | +ENTRYPOINT ["/usr/local/bin/entrypoint.sh"] |
0 commit comments