about summary refs log tree commit diff homepage
path: root/scripts
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2020-09-24 21:20:15 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2020-09-30 16:34:47 +0100
commitabec20c8cf805c4b2835608d561111da6e2e800f (patch)
treea195da202adc461f814aab276dbb5342b1f3da8d /scripts
parent2fad33172fc5e7f5e03f7b7e4c753f7b2330bc0f (diff)
downloadklee-abec20c8cf805c4b2835608d561111da6e2e800f.tar.gz
Fix check if LLVM is installed
Diffstat (limited to 'scripts')
-rw-r--r--scripts/build/p-llvm-linux-ubuntu.inc46
1 files changed, 43 insertions, 3 deletions
diff --git a/scripts/build/p-llvm-linux-ubuntu.inc b/scripts/build/p-llvm-linux-ubuntu.inc
index 98fe9abe..ef055583 100644
--- a/scripts/build/p-llvm-linux-ubuntu.inc
+++ b/scripts/build/p-llvm-linux-ubuntu.inc
@@ -81,10 +81,20 @@ install_binary_artifact_llvm() {
 
 # Check if the binary artifact is installed
 is_installed_llvm() {
+    local version=""
+    local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
+    local LLVM_VERSION_MINOR="${LLVM_VERSION/*./}"
+    [[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="${LLVM_VERSION}"
+    [[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="${LLVM_VERSION_MAJOR}"
     local lc=""
-    # Check if llvm-config with the right version exists    
-    lc=$(which "llvm-config-${LLVM_VERSION}")
-    
+
+    # Check for llvm-config without suffix but correct versions number
+    lc=$(which "llvm-config")
+    if [[ -z "${lc}" || $($lc --version) != "${LLVM_VERSION}"* ]]; then
+      # Check if llvm-config with the right version exists
+      lc=$(which "llvm-config-${version}")
+    fi
+
     [[ -z "${lc}" ]] && return 1
 
     local rtti
@@ -98,3 +108,33 @@ is_installed_llvm() {
     [[ $(to_bool "${REQUIRES_RTTI}") -eq $(to_bool "${rtti}") ]] || return 1
     [[ $(to_bool "${DISABLE_ASSERTIONS}") -ne $(to_bool "${assertion}") ]] || return 1
 }
+
+setup_artifact_variables_llvm() {
+    # Check for variables set and not empty
+    local version=""
+    local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
+    local LLVM_VERSION_MINOR="${LLVM_VERSION/*./}"
+    [[ "${LLVM_VERSION_MAJOR}" -le 6 ]] && version="${LLVM_VERSION}"
+    [[ "${LLVM_VERSION_MAJOR}" -ge 7 ]] && version="${LLVM_VERSION_MAJOR}"
+    local lc=""
+    # Check for llvm-config without suffix but correct versions number
+    lc=$(which "llvm-config")
+    if [[ -z "${lc}" || $($lc --version) != "${LLVM_VERSION}"* ]]; then
+      # Check if llvm-config with the right version exists
+      lc=$(which "llvm-config-${version}")
+    fi
+
+    [[ -z "${lc}" ]] && return 1
+
+    LLVM_CONFIG="${lc}"
+
+    LLVM_INSTALL="$(${lc} --bindir)"
+    BITCODE_CC="${LLVM_INSTALL}/clang"
+    BITCODE_CXX="${LLVM_INSTALL}/clang++"
+}
+
+get_build_artifacts_llvm() {
+  is_installed_llvm
+  [[ $? -ne 0 ]] && return 1
+  return 0
+}