Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update wheel build #1377

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 71 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,47 +1,90 @@
FROM --platform=linux/amd64 ubuntu:22.04
ARG DEBIAN_FRONTEND=noninteractive
FROM --platform=linux/amd64 ubuntu:24.04

COPY . /Triton

# libboost >= 1.68
# libpython >= 3.6
# llvm >= 12
RUN apt update && \
apt upgrade -y

# libboost >= 1.83
# libpython >= 3.12
# llvm >= 16.0
RUN DEBIAN_FRONTEND="noninteractive" \
apt install -y --no-install-suggests --no-install-recommends \
build-essential \
clang \
curl \
git \
libboost-all-dev \
libgmp-dev \
libpython3-dev \
libpython3-stdlib \
llvm-16 \
llvm-16-dev \
ninja-build \
pkg-config \
python3-pip \
python3-venv \
tar && \
apt clean

ENV VIRTUAL_ENV=/Triton-venv
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"

# cmake >= 3.20
RUN apt update && apt upgrade -y && apt install -y build-essential clang curl git libboost-all-dev libgmp-dev libpython3-dev libpython3-stdlib llvm-12 llvm-12-dev python3-pip tar ninja-build pkg-config && apt-get clean && pip install --upgrade pip && pip3 install Cython lief cmake meson
# libz3 >= 4.13.0
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install \
cmake \
lief \
meson \
setuptools \
unicorn==2.0.0 \
z3-solver

# libcapstone >= 5.0.x
RUN cd /tmp && \
curl -o cap.tgz -L https://github.com/aquynh/capstone/archive/5.0.1.tar.gz && \
tar xvf cap.tgz && cd capstone-5.0.1/ && CAPSTONE_ARCHS="arm aarch64 riscv x86" ./make.sh && \
make install && rm -rf /tmp/cap* \
&& ln -s /usr/lib/libcapstone.so.5 /usr/lib/x86_64-linux-gnu/libcapstone.so
RUN echo "[+] Download, build and install Capstone" && \
cd /tmp && \
curl -s -o capstone-5.0.1.tar.gz -L https://github.com/aquynh/capstone/archive/5.0.1.tar.gz && \
tar xf capstone-5.0.1.tar.gz && \
cd ./capstone-5.0.1 && \
CAPSTONE_ARCHS="arm aarch64 riscv x86" ./make.sh && \
make install

# libbitwuzla >= 0.4.0
RUN cd /tmp && \
RUN echo "[+] Download, build and install Bitwuzla" && \
cd /tmp && \
git clone https://github.com/bitwuzla/bitwuzla.git && \
cd bitwuzla && \
git checkout -b 0.4.0 0.4.0 && \
python3 ./configure.py --shared && \
cd build && \
ninja install && \
ldconfig
ninja -j$(nproc) install

# To test pre-releases 'pip install' the corresponding .whl from https://github.com/Z3Prover/z3/releases/tag/Nightly
# libz3 >= 4.6.0
RUN pip3 install z3-solver==4.8.14

RUN PYV=`python3 -c "import platform;print(f'3.{platform.python_version_tuple()[1]}')"` && \
RUN echo "[+] Build and install Triton" && \
Z3_PATH=$(python -c "import site; print(f'{site.getsitepackages()[0]}/z3')") && \
# Triton (LLVM for lifting; z3 or bitwuzla as SMT solver)
cd /Triton && mkdir /tmp/triton-build && cd /tmp/triton-build && cmake -DLLVM_INTERFACE=ON -DCMAKE_PREFIX_PATH=$(/usr/lib/llvm-12/bin/llvm-config --prefix) -DZ3_INTERFACE=ON -DZ3_INCLUDE_DIRS=/usr/local/lib/python$PYV/dist-packages/z3/include/ -DZ3_LIBRARIES=/usr/local/lib/python$PYV/dist-packages/z3/lib/libz3.so -DBITWUZLA_INTERFACE=ON -DBITWUZLA_INCLUDE_DIRS=/usr/local/include -DBITWUZLA_LIBRARIES=/usr/local/lib/x86_64-linux-gnu/libbitwuzla.so /Triton && make -j$(nproc) && make install
cd /Triton && \
mkdir /tmp/triton-build && \
cd /tmp/triton-build && \
cmake \
-DLLVM_INTERFACE=ON \
-DCMAKE_PREFIX_PATH=$(llvm-config-16 --prefix) \
-DZ3_INTERFACE=ON \
-DZ3_INCLUDE_DIRS=$Z3_PATH/include/ \
-DZ3_LIBRARIES=$Z3_PATH/lib/libz3.so \
-DBITWUZLA_INTERFACE=ON \
-DBITWUZLA_INCLUDE_DIRS=/usr/local/include \
-DBITWUZLA_LIBRARIES=/usr/local/lib/x86_64-linux-gnu/libbitwuzla.so \
/Triton && \
make -j$(nproc) && \
make install

RUN PYV=`python3 -c "import platform;print(f'3.{platform.python_version_tuple()[1]}')"` && \
PYP="/usr/lib/python$PYV/site-packages" && \
echo export PYTHONPATH="$PYP:\$PYTHONPATH" >> /etc/bash.bashrc && \
RUN echo "[+] Check Triton build" && \
echo export "PATH=$VIRTUAL_ENV/bin:$PATH" >> /etc/bash.bashrc && \
# Print z3 version.
python3 -c "import z3; print('Z3 version:', z3.get_version_string())" && \
# Next command fails if Triton has no z3 or bitwuzla support
PYTHONPATH="$PYP" python3 -c "from triton import *; ctx=TritonContext(ARCH.X86_64); ctx.setSolver(SOLVER.Z3); ctx.setSolver(SOLVER.BITWUZLA);"

# Dependencies required for testing
RUN pip install unicorn==2.0.0 lief
# Next command fails if Triton has no z3 or bitwuzla support.
python3 -c "from triton import *; ctx=TritonContext(ARCH.X86_64); ctx.setSolver(SOLVER.Z3); ctx.setSolver(SOLVER.BITWUZLA);"

ENTRYPOINT /bin/bash
6 changes: 5 additions & 1 deletion src/scripts/docker/build-wheel-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
#
# $ docker pull quay.io/pypa/manylinux_2_28_x86_64
# $ ./src/scripts/docker/build-docker-image.sh
# $ cd /tmp
# $ wget https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
# $ tar xf clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz
# $ cd -
# $ docker run \
# --rm \
# -v $(pwd):/src \
Expand Down Expand Up @@ -83,7 +87,7 @@ $PYTHON_BINARY -m build --wheel --outdir $WHEEL_DIR/linux_x86_64
# Build Triton Python wheel package for Python 3.13.
echo "[+] Build Triton wheel package for Python 3.13"
cd $SOURCE_DIR
export PYTHON_BINARY=/opt/_internal/cpython-3.13.0/bin/python
export PYTHON_BINARY=/opt/_internal/cpython-3.13.1/bin/python
export PYTHON_INCLUDE_DIRS=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])")
export PYTHON_LIBRARY=$($PYTHON_BINARY -c "from sysconfig import get_paths; print(get_paths()['include'])")

Expand Down
Loading