From 8d65fc6914889a1878238553e970d284b06e3fd9 Mon Sep 17 00:00:00 2001 From: Akash Kothari <akashk4@tyler.cs.illinois.edu> Date: Tue, 19 Jan 2021 11:44:16 -0600 Subject: [PATCH] Adding option of more targets to install script --- hpvm/scripts/llvm_installer.sh | 118 ++++++++++++++++++++++++++++++--- 1 file changed, 107 insertions(+), 11 deletions(-) diff --git a/hpvm/scripts/llvm_installer.sh b/hpvm/scripts/llvm_installer.sh index 6867cf64f4..13184fd7f7 100755 --- a/hpvm/scripts/llvm_installer.sh +++ b/hpvm/scripts/llvm_installer.sh @@ -28,18 +28,107 @@ LLVM_SRC="llvm-$VERSION.src" HPVM_RT=hpvm-rt/hpvm-rt.bc -read_yn "Build and install HPVM automatically?" AUTOMATE -echo -read -p "Number of threads: " NUM_THREADS +TARGET=all +TARGET_INPUT=all +FLAGGED=false + +# Get flags +while getopts 'hmj:t:' opt; do + case $opt in + h) + echo + echo + echo "This is the help menu for HPVM installation" + echo + echo "There are 3 options for installation:" + echo + echo "-m is a manual installation flag. This will require you to install HPVM manually by running cmake and make manually." + echo "For more details, refer to README.md. Defaults to automatic installation." + echo + echo "-j is the threads flag. Accepts one argument: how many threads to build with." + echo "To build with 2 threads, enter -j2. Defaults to 2 threads." + echo + echo "-t is the build target flag. Accepts one argument: which build target(s) you would like to build to." + echo "For single target, enter -a ARM. For multiple targets, enter -t \"X86;ARM\"." + echo "Supports the following targets: AArch64, AMDGPU, ARM, BPF, Hexagon, Mips, MSP430, NVPTX, PowerPC, Sparc, SystemZ, X86, XCore." + echo "Defaults to targeting all supported architectures." + echo + echo "If no flags are provided, the script will use command line prompts for all options." + echo + exit + ;; + m) + AUTOMATE=false + FLAGGED=true + ;; + j) + if ! [[ $OPTARG =~ ^[0-9]+$ ]]; then + echo "Invalid argument for # of threads: $OPTARG" + exit -1; + else + NUM_THREADS=$OPTARG + FLAGGED=true + fi + ;; + t) + TARGET=$OPTARG + FLAGGED=true + ;; + esac +done + +if $FLAGGED; then + echo "Running with the following options:" + echo Automated: $AUTOMATE + echo Threads: $NUM_THREADS + echo Targets: $TARGET + echo +else + echo "No Flags found. Using command line prompts." + read -p "Build and install HPVM automatically? (y or n): " AUTOMATE_INPUT + + if [[ $AUTOMATE_INPUT == "" ]]; then + echo "No input given. Using default: $AUTOMATE" + elif [[ ! $AUTOMATE_INPUT == "y" ]] && [[ ! $AUTOMATE_INPUT == "n" ]]; then + echo "Invalid input. Using default: $AUTOMATE" + elif [[ $AUTOMATE_INPUT == "n" ]]; then + AUTOMATE=false + fi + -if [ ! $NUM_THREADS -gt 0 ]; then - NUM_THREADS = 2 echo - echo Using $NUM_THREADS threads by default. + read -p "Number of threads: " NUM_THREADS_INPUT + + if [[ $NUM_THREADS_INPUT == "" ]]; then + echo "No input given. Using default: $NUM_THREADS" + elif ! [[ $NUM_THREADS_INPUT =~ ^[0-9]+$ ]]; then + echo "Given input is not an integer. Using default: $NUM_THREADS" + elif [ ! $NUM_THREADS_INPUT -gt 0 ]; then + echo "Given input is not greater than 0. Using default: $NUM_THREADS" + else + NUM_THREADS=$NUM_THREADS_INPUT + fi + + echo + echo + echo "Supports the following options: AArch64, AMDGPU, ARM, BPF, Hexagon, Mips, MSP430, NVPTX, PowerPC, Sparc, SystemZ, X86, XCore." + echo "If building for multiple targets, seperate options with semicolon:" + echo "e.g. X86;ARM" + read -p "Build target: " TARGET_INPUT + if [[ $TARGET_INPUT == "" ]]; then + echo "No input given. Using default: $TARGET" + else + TARGET=$TARGET_INPUT + fi echo -fi + echo "Running with the following options:" + echo Automated: $AUTOMATE + echo Threads: $NUM_THREADS + echo Targets: $TARGET + echo +fi if [ -d $LLVM_SRC ]; then echo Found $LLVM_SRC, not dowloading it again! @@ -113,9 +202,16 @@ cd $CURRENT_DIR/llvm_patches echo Patches applied. -if [ ! $AUTOMATE == "y" ]; then +if ! $AUTOMATE ; then echo - echo HPVM not installed. Exiting. + echo "HPVM not installed." + echo "To complete installation, follow these instructions:" + echo " - Create and navigate to a folder \"./build\" " + echo " - Run \"cmake ../llvm [options]\". Find potential options in README.md." + echo " - Run \"make -j<number of threads>\" and then \"make install\"" + echo "For more details refer to README.md." + echo + echo "Exiting." exit fi @@ -136,8 +232,8 @@ if [ ! -d $INSTALL_DIR ]; then fi cd $BUILD_DIR -echo cmake ../$LLVM_SRC -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -cmake ../$LLVM_SRC -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_TARGETS_TO_BUILD="X86" -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR +echo cmake ../$LLVM_SRC -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_TARGETS_TO_BUILD=$TARGET -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR +cmake ../$LLVM_SRC -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DLLVM_TARGETS_TO_BUILD=$TARGET -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR echo make -j$NUM_THREADS make -j$NUM_THREADS -- GitLab