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 Docker and docs #332

Merged
merged 5 commits into from
Jan 17, 2024
Merged
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
8 changes: 3 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Choose your LLVM version
ARG LLVM_VERSION=14
ARG ARCH=amd64
ARG UBUNTU_VERSION=20.04
# Choose your LLVM version (only _some_ versions are supported)
ARG LLVM_VERSION=16
ARG UBUNTU_VERSION=22.04
ARG DISTRO_BASE=ubuntu${UBUNTU_VERSION}
ARG BUILD_BASE=ubuntu:${UBUNTU_VERSION}
ARG LIBRARIES=/opt/trailofbits
Expand All @@ -15,7 +14,6 @@ FROM ${BUILD_BASE} as base
# https://github.com/lifting-bits/cxx-common/blob/master/docker/Dockerfile.ubuntu.vcpkg
FROM ghcr.io/lifting-bits/cxx-common/vcpkg-builder-ubuntu-v2:${UBUNTU_VERSION} as deps
ARG UBUNTU_VERSION
ARG ARCH
ARG LLVM_VERSION
ARG LIBRARIES

Expand Down
16 changes: 7 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ Most of Rellic's dependencies can be provided by the [cxx-common](https://github
| [CMake](https://cmake.org/) | 3.21+ |
| [Google Flags](https://github.com/google/glog) | Latest |
| [Google Log](https://github.com/google/glog) | Latest |
| [LLVM](http://llvm.org/) | 14|
| [Clang](http://clang.llvm.org/) | 14|
| [LLVM](http://llvm.org/) | 16|
| [Clang](http://clang.llvm.org/) | 16|
| [Z3](https://github.com/Z3Prover/z3) | 4.7.1+ |

## Pre-made Docker Images
Expand Down Expand Up @@ -245,7 +245,7 @@ To try out Rellic you can do the following, given a LLVM bitcode file of your ch

```shell
# Create some sample bitcode or your own
clang-14 -emit-llvm -c ./tests/tools/decomp/issue_4.c -o ./tests/tools/decomp/issue_4.bc
clang-16 -emit-llvm -c ./tests/tools/decomp/issue_4.c -o ./tests/tools/decomp/issue_4.bc

./rellic-build/tools/rellic-decomp --input ./tests/tools/decomp/issue_4.bc --output /dev/stdout
```
Expand All @@ -271,15 +271,13 @@ make -j8

The Docker image should provide an environment which can set-up, build, and run rellic. The Docker images are parameterized by Ubuntu verison, LLVM version, and architecture.

To build the docker image using LLVM 16 for Ubuntu 22.04 on amd64 you can run the following command:
To build the docker image using LLVM 16 for Ubuntu 22.04 you can run the following command:

```sh
ARCH=amd64; UBUNTU=22.04; LLVM=16; docker build . \
-t rellic:llvm${LLVM}-ubuntu${UBUNTU}-${ARCH} \
UBUNTU=22.04; LLVM=16; docker build . \
-t rellic:llvm${LLVM}-ubuntu${UBUNTU} \
-f Dockerfile \
--platform linux/${ARCH}
--build-arg UBUNTU_VERSION=${UBUNTU} \
--build-arg ARCH=${ARCH} \
--build-arg LLVM_VERSION=${LLVM}
```

Expand All @@ -293,7 +291,7 @@ clang-16 -emit-llvm -c ./tests/tools/decomp/issue_4.c -o ./tests/tools/decomp/is
docker run --rm -t -i \
-v $(pwd):/test -w /test \
-u $(id -u):$(id -g) \
rellic:llvm16-ubuntu22.04-amd64 --input ./tests/tools/decomp/issue_4.bc --output /dev/stdout
rellic:llvm16-ubuntu22.04 --input ./tests/tools/decomp/issue_4.bc --output /dev/stdout
```

To explain the above command more:
Expand Down
63 changes: 12 additions & 51 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CURR_DIR=$( pwd )
BUILD_DIR="${CURR_DIR}/rellic-build"
INSTALL_DIR=/usr/local
LLVM_VERSION=llvm-16
CXX_COMMON_VERSION=v0.4.1
CXX_COMMON_VERSION=v0.6.4
OS_VERSION=unknown
ARCH_VERSION=unknown
BUILD_FLAGS=
Expand All @@ -33,42 +33,19 @@ function GetUbuntuOSVersion
source /etc/lsb-release

case "${DISTRIB_CODENAME}" in
groovy)
echo "[!] Ubuntu 20.10 is not supported; using libraries for Ubuntu 20.04 instead"
OS_VERSION=ubuntu-20.04
noble)
OS_VERSION=ubuntu-24.04
return 0
;;
jammy)
OS_VERSION=ubuntu-22.04
return 0
;;
focal)
OS_VERSION=ubuntu-20.04
return 0
;;
eoan)
echo "[!] Ubuntu 19.10 is not supported; using libraries for Ubuntu 18.04 instead"
OS_VERSION=ubuntu-18.04
return 0
;;
disco)
echo "[!] Ubuntu 19.04 is not supported; using libraries for Ubuntu 18.04 instead"
OS_VERSION=ubuntu-18.04
return 0
;;
cosmic)
echo "[!] Ubuntu 18.10 is not supported; using libraries for Ubuntu 18.04 instead"
OS_VERSION=ubuntu-18.04
return 0
;;
bionic)
OS_VERSION=ubuntu-18.04
return 0
;;
*)
echo "[x] Ubuntu ${DISTRIB_CODENAME} is not supported. Only jammy (22.04) are pre-compiled."
echo "[x] Please see https://github.com/lifting-bits/cxx-common to build dependencies from source."
return 1
echo "[x] Attempting to use Ubuntu 22.04 binaries"
OS_VERSION=ubuntu-22.04
;;
esac
}
Expand Down Expand Up @@ -147,12 +124,12 @@ function GetOSVersion
;;

*arch*)
OS_VERSION=ubuntu-18.04
OS_VERSION=ubuntu-22.04
return 0
;;

[Kk]ali)
OS_VERSION=ubuntu-18.04
OS_VERSION=ubuntu-22.04
return 0;
;;

Expand Down Expand Up @@ -183,12 +160,12 @@ function DownloadLibraries

#BUILD_FLAGS="${BUILD_FLAGS} -DCMAKE_OSX_SYSROOT=${sdk_root}"
# Min version supported
OS_VERSION="macos-12"
OS_VERSION="macos-13"
# Hard-coded to match pre-built binaries in CI
XCODE_VERSION="14.2"
if [[ "$(sw_vers -productVersion)" == "12."* ]]; then
echo "Found MacOS Monterey"
OS_VERSION="macos-12"
XCODE_VERSION="15.0"
if [[ "$(sw_vers -productVersion)" == "13."* ]]; then
echo "Found MacOS Ventura"
OS_VERSION="macos-13"
else
echo "WARNING: ****Likely unsupported MacOS Version****"
echo "WARNING: ****Using ${OS_VERSION}****"
Expand Down Expand Up @@ -326,22 +303,6 @@ function Package
function GetLLVMVersion
{
case ${1} in
12)
LLVM_VERSION=llvm-12
return 0
;;
13)
LLVM_VERSION=llvm-13
return 0
;;
14)
LLVM_VERSION=llvm-14
return 0
;;
15)
LLVM_VERSION=llvm-15
return 0
;;
16)
LLVM_VERSION=llvm-16
return 0
Expand Down
Loading