Skip to content

Allow AOMP env var to end in lib/llvm. #1253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: aomp-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions bin/aomp_common_vars
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,25 @@ AOMP_VERSION_STRING=${AOMP_VERSION_STRING:-"$AOMP_VERSION-$AOMP_VERSION_MOD"}
ROCM_EXPECTED_MODVERSION=${ROCM_EXPECTED_MODVERSION:-6.2.4}
export AOMP_VERSION_STRING AOMP_VERSION AOMP_VERSION_MOD ROCM_VERSION ROCM_EXPECTED_MODVERSION

# Set install directory and the link directory.
# AOMP will be a symbolic link AOMP_INSTALL_DIR is the versioned dir name
AOMP=${AOMP:-$HOME/rocm/aomp}
AOMP_INSTALL_DIR=${AOMP}_${AOMP_VERSION_STRING}

# For example, if AOMP_REPOS=$HOME/git/aomp11, then the primary aomp repo
# is stored in $HOME/git/aomp11/aomp and the mono repo is stored in
# $HOME/aomp/llvm-project.
# Determine AOMP_INSTALL_DIR based on AOMP and if AOMP ends in lib/llvm
# strip off the lib/llvm. BUILD scripts should only use AOMP_INSTALL_DIR, not AOMP.

# NOTE regarding test scripts and test makefiles:
# TEST scripts or Makefiles should use AOMP env variable to find the compiler
# and runtimes. AOMP has a historic default to $HOME/rocm/aomp. But with the
# new convention, that follows the ROCm directory structure, AOMP should really
# be set to $HOME/rocm/aomp/lib/llvm. Some test scripts detect this historic
# default and add the lib/llvm to find the compiler. Since AOMP uses the same
# directory structure as /opt/rocm, setting AOMP=/opt/rocm/lib/llvm will use the
# ROCm compiler.

AOMP=${AOMP:-$HOME/rocm/aomp} # Assume test scripts will correct this.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most team members were presetting AOMP to end in lib/llvm. This strips that off to set AOMP_INSTALL_DIR. If you were using the default listed here, then nothing is stripped and build progresses correctly. However, since test scripts assume the compiler (e.g. clang++) is located at $AOMP (e.g. $AOMP/bin/clang++) , those test scripts will fail with this default value of AOMP. So a lot of people were presetting AOMP=/work/$USER/rocm/aomp/lib/llvm. Which causes build_aomp.sh to fail. This PR strips off lib/llvm for setting AOMP_INSTALL_DIR and does not modify AOMP. So now one can build if AOMP is set to something/lib/llvm.


# In case AOMP ws preset and ends in lib/llvm (like most testers correctly do),
# strip off the lib/llvm to determine AOMP_INSTALL_DIR.
_aomp_libllvm_stripped=${AOMP%*\/lib\/llvm}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we also make this work for AOMP=/usr/lib/aomp/llvm?

AOMP_INSTALL_DIR=${AOMP_INSTALL_DIR:-${_aomp_libllvm_stripped}_${AOMP_VERSION_STRING}}

AOMP_MAJOR_VERSION=${AOMP_VERSION%.*}
export AOMP_MAJOR_VERSION
AOMP_REPOS=${AOMP_REPOS:-${HOME}/git/aomp${AOMP_VERSION}}
Expand Down Expand Up @@ -170,6 +181,10 @@ AOMP_CXX_COMPILER=${AOMP_CXX_COMPILER:-$GCCXX}
# Non standalone builds are done with ROCm builds.
AOMP_STANDALONE_BUILD=${AOMP_STANDALONE_BUILD:-1}

