Skip to content

Commit 7aae84d

Browse files
Alexander Lochmannfabianbs96
andauthored
Allow LLVM beeing installed in a custom path (#690)
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 <52407375+fabianbs96@users.noreply.github.com>
1 parent 61b3a30 commit 7aae84d

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

bootstrap.sh

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set -eo pipefail
55
source ./utils/safeCommandsSet.sh
66

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

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

3233
# Parsing command-line-parameters
@@ -82,6 +83,15 @@ case $key in
8283
PHASAR_INSTALL_DIR="${key#*=}"
8384
shift # past argument=value
8485
;;
86+
-DLLVM_INSTALL_DIR)
87+
LLVM_INSTALL_DIR="$2"
88+
shift # past argument
89+
shift # past value
90+
;;
91+
-DLLVM_INSTALL_DIR=*)
92+
LLVM_INSTALL_DIR="${key#*=}"
93+
shift # past argument=value
94+
;;
8595
-h|--help)
8696
usage
8797
exit 0
@@ -157,6 +167,9 @@ tmp_dir=$(mktemp -d "llvm-build.XXXXXXXX" --tmpdir)
157167
rm -rf "${tmp_dir}"
158168
echo "dependencies successfully installed"
159169

170+
# *Always* set the LLVM root to ensure the Phasar script uses the proper toolchain
171+
LLVM_PARAMS=-DLLVM_ROOT="${LLVM_INSTALL_DIR}"
172+
160173
echo "Updating the submodules..."
161174
git submodule update --init
162175
echo "Submodules successfully updated"
@@ -169,7 +182,7 @@ export CXX=${LLVM_INSTALL_DIR}/bin/clang++
169182

170183
mkdir -p "${PHASAR_DIR}"/build
171184
safe_cd "${PHASAR_DIR}"/build
172-
cmake -G Ninja -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" "${BOOST_PARAMS}" -DPHASAR_BUILD_UNITTESTS="${DO_UNIT_TEST}" "${PHASAR_DIR}"
185+
cmake -G Ninja -DCMAKE_BUILD_TYPE="${BUILD_TYPE}" "${BOOST_PARAMS}" -DPHASAR_BUILD_UNITTESTS="${DO_UNIT_TEST}" "${LLVM_PARAMS}" "${PHASAR_DIR}"
173186
cmake --build . -j "${NUM_THREADS}"
174187

175188
echo "phasar successfully built"

0 commit comments

Comments
 (0)