about summary refs log tree commit diff homepage
path: root/scripts/build/p-sanitizer-linux-ubuntu.inc
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2022-03-25 23:07:40 +0000
committerCristian Cadar <c.cadar@imperial.ac.uk>2022-03-30 12:18:59 +0100
commit0373fd7d10fb5b23c86ebec2e932ea8f059f5b71 (patch)
tree785721f0b4202b1d30fa77160368e969e12a4eaa /scripts/build/p-sanitizer-linux-ubuntu.inc
parent23548f09b7bff999b0b346a5511b2a316ec798b4 (diff)
downloadklee-0373fd7d10fb5b23c86ebec2e932ea8f059f5b71.tar.gz
Clearly separate between LLVM, a bitcode compiler, and sanitizer compiler
All three can be different but also provided by the same package.
By separating the different use-cases, it allows to set them
independently.
Diffstat (limited to 'scripts/build/p-sanitizer-linux-ubuntu.inc')
-rw-r--r--scripts/build/p-sanitizer-linux-ubuntu.inc46
1 files changed, 46 insertions, 0 deletions
diff --git a/scripts/build/p-sanitizer-linux-ubuntu.inc b/scripts/build/p-sanitizer-linux-ubuntu.inc
new file mode 100644
index 00000000..bb6187ea
--- /dev/null
+++ b/scripts/build/p-sanitizer-linux-ubuntu.inc
@@ -0,0 +1,46 @@
+install_binary_artifact_sanitizer() {
+  if [[ -z "${SANITIZER_BUILD:=}" ]]; then
+    return 1
+  fi
+
+  source "${DIR}/common-functions"
+  local SANITIZER_LLVM_VERSION_MAJOR="${SANITIZER_LLVM_VERSION/.*/}"
+  local SANITIZER_LLVM_VERSION_MINOR="${SANITIZER_LLVM_VERSION/*./}"
+
+  local version=""
+  [[ "${SANITIZER_LLVM_VERSION_MAJOR}" -le 6 ]] && version="-${SANITIZER_LLVM_VERSION}"
+  [[ "${SANITIZER_LLVM_VERSION_MAJOR}" -ge 7 ]] && version="-${SANITIZER_LLVM_VERSION_MAJOR}"
+
+  # Add certificate
+  with_sudo apt update -y
+  dependencies=(
+    ca-certificates
+    wget
+    lsb-release
+    gnupg
+  )
+
+  with_sudo apt -y --no-install-recommends install "${dependencies[@]}"
+  wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | with_sudo apt-key add -
+
+  # Add repository
+  codename="$(lsb_release --codename --short)"
+  apt_entry="deb http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}${version} main"
+  if [[ ! $(grep -rq "${apt_entry}" /etc/apt) ]]; then
+    echo "${apt_entry}" | with_sudo tee -a /etc/apt/sources.list
+    with_sudo apt update -y
+  fi
+
+  with_sudo apt update -y
+  dependencies=(
+    "llvm${version}"
+    "clang${version}"
+  )
+
+  #Install essential dependencies
+  with_sudo apt -y --no-install-recommends install "${dependencies[@]}" || return 1
+}
+
+get_docker_config_id_sanitizer() {
+  return 0
+}