# BUILD scripts use the higher level AOMP_INSTALL_DIR for NON-compiler COMPONENTS
# such as HIP, debugger, and profiler. Compiler COMPONENTS are installed into
# the lower level LLVM_INSTALL_LOC . If LLVM_INSTALL_LOC is not set, it defaults
# to AOMP_INSTALL_DIR/lib/llvm. We strongly recommend NOT overriding LLVM_INSTALL_LOC.
if [ "$AOMP_STANDALONE_BUILD" == 1 ] ; then
LLVM_INSTALL_LOC=$AOMP_INSTALL_DIR/lib/llvm
else
Expand Down
18 changes: 10 additions & 8 deletions bin/build_flang-classic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,16 @@ if [ "$1" == "-h" ] || [ "$1" == "help" ] || [ "$1" == "-help" ] ; then
help_build_aomp
fi

if [ $AOMP_STANDALONE_BUILD == 1 ] ; then
if [ ! -L $AOMP ] ; then
if [ -d $AOMP ] ; then
echo "ERROR: Directory $AOMP is a physical directory."
echo " It must be a symbolic link or not exist"
exit 1
fi
fi
if [ $AOMP_STANDALONE_BUILD == 1 ] ; then
_aomp_libllvm_stripped=${AOMP%*\/lib\/llvm}
if [ ! -L $_aomp_libllvm_stripped ] ; then
if [ -d $_aomp_libllvm_stripped ] ; then
echo "ERROR: Directory $_aomp_libllvm_stripped is a physical directory."
echo " It must be a symbolic link or not exist"
echo " Specify a different value for AOMP env variable"
exit 1
fi
fi
fi

# Make sure we can update the install directory
Expand Down
8 changes: 5 additions & 3 deletions bin/build_llvm-classic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ if [ "$1" == "-h" ] || [ "$1" == "help" ] || [ "$1" == "-help" ] ; then
fi

if [ $AOMP_STANDALONE_BUILD == 1 ] ; then
if [ ! -L $AOMP ] ; then
if [ -d $AOMP ] ; then
echo "ERROR: Directory $AOMP is a physical directory."
_aomp_libllvm_stripped=${AOMP%*\/lib\/llvm}
if [ ! -L $_aomp_libllvm_stripped ] ; then
if [ -d $_aomp_libllvm_stripped ] ; then
echo "ERROR: Directory $_aomp_libllvm_stripped is a physical directory."
echo " It must be a symbolic link or not exist"
echo " Specify a different value for AOMP env variable"
exit 1
fi
fi
Expand Down
18 changes: 10 additions & 8 deletions bin/build_project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,12 @@ if [ "$1" == "-h" ] || [ "$1" == "help" ] || [ "$1" == "-help" ] ; then
fi

if [ $AOMP_STANDALONE_BUILD == 1 ] ; then
if [ ! -L $AOMP ] ; then
if [ -d $AOMP ] ; then
echo "ERROR: Directory $AOMP is a physical directory."
_aomp_libllvm_stripped=${AOMP%*\/lib\/llvm}
if [ ! -L $_aomp_libllvm_stripped ] ; then
if [ -d $_aomp_libllvm_stripped ] ; then
echo "ERROR: Directory $_aomp_libllvm_stripped is a physical directory."
echo " It must be a symbolic link or not exist"
echo " Specify a different value for AOMP env variable"
exit 1
fi
fi
Expand Down Expand Up @@ -258,12 +260,12 @@ if [ "$1" == "install" ] ; then
fi
if [ $AOMP_STANDALONE_BUILD == 1 ] ; then
echo " "
echo "------ Linking $INSTALL_PROJECT to $AOMP -------"
if [ -L $AOMP ] ; then
$SUDO rm $AOMP
_aomp_libllvm_stripped=${AOMP%*\/lib\/llvm}
echo "------ Linking $AOMP_INSTALL_DIR to $_aomp_libllvm_stripped -------"
if [ -L $_aomp_libllvm_stripped ] ; then
$SUDO rm $_aomp_libllvm_stripped
fi
$SUDO ln -sf $AOMP_INSTALL_DIR $AOMP

$SUDO ln -sf $AOMP_INSTALL_DIR $_aomp_libllvm_stripped
fi

# add executables forgot by make install but needed for testing
Expand Down