about summary refs log tree commit diff homepage
path: root/scripts/build
diff options
context:
space:
mode:
authorMartin Nowack <m.nowack@imperial.ac.uk>2023-10-12 10:23:34 +0100
committerCristian Cadar <c.cadar@imperial.ac.uk>2024-02-08 13:17:19 +0000
commit2b07721933d82f09c026134e0da52587f49d5df6 (patch)
tree57f1cc4e2fb43933587b20e57b3425524f3307eb /scripts/build
parent3ca81c2dc3881aec0bbf94646c73a148d706c76d (diff)
downloadklee-2b07721933d82f09c026134e0da52587f49d5df6.tar.gz
Add support to build newer LLVM versions
`-DLLVM_ENABLE_PROJECTS` does not include runtimes anymore,
instead a `-DLLVM_ENABLE_RUNTIMES` should be used in addition
Diffstat (limited to 'scripts/build')
-rw-r--r--scripts/build/p-libcxx.inc29
-rw-r--r--scripts/build/p-llvm.inc21
2 files changed, 35 insertions, 15 deletions
diff --git a/scripts/build/p-libcxx.inc b/scripts/build/p-libcxx.inc
index 641fad61..b0263c00 100644
--- a/scripts/build/p-libcxx.inc
+++ b/scripts/build/p-libcxx.inc
@@ -30,7 +30,6 @@ build_libcxx() {
   local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
 
   local cmake_flags=(
-   "-DLLVM_ENABLE_PROJECTS=libcxx;libcxxabi"
    "-DLLVM_ENABLE_THREADS:BOOL=OFF"
    "-DLIBCXX_ENABLE_THREADS:BOOL=OFF"
    "-DLIBCXX_ENABLE_SHARED:BOOL=ON"
@@ -40,6 +39,13 @@ build_libcxx() {
   )
 
   # Static ABI libraries are not supported under OS X
+  if [[ "${LLVM_VERSION_SHORT}" -ge "14" ]]; then
+    cmake_flags+=("-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi")
+    cmake_flags+=("-DLLVM_ENABLE_PROJECTS=")
+    cmake_flags+=("-DLLVM_ENABLE_PROJECTS_USED:BOOL=ON")
+  else
+    cmake_flags+=("-DLLVM_ENABLE_PROJECTS=libcxx;libcxxabi")
+  fi
   if [[ "${OS}" == "osx" ]]; then
     cmake_flags+=("-DLIBCXX_ENABLE_STATIC_ABI_LIBRARY:BOOL=OFF")
   else
@@ -53,7 +59,11 @@ build_libcxx() {
     export LLVM_COMPILER_PATH="$(dirname "${BITCODE_CC}")"
 
     cmake "${cmake_flags[@]}" "${LIBCXX_SRC}/llvm"
-    make cxx -j$(nproc) || make cxx
+   if [[ "${LLVM_VERSION_SHORT}" -ge "14" ]]; then
+     make runtimes - j"$(nproc)" || make cxx || return 1
+   else
+     make cxx - j"$(nproc)" || make cxx || return 1
+   fi
   )
 }
 
@@ -65,19 +75,24 @@ install_libcxx() {
     export LLVM_COMPILER=clang
     export LLVM_COMPILER_PATH="$(dirname "${BITCODE_CC}")"
 
-    cd "${LIBCXX_BUILD}/projects"
-    make install
+    if [[ "${LLVM_VERSION_SHORT}" -ge "14" ]]; then
+      cd "${LIBCXX_BUILD}/runtimes" || return 1
+      make install || return 1
+    else
+      cd "${LIBCXX_BUILD}/projects" || return 1
+      make install || return 1
+    fi
 
     local libraries
 
     if [[ "${OS}" == "osx" ]]; then
-      libraries=("${LIBCXX_INSTALL}"/lib/lib*.dylib)
+      libraries=("${LIBCXX_INSTALL}"/lib/*/lib*.dylib)
     else
-      libraries=("${LIBCXX_INSTALL}"/lib/lib*.so)
+      libraries=("${LIBCXX_INSTALL}"/lib/*/lib*.so)
     fi
 
     local LLVM_VERSION_MAJOR="${LLVM_VERSION/.*/}"
-    libraries+=("${LIBCXX_INSTALL}"/lib/lib*.a)
+    libraries+=("${LIBCXX_INSTALL}"/lib/*/lib*.a)
 
 
     for p in "${libraries[@]}" ; do
diff --git a/scripts/build/p-llvm.inc b/scripts/build/p-llvm.inc
index abf895ae..462d69f5 100644
--- a/scripts/build/p-llvm.inc
+++ b/scripts/build/p-llvm.inc
@@ -174,16 +174,21 @@ configure_llvm() {
   )
 
   if [[ "${SANITIZER_BUILD:-}" == "memory" ]]; then
-    # We have to build without libunwind if RTTI is disables
+    # We have to build without libunwind if RTTI is disabled
     CONFIG+=("-DLLVM_ENABLE_PROJECTS=${ENABLED_LLVM_PROJECTS}")
   else
-      CONFIG+=(
-          "-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON"
-          "-DLLVM_LINK_LLVM_DYLIB:BOOL=ON"
-          "-DLLVM_BUILD_STATIC:BOOL=OFF"
-          "-DLIBCLANG_BUILD_STATIC:BOOL=OFF"
-      )
-      CONFIG+=("-DLLVM_ENABLE_PROJECTS=${ENABLED_LLVM_PROJECTS};libcxx;libcxxabi;libunwind")
+    CONFIG+=(
+        "-DLLVM_BUILD_LLVM_DYLIB:BOOL=ON"
+        "-DLLVM_LINK_LLVM_DYLIB:BOOL=ON"
+        "-DLLVM_BUILD_STATIC:BOOL=OFF"
+        "-DLIBCLANG_BUILD_STATIC:BOOL=OFF"
+    )
+    if [[ "${LLVM_VERSION_SHORT}" -ge "14" ]]; then
+      CONFIG+=("-DLLVM_ENABLE_PROJECTS=${ENABLED_LLVM_PROJECTS}")
+      CONFIG+=("-DLLVM_ENABLE_RUNTIMES=libcxx;libcxxabi")
+    else
+      CONFIG+=("-DLLVM_ENABLE_PROJECTS=${ENABLED_LLVM_PROJECTS};libcxx;libcxxabi")
+    fi
   fi
 
   if [[ -n ${SANITIZER_BUILD} ]]; then