Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Commit

Permalink
SWDEV-335902 - Fix HIP when Git info unavailable
Browse files Browse the repository at this point in the history
Prior to this change, when Git_FOUND was false, HIP_VERSION_BUILD_ID
would be undefined in the CMake code. The value of HIP_VERSION_BUILD_ID
in <hip/hip_version.h> is taken from the CMake variable, so it was being
defined as nothing in those cases. That would cause compilation failures,
as src/hip_global.cpp contains the function:

    size_t amd_dbgapi_get_build_id() {
      return HIP_VERSION_BUILD_ID;
    }

which would become

    size_t amd_dbgapi_get_build_id() {
      return ;
    }

after preprocessing. To prevent this, we can define the version
information to a default value when Git is not found.

A related problem was reported by Harmen Stoppels in
ROCm/HIP#2218. When Git
is not available (or if the library is being built from a tarball),
the HIP_VERSION_GITHASH is not defined. This causes trouble because
HIP_LIB_VERSION_STRING is defined as "X.Y.Z-${HIP_VERSION_GITHASH}"
and therefore becomes "X.Y.Z-".

The incomplete version string becomes a problem when it is appended
to the shared library file name. File names that end with '-' confuse
the linker. They cause strange errors when attempting to link to the
HIP library. This problem can be prevented by dropping the trailing
dash and using "X.Y.Z" as the version string when HIP_VERSION_GITHASH
is not defined.

Change-Id: I6e290c1f1b603ba30c9ded885e125d9ca9a2e688
Signed-off-by: Cordell Bloor <Cordell.Bloor@amd.com>
  • Loading branch information
cgmb committed May 9, 2022
1 parent 0982521 commit 56b3260
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ if(GIT_FOUND)
set(HIP_PACKAGING_VERSION_PATCH ${HIP_VERSION_PATCH}-${HIP_VERSION_GITHASH})
endif()
else()
set(HIP_VERSION_BUILD_ID 0)
set(HIP_VERSION_BUILD_NAME "")
# FIXME: Some parts depend on this being set.
set(HIP_PACKAGING_VERSION_PATCH "0")
endif()
Expand Down Expand Up @@ -182,8 +184,10 @@ set (HIP_LIB_VERSION_MAJOR ${HIP_VERSION_MAJOR})
set (HIP_LIB_VERSION_MINOR ${HIP_VERSION_MINOR})
if (${ROCM_PATCH_VERSION} )
set (HIP_LIB_VERSION_PATCH ${ROCM_PATCH_VERSION})
else ()
elseif (DEFINED HIP_VERSION_GITHASH)
set (HIP_LIB_VERSION_PATCH ${HIP_VERSION_PATCH}-${HIP_VERSION_GITHASH})
else ()
set (HIP_LIB_VERSION_PATCH ${HIP_VERSION_PATCH})
endif ()
set (HIP_LIB_VERSION_STRING "${HIP_LIB_VERSION_MAJOR}.${HIP_LIB_VERSION_MINOR}.${HIP_LIB_VERSION_PATCH}")
if (DEFINED ENV{ROCM_RPATH})
Expand Down

0 comments on commit 56b3260

Please sign in to comment.