diff --git a/srock-bin/rebuild_srock_llvm.sh b/srock-bin/rebuild_srock_llvm.sh new file mode 100755 index 000000000..d62f52fe5 --- /dev/null +++ b/srock-bin/rebuild_srock_llvm.sh @@ -0,0 +1,78 @@ +#!/bin/bash +# +#Copyright © Advanced Micro Devices, Inc., or its affiliates. +# +#SPDX-License-Identifier: MIT +# +# +# rebuild_srock_llvm.sh: iterative rebuild of LLVM after successful +# build_srock.sh. +# +# --- Start standard header to set SROCK environment variables ---- +realpath=$(realpath "$0") +thisdir=$(dirname "$realpath") +. "$thisdir/srock_common_vars" +# --- end standard header ---- +_curdir=$PWD +_start_date=$(date) +_start_secs=$(date +%s) + +if [ ! -d "$SROCK_THEROCK_DIR" ] ; then + echo " ERROR: $0 requires that $SROCK_THEROCK_DIR exist and has " + echo " been setup with $thisdir/setup_srock.sh. Please run" + echo + echo " nohup $thisdir/setup_srock.sh &" + echo + exit 1 +fi + +# Print the start banner similar to DONE banner, useful if fails +echo +echo "===== START $0 on $_start_date" +echo " THEROCK targets: $_gfxsemicolons" +echo " THEROCK families: $_gfamsemicolons" +echo " ROCm install dir: $SROCK_INSTALL_DIR" +echo " TheRock Dir: $SROCK_THEROCK_DIR" +echo " TheRock branch: $SROCK_THEROCK_BRANCH" +echo " Compiler branch: $SROCK_COMPILER_BRANCH" +echo " SROCK config name: $SROCK_CONFIG" +echo " cmake args: ${_cmake_args[*]}" + +cd "$SROCK_THEROCK_DIR" +echo "===== Enable only LLVM project =====" +build_tools/buildctl.py enable amd-llvm + +echo "===== Rebuild LLVM =====" +# The first build picks up any changes from the LLVM project. +cd "$SROCK_THEROCK_DIR"/build/compiler/amd-llvm/build || exit +ninja install || exit + +echo "===== Install LLVM =====" +# The second build installs the compiler in the chosen installation directory. +cd "$SROCK_THEROCK_DIR"/build || exit +ninja install || exit + +# Gather some build stats +_end_date=$(date) +_end_secs=$(date +%s) +_secs_to_build=$(( _end_secs - _start_secs )) +_filecount=$(find "$SROCK_INSTALL_DIR" -type f | wc -l) +_size=$(du -hs "$SROCK_INSTALL_DIR" | cut -f1) + +echo +echo "===== DONE $0 on $_end_date" +echo " THEROCK targets: $_gfxsemicolons" +echo " ROCm install dir: $SROCK_INSTALL_DIR" +echo " TheRock Dir: $SROCK_THEROCK_DIR" +echo " TheRock branch: $SROCK_THEROCK_BRANCH" +echo " Compiler branch: $SROCK_COMPILER_BRANCH" +echo " SROCK config name: $SROCK_CONFIG" +echo " cmake command: $SROCK_CMAKE" +echo " Build time: $_secs_to_build (seconds)" +echo " Files: $_filecount" +echo " Size: $_size" +echo " cmake args: ${_cmake_args[*]}" +echo +echo " For aomp testing, set AOMP=$SROCK_LINK" +echo " or AOMP=$SROCK_INSTALL_DIR" +echo diff --git a/srock-bin/setup_srock.sh b/srock-bin/setup_srock.sh index 3ea2f9659..0c7be2df1 100755 --- a/srock-bin/setup_srock.sh +++ b/srock-bin/setup_srock.sh @@ -14,9 +14,14 @@ thisdir=$(dirname "$realpath") # --- end standard header ---- # -if [ -d "$SROCK_THEROCK_DIR" ] ; then +# Accept a single command as an argument. Only "restart" is accepted so far. +ARG=$1 + +if [ -d "$SROCK_THEROCK_DIR" ] && [ "$ARG" != "restart" ]; then echo " ERROR: $0 requires that $SROCK_THEROCK_DIR NOT exist" echo " Delete or move that directory to run $0" + echo " Alternatively, try '$0 restart' to reconfigure with" + echo " existing sources." exit 1 fi @@ -42,35 +47,51 @@ echo "===== Sourcing prebuild_srock.sh" . "$thisdir/prebuild_srock.sh" echo "===== DONE Sourcing prebuild_srock.sh" -cd "$SROCK_REPOS" || exit -echo -echo "===== git clone https://github.com/ROCm/TheRock.git -b $SROCK_THEROCK_BRANCH TheRock" -git clone https://github.com/ROCm/TheRock.git -b "$SROCK_THEROCK_BRANCH" TheRock -if [ -f TheRock/version.json ] ; then - _quoted=$(cat TheRock/version.json | grep rocm-version | cut -d: -f2) - _rocm_version=${_quoted//\"/} - echo " ROCm components version : $_rocm_version" - echo " SROCK_VERSION_STRING : $SROCK_VERSION_STRING (Compiler dev version)" +if [ "$ARG" != "restart" ]; then + cd "$SROCK_REPOS" || exit + echo + echo "===== git clone https://github.com/ROCm/TheRock.git -b $SROCK_THEROCK_BRANCH TheRock" + git clone https://github.com/ROCm/TheRock.git -b "$SROCK_THEROCK_BRANCH" TheRock + if [ -f TheRock/version.json ] ; then + _quoted=$(cat TheRock/version.json | grep rocm-version | cut -d: -f2) + _rocm_version=${_quoted//\"/} + echo " ROCm components version : $_rocm_version" + echo " SROCK_VERSION_STRING : $SROCK_VERSION_STRING (Compiler dev version)" + fi fi cd "$SROCK_THEROCK_DIR" || exit -if [ ! -d "$SROCK_THEROCK_DIR/.venv/bin" ] ; then +if [ -d "$SROCK_THEROCK_DIR/.venv/bin" ] ; then + echo + echo "===== Activating virtual environment =====" + cd "$SROCK_THEROCK_DIR" || exit + echo "source .venv/bin/activate" + source ".venv/bin/activate" +else echo echo "===== Building virtual environment in .venv and updating PATH =====" cd "$SROCK_THEROCK_DIR" || exit echo "python3 -m venv .venv && source .venv/bin/activate" # shellcheck disable=1091 python3 -m venv .venv && source ".venv/bin/activate" - echo "pip install -r requirements.txt" - pip install -r requirements.txt fi +echo "pip install -r requirements.txt" +pip install -r requirements.txt export PATH=$SROCK_THEROCK_DIR/.venv/bin:$PATH -echo -echo "===== Running python ./build_tools/fetch_sources.py =====" -python ./build_tools/fetch_sources.py -echo "===== Done running python ./build_tools/fetch_sources.py" +if [ "$ARG" != "restart" ]; then + echo + echo "===== Running python ./build_tools/fetch_sources.py =====" + python ./build_tools/fetch_sources.py + echo "===== Done running python ./build_tools/fetch_sources.py" +fi + +if [ "$ARG" = "restart" ]; then + echo "==== Removing build dir for restart =====" + echo "rm -rf $SROCK_THEROCK_DIR/build" + rm -rf "$SROCK_THEROCK_DIR/build" +fi echo "cd $SROCK_THEROCK_DIR" cd "$SROCK_THEROCK_DIR" || exit @@ -81,7 +102,7 @@ echo "===== Running build_tools/setup_ccache.py" eval "$(python3 ./build_tools/setup_ccache.py)" # Make updates to compiler submodules unless this is native TheRock build -if [ "$SROCK_COMPILER_BRANCH" != "develop" ] ; then +if [ "$SROCK_COMPILER_BRANCH" != "develop" ] && [ "$ARG" != "restart" ]; then # FIXME: Before wiping out current amd-staging changes, # to save current changes in the patches directory. # Otherwise, this is not a real development environment" @@ -143,13 +164,13 @@ if [ "$SROCK_COMPILER_BRANCH" != "develop" ] ; then fi echo " --- end compiler submodule updates for $SROCK_COMPILER_BRANCH" +fi cd "$SROCK_THEROCK_DIR" || exit echo echo "===== cmake CMD: $SROCK_CMAKE ${_cmake_args[*]}" $SROCK_CMAKE "${_cmake_args[@]}" _rc=$? && [ "$_rc" != 0 ] && cd "$_curdir" && exit "$_rc" -fi _setup_secs=$(date +%s) _secs_to_setup=$(( _setup_secs - _start_secs ))