Skip to content

Commit

Permalink
Adding symlinks for lib.<major> and lib.<string> (#110)
Browse files Browse the repository at this point in the history
* Updates to the RUNPATH of the lib

* Adding symlinks for lib.<major> and lib.<string>

-> Symlink to lib.<major> and lib.<patch from top level rocm lib directory

Co-authored-by: mpruthvikumar <[email protected]>
  • Loading branch information
saadrahim and mpruthvikumar authored Mar 5, 2020
1 parent 37f1fac commit fdd195a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmake/Common.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
set(ROCM_DISABLE_LDCONFIG OFF CACHE BOOL "")

function(package_set_postinst_prerm LIB_NAMES LIB_DIRS INCLUDE_DIRS)
function(package_set_postinst_prerm LIB_NAMES LIB_DIRS INCLUDE_DIRS SOVERSIONS)
list(LENGTH LIB_NAMES len1)
list(LENGTH LIB_DIRS len2)
if(NOT (len1 EQUAL len2))
Expand All @@ -13,10 +13,18 @@ function(package_set_postinst_prerm LIB_NAMES LIB_DIRS INCLUDE_DIRS)
set(PREINST_SOURCE "")
set(PRERM_SOURCE "")
set(PRERM_RPM_SOURCE "")

foreach(val RANGE ${len3})
list(GET LIB_NAMES ${val} lib_name)
list(GET LIB_DIRS ${val} lib_dir)
list(GET INCLUDE_DIRS ${val} inc_dir)
list(GET SOVERSIONS ${val} so_ver)

rocm_version_regex_parse("^([0-9]+).*" LIB_VERSION_MAJOR "${so_ver}")
set (LIB_VERSION_STRING "${so_ver}.0")
if(DEFINED ENV{ROCM_LIBPATCH_VERSION})
set (LIB_VERSION_STRING "${so_ver}.$ENV{ROCM_LIBPATCH_VERSION}")
endif()

set(POSTINST_SOURCE "${POSTINST_SOURCE}\nmkdir -p ${inc_dir}/../../include/")
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nmkdir -p ${lib_dir}/../../lib/cmake/${lib_name}")
Expand All @@ -25,13 +33,17 @@ function(package_set_postinst_prerm LIB_NAMES LIB_DIRS INCLUDE_DIRS)
endif()
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nln -sr ${inc_dir} ${inc_dir}/../../include/${lib_name}")
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nln -sr ${lib_dir}/lib${lib_name}.so ${lib_dir}/../../lib/lib${lib_name}.so")
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nln -sr ${lib_dir}/lib${lib_name}.so.${LIB_VERSION_MAJOR} ${lib_dir}/../../lib/lib${lib_name}.so.${LIB_VERSION_MAJOR}")
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nln -sr ${lib_dir}/lib${lib_name}.so.${LIB_VERSION_STRING} ${lib_dir}/../../lib/lib${lib_name}.so.${LIB_VERSION_STRING}")
set(POSTINST_SOURCE "${POSTINST_SOURCE}\nln -sr ${lib_dir}/cmake/${lib_name} ${lib_dir}/../../lib/cmake/${lib_name}\n")
#For preinstall script, first argument is 1 for install and 2 for upgrade
#Skip removal of symlinks if install command is called
set(PREINST_SOURCE "${PREINST_SOURCE}\nif [ $1 == 2 ]; then")
set(PREINST_SOURCE "${PREINST_SOURCE}\n\trm -f /etc/ld.so.conf.d/${lib_name}.conf")
set(PREINST_SOURCE "${PREINST_SOURCE}\n\tunlink ${inc_dir}/../../include/${lib_name}")
set(PREINST_SOURCE "${PREINST_SOURCE}\n\tunlink ${lib_dir}/../../lib/lib${lib_name}.so")
set(PREINST_SOURCE "${PREINST_SOURCE}\n\tunlink ${lib_dir}/../../lib/lib${lib_name}.so.${LIB_VERSION_MAJOR}")
set(PREINST_SOURCE "${PREINST_SOURCE}\n\tunlink ${lib_dir}/../../lib/lib${lib_name}.so.${LIB_VERSION_STRING}")
set(PREINST_SOURCE "${PREINST_SOURCE}\n\tunlink ${lib_dir}/../../lib/cmake/${lib_name}/${lib_name}")
set(PREINST_SOURCE "${PREINST_SOURCE}\n\trm -f ${lib_dir}/lib${lib_name}.so*")
set(PREINST_SOURCE "${PREINST_SOURCE}\n\trm -d ${lib_dir}/../../lib/cmake/${lib_name}\n")
Expand All @@ -40,6 +52,8 @@ function(package_set_postinst_prerm LIB_NAMES LIB_DIRS INCLUDE_DIRS)
set(PRERM_SOURCE "${PRERM_SOURCE}\nrm -f /etc/ld.so.conf.d/${lib_name}.conf")
set(PRERM_SOURCE "${PRERM_SOURCE}\nunlink ${inc_dir}/../../include/${lib_name}")
set(PRERM_SOURCE "${PRERM_SOURCE}\nunlink ${lib_dir}/../../lib/lib${lib_name}.so")
set(PRERM_SOURCE "${PRERM_SOURCE}\nunlink ${lib_dir}/../../lib/lib${lib_name}.so.${LIB_VERSION_MAJOR}")
set(PRERM_SOURCE "${PRERM_SOURCE}\nunlink ${lib_dir}/../../lib/lib${lib_name}.so.${LIB_VERSION_STRING}")
set(PRERM_SOURCE "${PRERM_SOURCE}\nunlink ${lib_dir}/../../lib/cmake/${lib_name}/${lib_name}")
set(PRERM_SOURCE "${PRERM_SOURCE}\nrm -d ${lib_dir}/../../lib/cmake/${lib_name}\n")

Expand All @@ -49,6 +63,8 @@ function(package_set_postinst_prerm LIB_NAMES LIB_DIRS INCLUDE_DIRS)
set(PRERM_RPM_SOURCE "${PRERM_RPM_SOURCE}\n\trm -f /etc/ld.so.conf.d/${lib_name}.conf")
set(PRERM_RPM_SOURCE "${PRERM_RPM_SOURCE}\n\tunlink ${inc_dir}/../../include/${lib_name}")
set(PRERM_RPM_SOURCE "${PRERM_RPM_SOURCE}\n\tunlink ${lib_dir}/../../lib/lib${lib_name}.so")
set(PRERM_RPM_SOURCE "${PRERM_RPM_SOURCE}\n\tunlink ${lib_dir}/../../lib/lib${lib_name}.so.${LIB_VERSION_MAJOR}")
set(PRERM_RPM_SOURCE "${PRERM_RPM_SOURCE}\n\tunlink ${lib_dir}/../../lib/lib${lib_name}.so.${LIB_VERSION_STRING}")
set(PRERM_RPM_SOURCE "${PRERM_RPM_SOURCE}\n\tunlink ${lib_dir}/../../lib/cmake/${lib_name}/${lib_name}")
set(PRERM_RPM_SOURCE "${PRERM_RPM_SOURCE}\n\trm -d ${lib_dir}/../../lib/cmake/${lib_name}\n")
set(PRERM_RPM_SOURCE "${PRERM_RPM_SOURCE}\nfi")
Expand Down
1 change: 1 addition & 0 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ package_set_postinst_prerm(
"hiprand;rocrand"
"${CMAKE_INSTALL_PREFIX}/hiprand/lib;${CMAKE_INSTALL_PREFIX}/rocrand/lib"
"${CMAKE_INSTALL_PREFIX}/hiprand/include;${CMAKE_INSTALL_PREFIX}/rocrand/include"
"${hiprand_SOVERSION};${rocrand_SOVERSION}"
)

# Include CPack to introduce the appropriate targets
Expand Down

0 comments on commit fdd195a

Please sign in to comment.