forked from pointblank-club/oaas
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile.test
More file actions
118 lines (91 loc) · 3.69 KB
/
Dockerfile.test
File metadata and controls
118 lines (91 loc) · 3.69 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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
FROM ubuntu:22.04
ENV DEBIAN_FRONTEND=noninteractive
# ============================================================================
# STAGE 1: Install build dependencies
# ============================================================================
RUN apt-get update && apt-get install -y \
build-essential \
cmake \
ninja-build \
git \
python3 \
python3-pip \
wget \
curl \
gnupg \
lsb-release \
software-properties-common \
libssl-dev \
openssl \
binutils \
file \
zlib1g-dev \
libtinfo-dev \
libxml2-dev \
&& rm -rf /var/lib/apt/lists/*
# ============================================================================
# STAGE 2: Build LLVM/Clang/MLIR with ClangIR (CIR) support
# ============================================================================
WORKDIR /opt
RUN git clone --depth=1 https://github.com/llvm/llvm-project.git llvm-project
WORKDIR /opt/llvm-project/build
RUN cmake ../llvm \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang;mlir" \
-DLLVM_TARGETS_TO_BUILD="X86" \
-DLLVM_ENABLE_ASSERTIONS=OFF \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_ENABLE_EH=ON \
-DLLVM_BUILD_EXAMPLES=OFF \
-DLLVM_BUILD_TESTS=OFF \
-DLLVM_BUILD_BENCHMARKS=OFF \
-DLLVM_BUILD_DOCS=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_DOCS=OFF \
-DCLANG_ENABLE_CIR=ON \
-DCMAKE_INSTALL_PREFIX=/usr/local/llvm
RUN ninja clang llvm-config mlir-opt mlir-translate opt llc FileCheck count not 2>&1 | tail -100
RUN ninja cir-opt 2>/dev/null || echo "cir-opt not available"
RUN ninja install 2>&1 | tail -20
# ============================================================================
# STAGE 3: Cleanup to save space
# ============================================================================
WORKDIR /opt
RUN rm -rf /opt/llvm-project/build /opt/llvm-project/.git
# ============================================================================
# STAGE 4: Set up environment
# ============================================================================
ENV PATH="/usr/local/llvm/bin:${PATH}"
ENV LD_LIBRARY_PATH="/usr/local/llvm/lib:${LD_LIBRARY_PATH}"
ENV LLVM_DIR="/usr/local/llvm/lib/cmake/llvm"
ENV MLIR_DIR="/usr/local/llvm/lib/cmake/mlir"
RUN echo '#!/bin/bash\nexec clang -fclangir "$@"' > /usr/local/bin/clangir && chmod +x /usr/local/bin/clangir
# ============================================================================
# STAGE 5: Verify installation
# ============================================================================
RUN clang --version && mlir-opt --version && mlir-translate --version
RUN echo 'int main() { return 0; }' > /tmp/test.c && \
(clang -fclangir -emit-cir /tmp/test.c -o /tmp/test.cir && echo "ClangIR works!" && cat /tmp/test.cir) || \
echo "ClangIR not available"
# ============================================================================
# STAGE 6: Copy project and build MLIR obfuscation passes
# ============================================================================
WORKDIR /app
COPY . .
WORKDIR /app/mlir-obs
RUN mkdir -p build && cd build && \
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release \
-DLLVM_DIR=/usr/local/llvm/lib/cmake/llvm \
-DMLIR_DIR=/usr/local/llvm/lib/cmake/mlir && \
ninja
RUN ls -la /app/mlir-obs/build/lib/
# ============================================================================
# STAGE 7: Install Python dependencies
# ============================================================================
WORKDIR /app/cmd/llvm-obfuscator
RUN pip3 install --no-cache-dir typer pyyaml || pip3 install typer pyyaml
WORKDIR /app
CMD ["/bin/bash"]