diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8acf8d3..1ce54de 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -25,9 +25,16 @@ RUN apt-get update && \ apt-get clean --yes && \ rm -rf /var/lib/apt/lists/* +# Install Docker +RUN curl -fsSL https://get.docker.com -o get-docker.sh \ + && sh get-docker.sh \ + && rm get-docker.sh + RUN apt-get -y purge llvm-14 clang-14 RUN pip3 install lit codespell jinja2 Pygments COPY ./install-llvm.sh /tmp/ RUN chmod +x /tmp/install-llvm.sh && /tmp/install-llvm.sh ${LLVM_VERSION} all + +RUN groupadd docker || true && usermod -aG docker root \ No newline at end of file diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f6bf695..a076ec2 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,8 +4,10 @@ "name": "C++", // to run local build of devcontainer "build": { "dockerfile": "./Dockerfile" }, - "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], - + "runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined", "--privileged"], + "mounts": [ + "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" + ], // Configure tool-specific properties. "customizations": { // Configure properties specific to VS Code. @@ -18,10 +20,15 @@ } }, - "remoteUser": "vscode", + "remoteUser": "root", "features": { "git": "os-provided", - "python": "os-provided" + "python": "os-provided", + "ghcr.io/devcontainers/features/docker-in-docker:2": { + "version": "latest", + "moby": true, + "dockerDashComposeVersion": "v2" + } }, "containerEnv": { "CMAKE_PREFIX_PATH": "/usr/lib/llvm-18/lib/cmake/mlir/;/usr/lib/llvm-18/lib/cmake/clang/", diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7ac45b3..d4e885a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,5 +54,59 @@ jobs: - name: Build ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }} run: cmake --build --preset ci --config ${{ matrix.build-type }} -j $(nproc) - - name: Test ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }} - run: ctest --preset ci --build-config ${{ matrix.build-type }} + #- name: Test ${{ matrix.build-type }} with sanitizers set ${{ matrix.sanitizers }} + # run: | + # cmake --preset ci + # ctest --preset ci --build-config ${{ matrix.build-type }} + test: + needs: build + strategy: + matrix: + llvm-version: [18] + image-version: [22.04] + build-type: [Release, Debug] + sanitizers: [ON, OFF] + runs-on: ubuntu-${{ matrix.image-version }} + env: + CMAKE_PREFIX_PATH: "/usr/lib/llvm-${{ matrix.llvm-version }}/lib/cmake/mlir/;/usr/lib/llvm-${{ matrix.llvm-version }}/lib/cmake/clang/" + LLVM_EXTERNAL_LIT: "/usr/local/bin/lit" + ENABLE_SANITIZER_UNDEFINED_BEHAVIOR: ${{ matrix.sanitizers }} + ENABLE_SANITIZER_ADDRESS: ${{ matrix.sanitizers }} + + steps: + - name: Clone the Patchestry repository + uses: actions/checkout@v4 + with: + submodules: true + fetch-depth: 1 + + - name: Install CTest dependencies + run: | + sudo apt-get update + sudo apt-get install -y \ + software-properties-common \ + ninja-build python3-pip \ + ccache cmake lld lcov \ + doxygen libzstd-dev + + curl -fsSL https://get.docker.com -o get-docker.sh \ + && sh get-docker.sh \ + && rm get-docker.sh + + sudo apt-get -y purge llvm-14 clang-14 + pip3 install lit codespell jinja2 Pygments + + curl -fsSL https://apt.llvm.org/llvm.sh -o llvm.sh && \ + chmod +x llvm.sh && \ + sudo ./llvm.sh ${{ matrix.llvm-version }} all && \ + rm llvm.sh + + sudo apt-get install libmlir-${{ matrix.llvm-version }}-dev mlir-${{ matrix.llvm-version }}-tools + sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++-${{ matrix.llvm-version }} 60 + sudo update-alternatives --install /usr/bin/cc cc /usr/bin/clang-${{ matrix.llvm-version }} 60 + sudo ln -s /usr/bin/FileCheck-${{ matrix.llvm-version }} /usr/bin/FileCheck + + - name: Run CTest + run: | + cmake --preset ci + ctest --preset ci --build-config ${{ matrix.build-type }} \ No newline at end of file diff --git a/scripts/ghidra/decompile-headless.sh b/scripts/ghidra/decompile-headless.sh index a64777d..c2602d9 100755 --- a/scripts/ghidra/decompile-headless.sh +++ b/scripts/ghidra/decompile-headless.sh @@ -39,4 +39,4 @@ docker run --rm \ -v $INPUT_PATH:/input \ -v $OUTPUT_PATH:/output \ trailofbits/patchestry-decompilation:latest \ - /input $FUNCTION_NAME /output \ No newline at end of file + /input $FUNCTION_NAME /output