Skip to content

Commit

Permalink
Allow LLVM beeing installed in a custom path (#690)
Browse files Browse the repository at this point in the history
Currently, the custom build of LLVM must be located in
/usr/local/llvm-14.
If not, CMake will either fail finding LLVMConfig.cmake or use a
different LLVM installation, e.g., the system-wide one.
This will, for example, result in an include path different from the
custom LLVM installation.
This commit extends 'bootstrap.sh' to set 'LLVM_ROOT' to the
custom installation. Moreover, it allows the user to select
an arbitrary location for LLVM.

(Fixed #689)

Co-authored-by: Fabian Schiebel <[email protected]>
  • Loading branch information
flipreverse and fabianbs96 authored Feb 1, 2024
1 parent 61b3a30 commit 7aae84d
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ set -eo pipefail
source ./utils/safeCommandsSet.sh

readonly PHASAR_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
readonly PHASAR_INSTALL_DIR="/usr/local/phasar"
readonly LLVM_INSTALL_DIR="/usr/local/llvm-14"
PHASAR_INSTALL_DIR="/usr/local/phasar"
LLVM_INSTALL_DIR="/usr/local/llvm-14"

NUM_THREADS=$(nproc)
LLVM_RELEASE=llvmorg-14.0.6
Expand All @@ -26,7 +26,8 @@ function usage {
echo -e "\t-DBOOST_DIR=<path>\t\t- The directory where boost should be installed (optional)"
echo -e "\t-DBOOST_VERSION=<string>\t- The desired boost version to install (optional)"
echo -e "\t-DCMAKE_BUILD_TYPE=<string>\t- The build mode for building PhASAR. One of {Debug, RelWithDebInfo, Release} (default is Release)"
echo -e "\t-DPHASAR_INSTALL_DIR=<path>\t- The folder where to install PhASAR if --install is specified (default is /usr/local/phasar)"
echo -e "\t-DPHASAR_INSTALL_DIR=<path>\t- The folder where to install PhASAR if --install is specified (default is ${PHASAR_INSTALL_DIR})"
echo -e "\t-DLLVM_INSTALL_DIR=<path>\t- The folder where to install LLVM if --install is specified (default is ${LLVM_INSTALL_DIR})"
}

# Parsing command-line-parameters
Expand Down Expand Up @@ -82,6 +83,15 @@ case $key in
PHASAR_INSTALL_DIR="${key#*=}"
shift # past argument=value
;;
-DLLVM_INSTALL_DIR)
LLVM_INSTALL_DIR="$2"
shift # past argument
shift # past value
;;
-DLLVM_INSTALL_DIR=*)
LLVM_INSTALL_DIR="${key#*=}"
shift # past argument=value
;;
-h|--help)
usage
exit 0
Expand Down Expand Up @@ -157,6 +167,9 @@ tmp_dir=$(mktemp -d "llvm-build.XXXXXXXX" --tmpdir)
rm -rf "${tmp_dir}"
echo "dependencies successfully installed"

# *Always* set the LLVM root to ensure the Phasar script uses the proper toolchain
LLVM_PARAMS=-DLLVM_ROOT="${LLVM_INSTALL_DIR}"

echo "Updating the submodules..."
git submodule update --init
echo "Submodules successfully updated"
Expand All @@ -169,7 +182,7 @@ export CXX=${LLVM_INSTALL_DIR}/bin/clang++

mkdir -p "${PHASAR_DIR}"/build
safe_cd "${PHASAR_DIR}"/build
cmake -G Ninja -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" "${BOOST_PARAMS}" -DPHASAR_BUILD_UNITTESTS="${DO_UNIT_TEST}" "${PHASAR_DIR}"
cmake -G Ninja -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" "${BOOST_PARAMS}" -DPHASAR_BUILD_UNITTESTS="${DO_UNIT_TEST}" "${LLVM_PARAMS}" "${PHASAR_DIR}"
cmake --build . -j "${NUM_THREADS}"

echo "phasar successfully built"
Expand Down

0 comments on commit 7aae84d

Please sign in to comment.