diff --git a/bin/aomp_common_vars b/bin/aomp_common_vars index cf6846b97..791944be7 100644 --- a/bin/aomp_common_vars +++ b/bin/aomp_common_vars @@ -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. + +# 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} +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}} @@ -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 diff --git a/bin/build_flang-classic.sh b/bin/build_flang-classic.sh index e6ccc9b2a..3f6a5374d 100755 --- a/bin/build_flang-classic.sh +++ b/bin/build_flang-classic.sh @@ -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 diff --git a/bin/build_llvm-classic.sh b/bin/build_llvm-classic.sh index 6e7e5c4fa..1718c1615 100755 --- a/bin/build_llvm-classic.sh +++ b/bin/build_llvm-classic.sh @@ -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 diff --git a/bin/build_project.sh b/bin/build_project.sh index 0c793ec43..db3b0fab0 100755 --- a/bin/build_project.sh +++ b/bin/build_project.sh @@ -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 @@ -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