From 946f77d244981dc2f5de5573d8eba5ed7692a8f1 Mon Sep 17 00:00:00 2001 From: Suman Nimmala Date: Wed, 28 Sep 2022 01:28:33 -0400 Subject: [PATCH 01/61] Initial empty repository From 68c763f3d0a1f683ddffab784a8452ec75c35a7a Mon Sep 17 00:00:00 2001 From: Ashutosh Mishra Date: Tue, 18 Oct 2022 10:35:37 +0530 Subject: [PATCH 02/61] Inital commit of the new lib package Signed-off-by: Ashutosh Mishra Change-Id: I605c3fb56584806dc6b392230e64d304449819f6 --- CMakeLists.txt | 162 +++++++++++++++++++++++++++++++++++++++++++++ README.txt | 93 ++++++++++++++++++++++++++ copyright | 37 +++++++++++ rocm-core.postinst | 65 ++++++++++++++++++ rocm-core.prerm | 25 +++++++ rocm_version.cpp | 77 +++++++++++++++++++++ rocm_version.h.in | 92 +++++++++++++++++++++++++ rocmmod.in | 16 +++++ utils.cmake | 156 +++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 723 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 README.txt create mode 100644 copyright create mode 100755 rocm-core.postinst create mode 100755 rocm-core.prerm create mode 100644 rocm_version.cpp create mode 100644 rocm_version.h.in create mode 100644 rocmmod.in create mode 100644 utils.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000000..54910944f2 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,162 @@ +################################################################################ +## +## The University of Illinois/NCSA +## Open Source License (NCSA) +## +## Copyright (c) 2014-2018, Advanced Micro Devices, Inc. All rights reserved. +## +## Developed by: +## +## AMD Research and AMD HSA Software Development +## +## Advanced Micro Devices, Inc. +## +## www.amd.com +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to +## deal with the Software without restriction, including without limitation +## the rights to use, copy, modify, merge, publish, distribute, sublicense, +## and#or sell copies of the Software, and to permit persons to whom the +## Software is furnished to do so, subject to the following conditions: +## +## - Redistributions of source code must retain the above copyright notice, +## this list of conditions and the following disclaimers. +## - Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimers in +## the documentation and#or other materials provided with the distribution. +## - Neither the names of Advanced Micro Devices, Inc, +## nor the names of its contributors may be used to endorse or promote +## products derived from this Software without specific prior written +## permission. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +## THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +## OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +## ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +## DEALINGS WITH THE SOFTWARE. +## +################################################################################ + +cmake_minimum_required( VERSION 3.16 ) +set( CORE_TARGET "rocm-core" ) + +project( ${CORE_TARGET} CXX ) + +## Verbose output. +set( CMAKE_VERBOSE_MAKEFILE on ) + +include( utils.cmake ) +include( GNUInstallDirs ) + +set( CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm" CACHE PATH "default cpack directory" ) +set( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library (.so) or not." ) +set( CPACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "package types to be produced " ) +set( COPYRIGHT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/copyright" ) +set( BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} ) + +if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in ) + file( READ "${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in" VER ) + + string( REGEX MATCH "ROCM_VERSION_MAJOR ([0-9]*)" _ ${VER} ) + set( ROCM_VERSION ${CMAKE_MATCH_1} ) + string( REGEX MATCH "ROCM_VERSION_MINOR ([0-9]*)" _ ${VER} ) + set( ROCM_VERSION "${ROCM_VERSION}.${CMAKE_MATCH_1}" ) + string( REGEX MATCH "ROCM_VERSION_PATCH ([0-9]*)" _ ${VER} ) + set( ROCM_VERSION "${ROCM_VERSION}.${CMAKE_MATCH_1}" ) + message( STATUS "ROCM_VERSION = ${ROCM_VERSION}" ) +else() + message( FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in does not exists." ) +endif() + +## Set the version +parse_rocm_version( ${ROCM_VERSION} ) +set_variables() + +if( DEFINED BUILD_ID ) + set( PACKAGE_BUILD_INFO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-${BUILD_ID}-${VERSION_HASH}" ) +else() + set( PACKAGE_BUILD_INFO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-9999-${VERSION_HASH}" ) +endif() + +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocmmod.in ${BUILD_DIR}/rocmmod @ONLY ) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.postinst ${BUILD_DIR}/postinst @ONLY ) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.prerm ${BUILD_DIR}/prerm @ONLY ) + +#Generate BUILD_INFO +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in ${BUILD_DIR}/rocm_version.h @ONLY ) + +#Make the rocmlib +set( SRCS rocm_version.cpp ) +add_library( ${CORE_TARGET} ${SRCS} ) + +set( CXX_FLAGS ${CXX_FLAGS} -g -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=c++11 ) +set( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,-z,nodelete -Wl,-no-undefined" ) +target_include_directories( ${CORE_TARGET} PRIVATE ${BUILD_DIR} ) + +## Set the VERSION and SOVERSION values +set( PATCH_STRING "${VERSION_PATCH}.${ROCM_LIBPATCH_VERSION}" ) +set( SO_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${PATCH_STRING}" ) +set_property( TARGET ${CORE_TARGET} PROPERTY VERSION "${SO_VERSION_STRING}" ) +set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${VERSION_MAJOR}" ) + + +#intallation directive +install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) +install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) +install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} ) + + +## Packaging directives +set ( CPACK_PACKAGE_NAME ${CORE_TARGET} ) +set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) +set ( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) +set ( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) +set ( CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH} ) +set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" ) +set ( CPACK_PACKAGE_CONTACT "ROCm Dev Support " ) +set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Radeon Open Compute (ROCm) Runtime software stack" ) +set ( CPACK_RESOURCE_FILE_LICENSE "${COPYRIGHT_FILE}" ) + +## packaging variables +if ( DEFINED ROCM_LIBPATCH_VERSION ) + set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}.${ROCM_LIBPATCH_VERSION}" ) + message ( STATUS "Using CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION}" ) +endif() + +## Debian package specific variables +message ( STATUS "Using CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) +set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) + +## RPM package specific variables + +## 'dist' breaks manual builds on debian systems due to empty Provides +execute_process( COMMAND rpm --eval %{?dist} + RESULT_VARIABLE PROC_RESULT + OUTPUT_VARIABLE EVAL_RESULT + OUTPUT_STRIP_TRAILING_WHITESPACE ) + +if ( PROC_RESULT EQUAL "0" AND NOT EVAL_RESULT STREQUAL "" ) + string ( APPEND CPACK_RPM_PACKAGE_RELEASE "%{?dist}" ) +endif() +message(STATUS "Using CPACK_RPM_PACKAGE_RELEASE: ${CPACK_RPM_PACKAGE_RELEASE}") +set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) + +# Debian package specific variables +set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) +set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) +set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) + +## RPM package specific variables +set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) +set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) +set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) + +if ( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) + set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) +endif ( ) + +## Include packaging +include ( CPack ) diff --git a/README.txt b/README.txt new file mode 100644 index 0000000000..e0e2a7e27d --- /dev/null +++ b/README.txt @@ -0,0 +1,93 @@ + +For building : + + git clone + + cd rocm-core; mkdir -p build ; cd build + + After this invoke cmake with the following variables define as deemed fit + + + cmake \ + -DCMAKE_CURRENT_BINARY_DIR=$PWD \ + -DCMAKE_CURRENT_SOURCE_DIR=$PWD/../ \ + -DCMAKE_VERBOSE_MAKEFILE=1 \ + -DCMAKE_INSTALL_PREFIX=./ \ + -DCPACK_GENERATOR=DEB \ + .. + + make + make install + make package + +After this the package "rocm-core_1.0.0-local_amd64.deb" will be generated accordingly + +The content of which will be the following : + +$dpkg -I rocm-core_1.0.0-local_amd64.deb + new Debian package, version 2.0. + size 6604 bytes: control archive=1608 bytes. + 285 bytes, 10 lines control + 191 bytes, 3 lines md5sums + 2360 bytes, 65 lines * postinst #!/bin/bash + 593 bytes, 25 lines * prerm #!/bin/bash + Architecture: amd64 + Description: Radeon Open Compute (ROCm) Runtime software stack + Homepage: https://github.com/RadeonOpenCompute/ROCm + Maintainer: ROCm Dev Support + Package: rocm-core + Priority: optional + Section: devel + Version: 1.0.0-local + Installed-Size: 70 + + +$dpkg -c rocm-core_1.0.0-local_amd64.deb +drwxrwxr-x root/root 0 2022-11-09 09:02 ./opt/ +drwxrwxr-x root/root 0 2022-11-09 09:02 ./opt/rocm/ +drwxrwxr-x root/root 0 2022-11-09 09:02 ./opt/rocm/include/ +-rw-r--r-- root/root 2970 2022-11-09 09:02 ./opt/rocm/include/rocm_version.h +drwxrwxr-x root/root 0 2022-11-09 09:02 ./opt/rocm/lib/ +lrwxrwxrwx root/root 0 2022-11-09 09:02 ./opt/rocm/lib/librocm-core.so -> librocm-core.so.1 +lrwxrwxrwx root/root 0 2022-11-09 09:02 ./opt/rocm/lib/librocm-core.so.1 -> librocm-core.so.1.0.0. +-rwxr-xr-x root/root 17096 2022-11-09 09:02 ./opt/rocm/lib/librocm-core.so.1.0.0. +-rw-r--r-- root/root 420 2022-11-09 09:02 ./opt/rocm/lib/rocmmod + + + +The flags for the lib would the following : + +$readelf -d ./opt/rocm/lib/librocm-core.so.1.0.0. + +Dynamic section at offset 0x2de0 contains 28 entries: + Tag Type Name/Value + 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6] + 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1] + 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] + 0x000000000000000e (SONAME) Library soname: [librocm-core.so.1] + 0x000000000000000c (INIT) 0x1000 + 0x000000000000000d (FINI) 0x12dc + 0x0000000000000019 (INIT_ARRAY) 0x3dd0 + 0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) + 0x000000000000001a (FINI_ARRAY) 0x3dd8 + 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) + 0x000000006ffffef5 (GNU_HASH) 0x2f0 + 0x0000000000000005 (STRTAB) 0x480 + 0x0000000000000006 (SYMTAB) 0x318 + 0x000000000000000a (STRSZ) 558 (bytes) + 0x000000000000000b (SYMENT) 24 (bytes) + 0x0000000000000003 (PLTGOT) 0x4000 + 0x0000000000000002 (PLTRELSZ) 168 (bytes) + 0x0000000000000014 (PLTREL) RELA + 0x0000000000000017 (JMPREL) 0x820 + 0x0000000000000007 (RELA) 0x760 + 0x0000000000000008 (RELASZ) 192 (bytes) + 0x0000000000000009 (RELAENT) 24 (bytes) + 0x000000006ffffffb (FLAGS_1) Flags: NODELETE + 0x000000006ffffffe (VERNEED) 0x6d0 + 0x000000006fffffff (VERNEEDNUM) 3 + 0x000000006ffffff0 (VERSYM) 0x6ae + 0x000000006ffffff9 (RELACOUNT) 3 + 0x0000000000000000 (NULL) 0x0 + + diff --git a/copyright b/copyright new file mode 100644 index 0000000000..6a2ccdfb1b --- /dev/null +++ b/copyright @@ -0,0 +1,37 @@ +The University of Illinois/NCSA +Open Source License (NCSA) + +Copyright (c) 2014-2017, Advanced Micro Devices, Inc. All rights reserved. + +Developed by: + + AMD Research and AMD HSA Software Development + + Advanced Micro Devices, Inc. + + www.amd.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal with the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + + - Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + - Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimers in + the documentation and/or other materials provided with the distribution. + - Neither the names of Advanced Micro Devices, Inc, + nor the names of its contributors may be used to endorse or promote + products derived from this Software without specific prior written + permission. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS WITH THE SOFTWARE. diff --git a/rocm-core.postinst b/rocm-core.postinst new file mode 100755 index 0000000000..728f6e6ff5 --- /dev/null +++ b/rocm-core.postinst @@ -0,0 +1,65 @@ +#!/bin/bash + +do_update_alternatives(){ + # skip update if program doesn't exist + command -v update-alternatives >/dev/null || return 0 + local altscore now + now=$(date -u +%s) # Number of seconds since 1 Jan 1970 + + # The reason for this approach rather than using the build number + # is to allow for jobs from different builds. In one build job the + # job number might be at 1200, whilst in a release job the number + # may be only 1. This approach assums that if you install a build + # with a different semantic version then the highest is the + # desired one, but if you install two with the same semver then + # the newest is the desired version. + + # Build up a score. It needs to fit in 32 bits + altscore=$((@VERSION_MAJOR@ - 3)) + altscore=$((altscore * 14 + @VERSION_MINOR@)) # Allow up to 14 minor + altscore=$((altscore * 14 + @VERSION_PATCH@)) # Allow up to 14 patch + + # So far if the version is less than 9 we have a number (altscore) + # that is less than 1175. 2**31/1175 is about 1.8 million. So + # multiply altscore by 1,000,000 and add in a factor of how many + # minutes have passed from an arbitary point in time (1,600,000,000 + # seconds after 1 Jan 1970 or Sep 13 12:26:40 2020) on the + # basis that no one is going to be installing a new version more + # often than every minute. This does get things wrong if a million + # minutes pass and you are downgrading, but the chances of someone + # waiting almost 2 years between installing a version and the + # previous patch level is small. + + + altscore=$((altscore*1000000+(now-1600000000)/60)) + + # Update the /opt/rocm symlink + update-alternatives --install "/opt/rocm" "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" "$altscore" + for loc in "/usr/share/modules/modulefiles" "/usr/local/Modules/modulefiles" "/usr/share/Modules/modulefiles" + do + if [ -d "$loc" ] + then + update-alternatives --install "$loc/rocmmod@ROCM_VERSION@" "rocmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore" + break; + fi + done + true +} + +if [ -e /etc/lsb-release ] && source /etc/lsb-release && [ "$DISTRIB_ID" = "Ubuntu" ] +then + case "$1" in + (configure) + do_update_alternatives + ;; + (abort-upgrade|abort-remove|abort-deconfigure) + echo "$1" + ;; + (*) + exit 0 + ;; + esac +else + do_update_alternatives +fi + diff --git a/rocm-core.prerm b/rocm-core.prerm new file mode 100755 index 0000000000..bb83e250bd --- /dev/null +++ b/rocm-core.prerm @@ -0,0 +1,25 @@ +#!/bin/bash + +do_update_alternatives(){ + # skip update if program doesn't exist + command -v update-alternatives >/dev/null || return 0 + # Update the /opt/rocm symlink + update-alternatives --remove "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" + update-alternatives --remove "rocmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod"|| true +} + +if [ -e /etc/lsb-release ] && source /etc/lsb-release && [ "$DISTRIB_ID" = "Ubuntu" ] +then + case "$1" in + (remove | upgrade) + do_update_alternatives + ;; + (purge) + ;; + (*) + exit 0 + ;; + esac +else + do_update_alternatives +fi diff --git a/rocm_version.cpp b/rocm_version.cpp new file mode 100644 index 0000000000..e8ac822258 --- /dev/null +++ b/rocm_version.cpp @@ -0,0 +1,77 @@ +#include "rocm_version.h" +#include +#include +#include + + +#define NULL_CHECK(ptr) if(!ptr) return VerIncorrecPararmeters; + + +#define CHECK_AND_REPORT_API_RESULT(val) do { \ + if(VerSuccess != val) { \ + const char *ErrStrings[VerErrorMAX]= { "VerSuccess", "VerIncorrecPararmeters", "VerValuesNotDefined" }; \ + fprintf(stderr, " API returned : %s \n", ErrStrings[val]); \ + fflush(stderr); \ + return val; \ + } \ + }while(0); + + + +VerErrors getROCmVersion(unsigned int* Major, unsigned int* Minor, unsigned int* Patch) { + + NULL_CHECK(Major) + NULL_CHECK(Minor) + NULL_CHECK(Patch) + + *Major=ROCM_VERSION_MAJOR; + *Minor=ROCM_VERSION_MINOR; + *Patch=ROCM_VERSION_PATCH; + + return VerSuccess; +} + + + +static VerErrors getBuildInfoLen( int* InfoStrlen ) { + + NULL_CHECK(InfoStrlen); +#if defined(ROCM_BUILD_INFO) + *InfoStrlen = 1 + strlen(ROCM_BUILD_INFO);//additional char for null termination +#else + return VerValuesNotDefined; +#endif //end defination checker + return VerSuccess; +} + +static VerErrors getBuildInfo( char* InfoString, int len ) { + + NULL_CHECK(InfoString); +#if defined(ROCM_BUILD_INFO) + + strcpy(InfoString,ROCM_BUILD_INFO); + InfoString[len]='\0'; +#else + return VerValuesNotDefined; +#endif //end defination checker + return VerSuccess; +} + +VerErrors printBuildInfo() { + + int lenstr=0; + VerErrors apiret=VerSuccess; + + apiret=getBuildInfoLen(&lenstr); + CHECK_AND_REPORT_API_RESULT(apiret); + + char* cstr=(char*) malloc(lenstr*sizeof(char)); + apiret=getBuildInfo(cstr,lenstr); + CHECK_AND_REPORT_API_RESULT(apiret); + + printf("\n Build Info of lib = [%s] \n",cstr); + + free(cstr); + + return VerSuccess; +} diff --git a/rocm_version.h.in b/rocm_version.h.in new file mode 100644 index 0000000000..03539232be --- /dev/null +++ b/rocm_version.h.in @@ -0,0 +1,92 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// The University of Illinois/NCSA +// Open Source License (NCSA) +// +// Copyright (c) 2014-2021, Advanced Micro Devices, Inc. All rights reserved. +// +// Developed by: +// +// AMD Research and AMD HSA Software Development +// +// Advanced Micro Devices, Inc. +// +// www.amd.com +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal with the Software without restriction, including without limitation +// the rights to use, copy, modify, merge, publish, distribute, sublicense, +// and/or sell copies of the Software, and to permit persons to whom the +// Software is furnished to do so, subject to the following conditions: +// +// - Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimers. +// - Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimers in +// the documentation and/or other materials provided with the distribution. +// - Neither the names of Advanced Micro Devices, Inc, +// nor the names of its contributors may be used to endorse or promote +// products derived from this Software without specific prior written +// permission. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +// THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS WITH THE SOFTWARE. +// +//////////////////////////////////////////////////////////////////////////////// + + +#ifndef _ROCM_VERSION_H_ +#define _ROCM_VERSION_H_ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#define LIB_API_PUBLIC __attribute__ ((visibility ("default"))) + + + +#define ROCM_VERSION_MAJOR 1 +#define ROCM_VERSION_MINOR 0 +#define ROCM_VERSION_PATCH 0 +#define ROCM_BUILD_INFO "@PACKAGE_BUILD_INFO@" + +typedef enum { + VerSuccess=0, + VerIncorrecPararmeters, + VerValuesNotDefined, + VerErrorMAX //This should always be last value in the enumerations +} VerErrors; + + +// API for getting the verion +// Return val : VerErros : API execution status. The parameters are valid only when the exetution status is SUCCESS==0 +LIB_API_PUBLIC VerErrors getROCmVersion(unsigned int* Major, unsigned int* Minor, unsigned int* Patch) __attribute__((nonnull)) ; +// Usage : +// int mj=0,mn=0,p=0,ret=0; +// ret=getROCMVersion(&mj,&mn,&p); +// if(ret !=VerSuccess ) // error occured +// +// check for the values and +// + + + +//API for building build info on console +LIB_API_PUBLIC VerErrors printBuildInfo(); + + +#ifdef __cplusplus +} // end extern "C" block +#endif + +#endif //_ROCM_VERSION_H_ header guard + diff --git a/rocmmod.in b/rocmmod.in new file mode 100644 index 0000000000..584c00582f --- /dev/null +++ b/rocmmod.in @@ -0,0 +1,16 @@ +#%Module1.0###################################################################### +## +## Rocm module +## + +module-whatis "adds `@CPACK_PACKAGING_INSTALL_PREFIX@/bin' to your PATH environment variable" + +proc ModulesHelp { } { + puts stderr "\tThe ROCM Module." +} + + +prepend-path PATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/bin:@CPACK_PACKAGING_INSTALL_PREFIX@/opencl/bin" +prepend-path CMAKE_PREFIX_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" +setenv ROCM_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" +setenv HIP_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@/hip" diff --git a/utils.cmake b/utils.cmake new file mode 100644 index 0000000000..d3431590e7 --- /dev/null +++ b/utils.cmake @@ -0,0 +1,156 @@ +################################################################################ +## +## The University of Illinois/NCSA +## Open Source License (NCSA) +## +## Copyright (c) 2014-2018, Advanced Micro Devices, Inc. All rights reserved. +## +## Developed by: +## +## AMD Research and AMD HSA Software Development +## +## Advanced Micro Devices, Inc. +## +## www.amd.com +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to +## deal with the Software without restriction, including without limitation +## the rights to use, copy, modify, merge, publish, distribute, sublicense, +## and#or sell copies of the Software, and to permit persons to whom the +## Software is furnished to do so, subject to the following conditions: +## +## - Redistributions of source code must retain the above copyright notice, +## this list of conditions and the following disclaimers. +## - Redistributions in binary form must reproduce the above copyright +## notice, this list of conditions and the following disclaimers in +## the documentation and#or other materials provided with the distribution. +## - Neither the names of Advanced Micro Devices, Inc, +## nor the names of its contributors may be used to endorse or promote +## products derived from this Software without specific prior written +## permission. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +## THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +## OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +## ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +## DEALINGS WITH THE SOFTWARE. +## +################################################################################ + +## Parses the VERSION_STRING variable and places +## the first, second and third number values in +## the major, minor and patch variables. +function( parse_rocm_version VERSION_STRING ) + + string ( FIND ${VERSION_STRING} "-" STRING_INDEX ) + + if ( ${STRING_INDEX} GREATER -1 ) + math ( EXPR STRING_INDEX "${STRING_INDEX} + 1" ) + string ( SUBSTRING ${VERSION_STRING} ${STRING_INDEX} -1 VERSION_BUILD ) + endif () + + string ( REGEX MATCHALL "[0123456789]+" VERSIONS ${VERSION_STRING} ) + list ( LENGTH VERSIONS VERSION_COUNT ) + + if ( ${VERSION_COUNT} GREATER 0) + list ( GET VERSIONS 0 MAJOR ) + set ( VERSION_MAJOR ${MAJOR} PARENT_SCOPE ) + set ( TEMP_VERSION_STRING "${MAJOR}" ) + endif () + + if ( ${VERSION_COUNT} GREATER 1 ) + list ( GET VERSIONS 1 MINOR ) + set ( VERSION_MINOR ${MINOR} PARENT_SCOPE ) + set ( TEMP_VERSION_STRING "${TEMP_VERSION_STRING}.${MINOR}" ) + endif () + + if ( ${VERSION_COUNT} GREATER 2 ) + list ( GET VERSIONS 2 PATCH ) + set ( VERSION_PATCH ${PATCH} PARENT_SCOPE ) + set ( TEMP_VERSION_STRING "${TEMP_VERSION_STRING}.${PATCH}" ) + endif () + + if ( DEFINED VERSION_BUILD ) + set ( VERSION_BUILD "${VERSION_BUILD}" PARENT_SCOPE ) + endif () + + set ( VERSION_STRING "${TEMP_VERSION_STRING}" PARENT_SCOPE ) + +endfunction () + + +## Sets cmake variables which can be derived from existing +function( set_variables ) + set( VERSION_COMMIT_COUNT 0 ) + set( VERSION_HASH "unknown" ) + + find_program( GIT NAMES git ) + + if( GIT ) + # Get branch commit (common ancestor) of current branch and master branch. + execute_process(COMMAND git merge-base HEAD origin/HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE GIT_MERGE_BASE + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE RESULT ) + + if( ${RESULT} EQUAL 0 ) + # Count commits from branch point. + execute_process(COMMAND git rev-list --count ${GIT_MERGE_BASE}..HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE VERSION_COMMIT_COUNT + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE RESULT ) + if(NOT ${RESULT} EQUAL 0 ) + set( VERSION_COMMIT_COUNT 0 ) + endif() + endif() + + # Get current short hash. + execute_process(COMMAND git rev-parse --short HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + OUTPUT_VARIABLE VERSION_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE RESULT ) + if( ${RESULT} EQUAL 0 ) + # Check for dirty workspace. + execute_process(COMMAND git diff --quiet + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE RESULT ) + if(${RESULT} EQUAL 1) + set(VERSION_HASH "${VERSION_HASH}-dirty") + endif() + else() + set( VERSION_HASH "unknown" ) + endif() + endif() + + if ( DEFINED CPACK_RPM_PACKAGE_RELEASE ) + set ( CPACK_RPM_PACKAGE_RELEASE ${CPACK_RPM_PACKAGE_RELEASE} PARENT_SCOPE ) + else() + set ( CPACK_RPM_PACKAGE_RELEASE "local" PARENT_SCOPE ) + endif() + + if ( DEFINED CPACK_DEBIAN_PACKAGE_RELEASE ) + set ( CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE} PARENT_SCOPE ) + else() + set ( CPACK_DEBIAN_PACKAGE_RELEASE "local" PARENT_SCOPE ) + endif() + + set( VERSION_COMMIT_COUNT "${VERSION_COMMIT_COUNT}" PARENT_SCOPE ) + set( VERSION_HASH "${VERSION_HASH}" PARENT_SCOPE ) + + message(STATUS "VERSION_MAJOR : ${VERSION_MAJOR}" ) + message(STATUS "VERSION_MINOR : ${VERSION_MINOR}" ) + message(STATUS "VERSION_PATCH : ${VERSION_PATCH}" ) + message(STATUS "VERSION_COMMIT_COUNT : ${VERSION_COMMIT_COUNT}" ) + message(STATUS "VERSION_HASH : ${VERSION_HASH}" ) + message(STATUS "CPACK_DEBIAN_PACKAGE_RELEASE : ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) + message(STATUS "CPACK_RPM_PACKAGE_RELEASE : ${CPACK_RPM_PACKAGE_RELEASE}" ) + +endfunction() + + From 6abd8b4da4cf16ca1afc565175d6fa4da6280fcb Mon Sep 17 00:00:00 2001 From: Ashutosh Mishra Date: Fri, 2 Dec 2022 22:43:40 +0530 Subject: [PATCH 03/61] Adding version info External modules are dependant on scraping .info/version file for their processing. This change is putting the file back for the same. Signed-off-by: Ashutosh Mishra Change-Id: I0a5b7b9c1e9902de6c374d770c6ba4b29e62c2fe --- CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54910944f2..3d9202fb5f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,12 +75,12 @@ endif() parse_rocm_version( ${ROCM_VERSION} ) set_variables() -if( DEFINED BUILD_ID ) - set( PACKAGE_BUILD_INFO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-${BUILD_ID}-${VERSION_HASH}" ) -else() - set( PACKAGE_BUILD_INFO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-9999-${VERSION_HASH}" ) +if( NOT DEFINED BUILD_ID ) + set( BUILD_ID "9999") endif() +set( PACKAGE_BUILD_INFO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-${BUILD_ID}-${VERSION_HASH}" ) + configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocmmod.in ${BUILD_DIR}/rocmmod @ONLY ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.postinst ${BUILD_DIR}/postinst @ONLY ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.prerm ${BUILD_DIR}/prerm @ONLY ) @@ -104,6 +104,8 @@ set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${VERSION_MAJOR}" ) #intallation directive +file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) +install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info ) install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} ) From 38959daacdd56c21391363231c99ce101d4d42d5 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Thu, 8 Dec 2022 22:16:08 -0600 Subject: [PATCH 04/61] SWDEV-354524 : Changing the module file name. Now modules can be loaded as module load rocm/x.x.x Change-Id: I6fe5b5fb9bb852a2bfac9b69ac0c96b75d4fb959 --- rocm-core.postinst | 3 ++- rocm-core.prerm | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/rocm-core.postinst b/rocm-core.postinst index 728f6e6ff5..9983886070 100755 --- a/rocm-core.postinst +++ b/rocm-core.postinst @@ -39,7 +39,8 @@ do_update_alternatives(){ do if [ -d "$loc" ] then - update-alternatives --install "$loc/rocmmod@ROCM_VERSION@" "rocmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore" + mkdir -p "$loc/rocm" + update-alternatives --install "$loc/rocm/@ROCM_VERSION@" "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore" break; fi done diff --git a/rocm-core.prerm b/rocm-core.prerm index bb83e250bd..1fba7c9752 100755 --- a/rocm-core.prerm +++ b/rocm-core.prerm @@ -5,7 +5,7 @@ do_update_alternatives(){ command -v update-alternatives >/dev/null || return 0 # Update the /opt/rocm symlink update-alternatives --remove "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" - update-alternatives --remove "rocmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod"|| true + update-alternatives --remove "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod"|| true } if [ -e /etc/lsb-release ] && source /etc/lsb-release && [ "$DISTRIB_ID" = "Ubuntu" ] From b89ee9ff8b904547eca2cbff1981836c706f0418 Mon Sep 17 00:00:00 2001 From: Ashutosh Mishra Date: Fri, 6 Jan 2023 12:37:49 +0530 Subject: [PATCH 05/61] Correcting version information Correted version in header for ROCm and so version. Computed libpatchversion from ROCm version.Corrected so version during build Signed-off-by: Ashutosh Mishra Change-Id: I55ad6c69352369872a40529cd5b108cbd4cd4bb1 --- CMakeLists.txt | 29 ++++++++++------------------- README.txt | 3 +++ rocm_version.h.in | 6 +++--- utils.cmake | 21 +++++++++++++++++++++ 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d9202fb5f..a5c17ba18a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,30 +51,22 @@ set( CMAKE_VERBOSE_MAKEFILE on ) include( utils.cmake ) include( GNUInstallDirs ) +#Parse Version +message( STATUS "ROCM_VERSION = ${ROCM_VERSION}" ) +parse_rocm_version( ${ROCM_VERSION} ) + set( CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm" CACHE PATH "default cpack directory" ) set( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library (.so) or not." ) set( CPACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "package types to be produced " ) set( COPYRIGHT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/copyright" ) set( BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} ) -if( EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in ) - file( READ "${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in" VER ) - - string( REGEX MATCH "ROCM_VERSION_MAJOR ([0-9]*)" _ ${VER} ) - set( ROCM_VERSION ${CMAKE_MATCH_1} ) - string( REGEX MATCH "ROCM_VERSION_MINOR ([0-9]*)" _ ${VER} ) - set( ROCM_VERSION "${ROCM_VERSION}.${CMAKE_MATCH_1}" ) - string( REGEX MATCH "ROCM_VERSION_PATCH ([0-9]*)" _ ${VER} ) - set( ROCM_VERSION "${ROCM_VERSION}.${CMAKE_MATCH_1}" ) - message( STATUS "ROCM_VERSION = ${ROCM_VERSION}" ) -else() - message( FATAL_ERROR "${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in does not exists." ) -endif() - -## Set the version -parse_rocm_version( ${ROCM_VERSION} ) +## Set variables set_variables() +set( SO_MAJOR "1") +set( SO_MINOR "0" ) + if( NOT DEFINED BUILD_ID ) set( BUILD_ID "9999") endif() @@ -97,10 +89,9 @@ set( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,-z,nodelete -Wl target_include_directories( ${CORE_TARGET} PRIVATE ${BUILD_DIR} ) ## Set the VERSION and SOVERSION values -set( PATCH_STRING "${VERSION_PATCH}.${ROCM_LIBPATCH_VERSION}" ) -set( SO_VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${PATCH_STRING}" ) +set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${ROCM_LIBPATCH_VERSION}" ) set_property( TARGET ${CORE_TARGET} PROPERTY VERSION "${SO_VERSION_STRING}" ) -set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${VERSION_MAJOR}" ) +set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" ) #intallation directive diff --git a/README.txt b/README.txt index e0e2a7e27d..42581aa1b1 100644 --- a/README.txt +++ b/README.txt @@ -14,6 +14,9 @@ For building : -DCMAKE_VERBOSE_MAKEFILE=1 \ -DCMAKE_INSTALL_PREFIX=./ \ -DCPACK_GENERATOR=DEB \ + -DCPACK_DEBIAN_PACKAGE_RELEASE="local.9999~20.04" \ + -DCPACK_RPM_PACKAGE_RELEASE="local.9999" \ + -DROCM_VERSION="5.5.0" \ .. make diff --git a/rocm_version.h.in b/rocm_version.h.in index 03539232be..869541ae11 100644 --- a/rocm_version.h.in +++ b/rocm_version.h.in @@ -53,10 +53,10 @@ extern "C" { #define LIB_API_PUBLIC __attribute__ ((visibility ("default"))) +#define ROCM_VERSION_MAJOR @VERSION_MAJOR@ +#define ROCM_VERSION_MINOR @VERSION_MINOR@ +#define ROCM_VERSION_PATCH @VERSION_PATCH@ -#define ROCM_VERSION_MAJOR 1 -#define ROCM_VERSION_MINOR 0 -#define ROCM_VERSION_PATCH 0 #define ROCM_BUILD_INFO "@PACKAGE_BUILD_INFO@" typedef enum { diff --git a/utils.cmake b/utils.cmake index d3431590e7..13fa9b8a17 100644 --- a/utils.cmake +++ b/utils.cmake @@ -128,6 +128,26 @@ function( set_variables ) endif() endif() + #set libpatch version + if(NOT DEFINED ROCM_LIBPATCH_VERSION) + set(ROCM_LIBPATCH_VERSION "${VERSION_MAJOR}") + string(LENGTH ${VERSION_MINOR} LENSTR) + if(LENSTR EQUAL 1) # length of version cannot be zero hence it would be 1 or greater + set(ROCM_LIBPATCH_VERSION "${ROCM_LIBPATCH_VERSION}0${VERSION_MINOR}") + else() # length is greater than 1 + set(ROCM_LIBPATCH_VERSION "${ROCM_LIBPATCH_VERSION}${VERSION_MINOR}") + endif() + + string(LENGTH ${VERSION_PATCH} LENSTR) + if(LENSTR EQUAL 1) # length of version cannot be zero hence it would be 1 or greater + set(ROCM_LIBPATCH_VERSION "${ROCM_LIBPATCH_VERSION}0${VERSION_PATCH}") + else() # length is greater than 1 + set(ROCM_LIBPATCH_VERSION "${ROCM_LIBPATCH_VERSION}${VERSION_PATCH}") + endif() + + set(ROCM_LIBPATCH_VERSION "${ROCM_LIBPATCH_VERSION}" PARENT_SCOPE ) + endif() + if ( DEFINED CPACK_RPM_PACKAGE_RELEASE ) set ( CPACK_RPM_PACKAGE_RELEASE ${CPACK_RPM_PACKAGE_RELEASE} PARENT_SCOPE ) else() @@ -146,6 +166,7 @@ function( set_variables ) message(STATUS "VERSION_MAJOR : ${VERSION_MAJOR}" ) message(STATUS "VERSION_MINOR : ${VERSION_MINOR}" ) message(STATUS "VERSION_PATCH : ${VERSION_PATCH}" ) + message(STATUS "ROCM_LIBPATCH_VERSION : ${ROCM_LIBPATCH_VERSION}" ) message(STATUS "VERSION_COMMIT_COUNT : ${VERSION_COMMIT_COUNT}" ) message(STATUS "VERSION_HASH : ${VERSION_HASH}" ) message(STATUS "CPACK_DEBIAN_PACKAGE_RELEASE : ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) From 3422b9ffe91100d87239314d6474ee511f8cef49 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Tue, 24 Jan 2023 10:55:12 -0600 Subject: [PATCH 06/61] Updating the readme Change-Id: Ia6decd0f47170c5ac2e47bada0e174e876779038 --- README.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.txt b/README.txt index 42581aa1b1..2636219c54 100644 --- a/README.txt +++ b/README.txt @@ -1,5 +1,14 @@ +Introduction: +rocm-core is a utility which can be used to get ROCm release version. +It also provides the Lmod modules files for the ROCm release. +getROCmVersion function provides the ROCm version. -For building : +Lmod module files can be loaded with the following commads. +module load rocm/x.y or +module load rocm + + +Build: git clone From 3118790ad5cdef7c7d5786bdef9d54e73c04ea12 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Mon, 6 Feb 2023 17:38:19 -0600 Subject: [PATCH 07/61] OSRB review update : Changing the license file to MIT Change-Id: I4a079df5ac10620f16649234064d54e922d246aa --- CMakeLists.txt | 45 +++++++++++++++------------------------------ copyright | 44 ++++++++++++++------------------------------ rocm_version.h.in | 43 +++++++++++++------------------------------ utils.cmake | 44 ++++++++++++++------------------------------ 4 files changed, 56 insertions(+), 120 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a5c17ba18a..0b769fe360 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,42 +1,26 @@ ################################################################################ ## -## The University of Illinois/NCSA -## Open Source License (NCSA) +## MIT License ## -## Copyright (c) 2014-2018, Advanced Micro Devices, Inc. All rights reserved. -## -## Developed by: -## -## AMD Research and AMD HSA Software Development -## -## Advanced Micro Devices, Inc. -## -## www.amd.com +## Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. ## ## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to -## deal with the Software without restriction, including without limitation -## the rights to use, copy, modify, merge, publish, distribute, sublicense, -## and#or sell copies of the Software, and to permit persons to whom the -## Software is furnished to do so, subject to the following conditions: +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: ## -## - Redistributions of source code must retain the above copyright notice, -## this list of conditions and the following disclaimers. -## - Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimers in -## the documentation and#or other materials provided with the distribution. -## - Neither the names of Advanced Micro Devices, Inc, -## nor the names of its contributors may be used to endorse or promote -## products derived from this Software without specific prior written -## permission. +## The above copyright notice and this permission notice shall be included in all +## copies or substantial portions of the Software. ## ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -## OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -## ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -## DEALINGS WITH THE SOFTWARE. +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. ## ################################################################################ @@ -144,6 +128,7 @@ set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/pre ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) +set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) diff --git a/copyright b/copyright index 6a2ccdfb1b..33843f52b6 100644 --- a/copyright +++ b/copyright @@ -1,37 +1,21 @@ -The University of Illinois/NCSA -Open Source License (NCSA) +MIT License -Copyright (c) 2014-2017, Advanced Micro Devices, Inc. All rights reserved. - -Developed by: - - AMD Research and AMD HSA Software Development - - Advanced Micro Devices, Inc. - - www.amd.com +Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to -deal with the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimers. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimers in - the documentation and/or other materials provided with the distribution. - - Neither the names of Advanced Micro Devices, Inc, - nor the names of its contributors may be used to endorse or promote - products derived from this Software without specific prior written - permission. +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS WITH THE SOFTWARE. +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/rocm_version.h.in b/rocm_version.h.in index 869541ae11..f9c11a9c6f 100644 --- a/rocm_version.h.in +++ b/rocm_version.h.in @@ -1,42 +1,25 @@ //////////////////////////////////////////////////////////////////////////////// // -// The University of Illinois/NCSA -// Open Source License (NCSA) +// MIT License // -// Copyright (c) 2014-2021, Advanced Micro Devices, Inc. All rights reserved. -// -// Developed by: -// -// AMD Research and AMD HSA Software Development -// -// Advanced Micro Devices, Inc. -// -// www.amd.com +// Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. // // Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to -// deal with the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: // -// - Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimers. -// - Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimers in -// the documentation and/or other materials provided with the distribution. -// - Neither the names of Advanced Micro Devices, Inc, -// nor the names of its contributors may be used to endorse or promote -// products derived from this Software without specific prior written -// permission. +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -// OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -// DEALINGS WITH THE SOFTWARE. +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // //////////////////////////////////////////////////////////////////////////////// diff --git a/utils.cmake b/utils.cmake index 13fa9b8a17..3b48f05bca 100644 --- a/utils.cmake +++ b/utils.cmake @@ -1,42 +1,26 @@ ################################################################################ ## -## The University of Illinois/NCSA -## Open Source License (NCSA) +## MIT License ## -## Copyright (c) 2014-2018, Advanced Micro Devices, Inc. All rights reserved. -## -## Developed by: -## -## AMD Research and AMD HSA Software Development -## -## Advanced Micro Devices, Inc. -## -## www.amd.com +## Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. ## ## Permission is hereby granted, free of charge, to any person obtaining a copy -## of this software and associated documentation files (the "Software"), to -## deal with the Software without restriction, including without limitation -## the rights to use, copy, modify, merge, publish, distribute, sublicense, -## and#or sell copies of the Software, and to permit persons to whom the -## Software is furnished to do so, subject to the following conditions: +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: ## -## - Redistributions of source code must retain the above copyright notice, -## this list of conditions and the following disclaimers. -## - Redistributions in binary form must reproduce the above copyright -## notice, this list of conditions and the following disclaimers in -## the documentation and#or other materials provided with the distribution. -## - Neither the names of Advanced Micro Devices, Inc, -## nor the names of its contributors may be used to endorse or promote -## products derived from this Software without specific prior written -## permission. +## The above copyright notice and this permission notice shall be included in all +## copies or substantial portions of the Software. ## ## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR ## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -## THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR -## OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -## ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -## DEALINGS WITH THE SOFTWARE. +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. ## ################################################################################ From c9f19353250fbbf147ef0c40d71672813f0d21e2 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Wed, 15 Feb 2023 15:13:03 -0600 Subject: [PATCH 08/61] SWDEV-383541 : Updating the HIP_PATH in env Change-Id: I8a58fe684ce1a6f076d41faf0365d19f11862623 --- rocmmod.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rocmmod.in b/rocmmod.in index 584c00582f..6acde293f8 100644 --- a/rocmmod.in +++ b/rocmmod.in @@ -10,7 +10,7 @@ proc ModulesHelp { } { } -prepend-path PATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/bin:@CPACK_PACKAGING_INSTALL_PREFIX@/opencl/bin" +prepend-path PATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/bin" prepend-path CMAKE_PREFIX_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" setenv ROCM_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" -setenv HIP_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@/hip" +setenv HIP_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" From 6794b39fffb2b21042d0f4d270107e3409793868 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Fri, 3 Mar 2023 09:24:05 -0600 Subject: [PATCH 09/61] SWDEV-354524 - Adding the changelog for ROCM 5.5.0 release Change-Id: I166bc97a9c8a80744d6bde23d180864c3c16d271 --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000..294b597e90 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +Change Logs for rocm-core + +Unreleased for ROCm5.5.0 + - Added module file support for ROCm. + - From ROCm5.5.0 release ROCm module files can be loaded as rocm/5.5.0 From 2acbecc1b9e3e669627573c707d2137a5e3b02ad Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Fri, 3 Mar 2023 00:24:25 -0800 Subject: [PATCH 10/61] SWDEV-351540 - ASAN packaging for rocm-core Package only ASAN libraries Component based install Suffix "asan" added to package name Change-Id: Ic758eefef27742df3a4a4301fd3661714de4bb36 --- CMakeLists.txt | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b769fe360..0b6c24edd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ set( SRCS rocm_version.cpp ) add_library( ${CORE_TARGET} ${SRCS} ) set( CXX_FLAGS ${CXX_FLAGS} -g -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=c++11 ) -set( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,-z,nodelete -Wl,-no-undefined" ) +set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete -Wl,-no-undefined" ) target_include_directories( ${CORE_TARGET} PRIVATE ${BUILD_DIR} ) ## Set the VERSION and SOVERSION values @@ -77,17 +77,25 @@ set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${ROCM_LIBPATCH_VERSION}" ) set_property( TARGET ${CORE_TARGET} PROPERTY VERSION "${SO_VERSION_STRING}" ) set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" ) +if(ENABLE_ASAN_PACKAGING) + # Only libraries required for ASAN Package + set( CPACK_COMPONENTS_ALL asan ) + set(COMP_TYPE "asan") +else() + set( CPACK_COMPONENTS_ALL runtime ) + set(COMP_TYPE "runtime") +endif() #intallation directive file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) -install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info ) -install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) -install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} ) - +install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT runtime ) +install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + COMPONENT ${COMP_TYPE} ) +install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT runtime ) +install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) ## Packaging directives -set ( CPACK_PACKAGE_NAME ${CORE_TARGET} ) set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) set ( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) set ( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) @@ -96,7 +104,6 @@ set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERS set ( CPACK_PACKAGE_CONTACT "ROCm Dev Support " ) set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Radeon Open Compute (ROCm) Runtime software stack" ) set ( CPACK_RESOURCE_FILE_LICENSE "${COPYRIGHT_FILE}" ) - ## packaging variables if ( DEFINED ROCM_LIBPATCH_VERSION ) set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}.${ROCM_LIBPATCH_VERSION}" ) @@ -104,10 +111,18 @@ if ( DEFINED ROCM_LIBPATCH_VERSION ) endif() ## Debian package specific variables +set ( CPACK_DEB_COMPONENT_INSTALL ON ) +set ( CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) +# ASAN package name +set ( CPACK_DEBIAN_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) message ( STATUS "Using CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) ## RPM package specific variables +set ( CPACK_RPM_COMPONENT_INSTALL ON ) +set ( CPACK_RPM_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) +# ASAN package name +set ( CPACK_RPM_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) ## 'dist' breaks manual builds on debian systems due to empty Provides execute_process( COMMAND rpm --eval %{?dist} @@ -124,13 +139,17 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) +if(NOT ENABLE_ASAN_PACKAGING) + set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) +endif() ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) -set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) +if(NOT ENABLE_ASAN_PACKAGING) + set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) + set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) +endif() if ( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) From 572f1cc601003beee7f93baaed7a4bb2241f17a3 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Tue, 14 Mar 2023 10:43:32 -0700 Subject: [PATCH 11/61] SWDEV-351540 - Improvements for ASAN changes in rocm-core License file added to rocm-core asan and normal package Package description updated for ASAN package Added rocm-core-asan dependency to rocm-core, so that removing rocm-core will cleanup all asan pacakges as well Added component name to cpack post install variables Change-Id: Id8b69b4469ff3c66a6bd32503defd6411ce3b6c7 --- CMakeLists.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b6c24edd7..6a8743d24c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,10 +80,12 @@ set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" ) if(ENABLE_ASAN_PACKAGING) # Only libraries required for ASAN Package set( CPACK_COMPONENTS_ALL asan ) - set(COMP_TYPE "asan") + set( COMP_TYPE "asan" ) + set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) AddressSanitizer Instrumented Runtime software stack" ) else() set( CPACK_COMPONENTS_ALL runtime ) - set(COMP_TYPE "runtime") + set( COMP_TYPE "runtime" ) + set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) Runtime software stack" ) endif() #intallation directive @@ -95,6 +97,10 @@ install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT runtime ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) +# License file +install(FILES ${COPYRIGHT_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt COMPONENT runtime) +install(FILES ${COPYRIGHT_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR}-asan RENAME LICENSE.txt COMPONENT asan) + ## Packaging directives set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) set ( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) @@ -102,7 +108,7 @@ set ( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) set ( CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH} ) set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" ) set ( CPACK_PACKAGE_CONTACT "ROCm Dev Support " ) -set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Radeon Open Compute (ROCm) Runtime software stack" ) +set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PKG_DESCRIPTION}" ) set ( CPACK_RESOURCE_FILE_LICENSE "${COPYRIGHT_FILE}" ) ## packaging variables if ( DEFINED ROCM_LIBPATCH_VERSION ) @@ -138,18 +144,16 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) +set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -if(NOT ENABLE_ASAN_PACKAGING) - set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) -endif() +set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) +set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -if(NOT ENABLE_ASAN_PACKAGING) - set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) - set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) -endif() +set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) +set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) if ( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) From f347955757a893f9a9c12110f530ee4a87c48748 Mon Sep 17 00:00:00 2001 From: Icarus Sparry Date: Wed, 5 Apr 2023 07:16:56 +0000 Subject: [PATCH 12/61] Update rocm module for MANPATH Allow access to the manuals for llvm Change-Id: Iea4c83412ff2defb0a2a013aab1a555eb3e24e8c Signed-off-by: Icarus Sparry --- rocmmod.in | 1 + 1 file changed, 1 insertion(+) diff --git a/rocmmod.in b/rocmmod.in index 6acde293f8..ba5c23780d 100644 --- a/rocmmod.in +++ b/rocmmod.in @@ -11,6 +11,7 @@ proc ModulesHelp { } { prepend-path PATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/bin" +prepend-path MANPATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_MANDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/share/man1" prepend-path CMAKE_PREFIX_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" setenv ROCM_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" setenv HIP_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" From 8ce1529027a789e51758f00c400acf148c4f3765 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Thu, 18 May 2023 05:22:02 -0700 Subject: [PATCH 13/61] For testing purpose removing the dependency of rocm-core-asan with rocm-core The change is made temporarily for testing the ASAN jenkins build. Need to revert this change after testing Change-Id: Icbfcfec423170114becdc82696afcf54b6d79d48 --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a8743d24c..6f68bb9a8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,13 +144,15 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) -set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) +# TODO: Need to enable this later :Commenting for testing purpose +#set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) -set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) +# TODO: Need to enable this later :Commenting for testing purpose +#set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) From 7cd7ed199a98c85e22be6216ebb38142128d654d Mon Sep 17 00:00:00 2001 From: ROCm CI Service Account <66695075+rocm-ci@users.noreply.github.com> Date: Tue, 25 Jul 2023 23:15:01 +0530 Subject: [PATCH 14/61] merge release code into development (#1) * SWDEV-383541 : Updating the HIP_PATH in env Change-Id: I8a58fe684ce1a6f076d41faf0365d19f11862623 (cherry picked from commit c9f19353250fbbf147ef0c40d71672813f0d21e2) * OSRB review update : Changing the license file to MIT Change-Id: I4a079df5ac10620f16649234064d54e922d246aa (cherry picked from commit 3118790ad5cdef7c7d5786bdef9d54e73c04ea12) --------- Co-authored-by: Nirmal Unnikrishnan From be7ab0a514e5e8f5605111c41e4e19d52c5e2158 Mon Sep 17 00:00:00 2001 From: nunnikri <71024015+nunnikri@users.noreply.github.com> Date: Tue, 25 Jul 2023 13:52:55 -0700 Subject: [PATCH 15/61] Revert "merge release code into development (#1)" (#3) This reverts commit 7cd7ed199a98c85e22be6216ebb38142128d654d. From c0331f38c70d3a68924c594669169007867b1d16 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Fri, 3 Mar 2023 00:24:25 -0800 Subject: [PATCH 16/61] SWDEV-351540 - ASAN packaging for rocm-core Package only ASAN libraries Component based install Suffix "asan" added to package name Change-Id: Ic758eefef27742df3a4a4301fd3661714de4bb36 --- CMakeLists.txt | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b769fe360..0b6c24edd7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,7 +69,7 @@ set( SRCS rocm_version.cpp ) add_library( ${CORE_TARGET} ${SRCS} ) set( CXX_FLAGS ${CXX_FLAGS} -g -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=c++11 ) -set( CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,-z,nodelete -Wl,-no-undefined" ) +set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete -Wl,-no-undefined" ) target_include_directories( ${CORE_TARGET} PRIVATE ${BUILD_DIR} ) ## Set the VERSION and SOVERSION values @@ -77,17 +77,25 @@ set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${ROCM_LIBPATCH_VERSION}" ) set_property( TARGET ${CORE_TARGET} PROPERTY VERSION "${SO_VERSION_STRING}" ) set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" ) +if(ENABLE_ASAN_PACKAGING) + # Only libraries required for ASAN Package + set( CPACK_COMPONENTS_ALL asan ) + set(COMP_TYPE "asan") +else() + set( CPACK_COMPONENTS_ALL runtime ) + set(COMP_TYPE "runtime") +endif() #intallation directive file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) -install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info ) -install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE ) -install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} ) - +install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT runtime ) +install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + COMPONENT ${COMP_TYPE} ) +install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT runtime ) +install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) ## Packaging directives -set ( CPACK_PACKAGE_NAME ${CORE_TARGET} ) set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) set ( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) set ( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) @@ -96,7 +104,6 @@ set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERS set ( CPACK_PACKAGE_CONTACT "ROCm Dev Support " ) set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Radeon Open Compute (ROCm) Runtime software stack" ) set ( CPACK_RESOURCE_FILE_LICENSE "${COPYRIGHT_FILE}" ) - ## packaging variables if ( DEFINED ROCM_LIBPATCH_VERSION ) set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}.${ROCM_LIBPATCH_VERSION}" ) @@ -104,10 +111,18 @@ if ( DEFINED ROCM_LIBPATCH_VERSION ) endif() ## Debian package specific variables +set ( CPACK_DEB_COMPONENT_INSTALL ON ) +set ( CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) +# ASAN package name +set ( CPACK_DEBIAN_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) message ( STATUS "Using CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) ## RPM package specific variables +set ( CPACK_RPM_COMPONENT_INSTALL ON ) +set ( CPACK_RPM_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) +# ASAN package name +set ( CPACK_RPM_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) ## 'dist' breaks manual builds on debian systems due to empty Provides execute_process( COMMAND rpm --eval %{?dist} @@ -124,13 +139,17 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) +if(NOT ENABLE_ASAN_PACKAGING) + set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) +endif() ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) -set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) +if(NOT ENABLE_ASAN_PACKAGING) + set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) + set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) +endif() if ( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) From 50dd0fd2fb3c089ba44d2ddd35072428c2bf02b2 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Tue, 14 Mar 2023 10:43:32 -0700 Subject: [PATCH 17/61] SWDEV-351540 - Improvements for ASAN changes in rocm-core License file added to rocm-core asan and normal package Package description updated for ASAN package Added rocm-core-asan dependency to rocm-core, so that removing rocm-core will cleanup all asan pacakges as well Added component name to cpack post install variables Change-Id: Id8b69b4469ff3c66a6bd32503defd6411ce3b6c7 --- CMakeLists.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b6c24edd7..6a8743d24c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,10 +80,12 @@ set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" ) if(ENABLE_ASAN_PACKAGING) # Only libraries required for ASAN Package set( CPACK_COMPONENTS_ALL asan ) - set(COMP_TYPE "asan") + set( COMP_TYPE "asan" ) + set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) AddressSanitizer Instrumented Runtime software stack" ) else() set( CPACK_COMPONENTS_ALL runtime ) - set(COMP_TYPE "runtime") + set( COMP_TYPE "runtime" ) + set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) Runtime software stack" ) endif() #intallation directive @@ -95,6 +97,10 @@ install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT runtime ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) +# License file +install(FILES ${COPYRIGHT_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt COMPONENT runtime) +install(FILES ${COPYRIGHT_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR}-asan RENAME LICENSE.txt COMPONENT asan) + ## Packaging directives set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) set ( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) @@ -102,7 +108,7 @@ set ( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) set ( CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH} ) set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" ) set ( CPACK_PACKAGE_CONTACT "ROCm Dev Support " ) -set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Radeon Open Compute (ROCm) Runtime software stack" ) +set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PKG_DESCRIPTION}" ) set ( CPACK_RESOURCE_FILE_LICENSE "${COPYRIGHT_FILE}" ) ## packaging variables if ( DEFINED ROCM_LIBPATCH_VERSION ) @@ -138,18 +144,16 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) +set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -if(NOT ENABLE_ASAN_PACKAGING) - set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) -endif() +set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) +set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -if(NOT ENABLE_ASAN_PACKAGING) - set ( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) - set ( CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) -endif() +set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) +set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) if ( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) From 57b5e98d9267f6ddf841a5dcdbf0bda763df4723 Mon Sep 17 00:00:00 2001 From: Icarus Sparry Date: Wed, 5 Apr 2023 07:16:56 +0000 Subject: [PATCH 18/61] Update rocm module for MANPATH Allow access to the manuals for llvm Change-Id: Iea4c83412ff2defb0a2a013aab1a555eb3e24e8c Signed-off-by: Icarus Sparry --- rocmmod.in | 1 + 1 file changed, 1 insertion(+) diff --git a/rocmmod.in b/rocmmod.in index 6acde293f8..ba5c23780d 100644 --- a/rocmmod.in +++ b/rocmmod.in @@ -11,6 +11,7 @@ proc ModulesHelp { } { prepend-path PATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/bin" +prepend-path MANPATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_MANDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/share/man1" prepend-path CMAKE_PREFIX_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" setenv ROCM_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" setenv HIP_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" From 86f7d52d97db856381861a9524d10ee971c264c3 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Thu, 18 May 2023 05:22:02 -0700 Subject: [PATCH 19/61] For testing purpose removing the dependency of rocm-core-asan with rocm-core The change is made temporarily for testing the ASAN jenkins build. Need to revert this change after testing Change-Id: Icbfcfec423170114becdc82696afcf54b6d79d48 --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a8743d24c..6f68bb9a8e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,13 +144,15 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) -set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) +# TODO: Need to enable this later :Commenting for testing purpose +#set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) -set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) +# TODO: Need to enable this later :Commenting for testing purpose +#set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) From 3d625f35e8eb263fa8292e0ebe224024260155a6 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Tue, 25 Jul 2023 17:36:28 -0700 Subject: [PATCH 20/61] SWDEV-366827 - Header file installation path changed as per file reorganization Change-Id: Idb94bd3c4cb32fa11ee6821b62ccd04d77a830e8 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f68bb9a8e..271c6647e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT ${COMP_TYPE} ) -install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT runtime ) +install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core COMPONENT runtime ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) # License file From fcafd602e3eb7fe16b4f86f1c6d2938603b93385 Mon Sep 17 00:00:00 2001 From: nunnikri <71024015+nunnikri@users.noreply.github.com> Date: Wed, 26 Jul 2023 13:01:42 -0700 Subject: [PATCH 21/61] Update CHANGELOG.md Update CHANGELOG for ROCm5.6 release --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 294b597e90..bf05b0d1ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ Change Logs for rocm-core +ROCm5.6.0 release + - Added initial support for Adress Sanitizer(ASAN) enabled builds. + - Full support of ASAN will be coming in later release -Unreleased for ROCm5.5.0 +ROCm5.5.0 release - Added module file support for ROCm. - From ROCm5.5.0 release ROCm module files can be loaded as rocm/5.5.0 From cf852844b5b9efc011948f80194f219994a3540e Mon Sep 17 00:00:00 2001 From: nunnikri <71024015+nunnikri@users.noreply.github.com> Date: Wed, 26 Jul 2023 13:02:06 -0700 Subject: [PATCH 22/61] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf05b0d1ad..dacf8140a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ Change Logs for rocm-core + ROCm5.6.0 release - Added initial support for Adress Sanitizer(ASAN) enabled builds. - Full support of ASAN will be coming in later release From 7c45d24f0697502148e5afedb77ba8f8376e4922 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Tue, 25 Jul 2023 17:36:28 -0700 Subject: [PATCH 23/61] SWDEV-366827 - Header file installation path changed as per file reorganization Change-Id: Idb94bd3c4cb32fa11ee6821b62ccd04d77a830e8 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f68bb9a8e..271c6647e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -94,7 +94,7 @@ install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT ${COMP_TYPE} ) -install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT runtime ) +install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core COMPONENT runtime ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) # License file From 86b7e2ff4f54f945076b704232a32b47893d5e44 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Wed, 2 Aug 2023 13:34:37 -0400 Subject: [PATCH 24/61] Revert "For testing purpose removing the dependency of rocm-core-asan with rocm-core" This reverts commit 8ce1529027a789e51758f00c400acf148c4f3765. Reason for revert: Change-Id: Ie7618c7aa2b3d71efba950e296b48e728c651ff7 --- CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 271c6647e9..61e65d4ba8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,15 +144,13 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) -# TODO: Need to enable this later :Commenting for testing purpose -#set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) +set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) -# TODO: Need to enable this later :Commenting for testing purpose -#set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) +set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) From 6fa9abf3f16747f44a5f8506900b4a1819a3e65a Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Wed, 2 Aug 2023 13:34:37 -0400 Subject: [PATCH 25/61] Revert "For testing purpose removing the dependency of rocm-core-asan with rocm-core" This reverts commit 8ce1529027a789e51758f00c400acf148c4f3765. Reason for revert: Change-Id: Ie7618c7aa2b3d71efba950e296b48e728c651ff7 --- CMakeLists.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 271c6647e9..61e65d4ba8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -144,15 +144,13 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) -# TODO: Need to enable this later :Commenting for testing purpose -#set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) +set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) -# TODO: Need to enable this later :Commenting for testing purpose -#set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) +set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) From f77cd2cca186da2e46f86df73be0450a2a020825 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Thu, 3 Aug 2023 14:26:45 -0700 Subject: [PATCH 26/61] SWDEV-415345 - Correct the installation path of rocm_version.h header file Added file reorg backward compatibility support by creating wrapper header file. Change-Id: Iee4644c8ae51ba508c21abb765a1e1d974dc6e97 --- CMakeLists.txt | 27 ++++++++++++++ header_template.hpp.in | 48 +++++++++++++++++++++++++ rocm-core-backward-compat.cmake | 63 +++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 header_template.hpp.in create mode 100644 rocm-core-backward-compat.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 61e65d4ba8..7a2763a10b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,10 @@ set( CPACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "package types to be produced " set( COPYRIGHT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/copyright" ) set( BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} ) +if(NOT ENABLE_ASAN_PACKAGING) + option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compatibility" OFF) +endif() + ## Set variables set_variables() @@ -64,6 +68,29 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.prerm ${BUILD_DIR}/prerm @ #Generate BUILD_INFO configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in ${BUILD_DIR}/rocm_version.h @ONLY ) +#File reorg Backward compatibility function +if(NOT WIN32) + if(FILE_REORG_BACKWARD_COMPATIBILITY) + # To enabe/disable #error in wrapper header files + if(NOT DEFINED ROCM_HEADER_WRAPPER_WERROR) + if(DEFINED ENV{ROCM_HEADER_WRAPPER_WERROR}) + set(ROCM_HEADER_WRAPPER_WERROR "$ENV{ROCM_HEADER_WRAPPER_WERROR}" + CACHE STRING "Header wrapper warnings as errors.") + else() + set(ROCM_HEADER_WRAPPER_WERROR "OFF" CACHE STRING "Header wrapper warnings as errors.") + endif() + endif() + + if(ROCM_HEADER_WRAPPER_WERROR) + set(deprecated_error 1) + else() + set(deprecated_error 0) + endif() + + include(rocm-core-backward-compat.cmake) + endif() #FILE_REORG_BACKWARD_COMPATIBILITY +endif() + #Make the rocmlib set( SRCS rocm_version.cpp ) add_library( ${CORE_TARGET} ${SRCS} ) diff --git a/header_template.hpp.in b/header_template.hpp.in new file mode 100644 index 0000000000..0d8c481e90 --- /dev/null +++ b/header_template.hpp.in @@ -0,0 +1,48 @@ +/* + MIT License + + Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + */ +#ifndef @include_guard@ +#define @include_guard@ + +#ifndef ROCM_HEADER_WRAPPER_WERROR +#define ROCM_HEADER_WRAPPER_WERROR @deprecated_error@ +#endif +#if ROCM_HEADER_WRAPPER_WERROR /* ROCM_HEADER_WRAPPER_WERROR 1 */ +#error "@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ " +#else /* ROCM_HEADER_WRAPPER_WERROR 0 */ +#if defined(__GNUC__) +#warning "@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ " +#else +#pragma message ("@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ ") +#endif +#endif /* ROCM_HEADER_WRAPPER_WERROR */ + +@include_statements@ + +@hashzero_check@ + +@file_contents@ + +@hash_endif@ + +#endif diff --git a/rocm-core-backward-compat.cmake b/rocm-core-backward-compat.cmake new file mode 100644 index 0000000000..e96572e669 --- /dev/null +++ b/rocm-core-backward-compat.cmake @@ -0,0 +1,63 @@ +# Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +cmake_minimum_required(VERSION 3.16.8) + +set(ROCM_CORE_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(ROCM_CORE_WRAPPER_DIR ${ROCM_CORE_BUILD_DIR}/wrapper_dir) +set(ROCM_CORE_WRAPPER_INC_DIR ${ROCM_CORE_WRAPPER_DIR}/include) +set(headerfile_dir "rocm-core") + +#Function to set actual file contents in wrapper files +#Some components grep for the contents in the file +function(set_file_contents input_file) + set(hashzero_check "#if 0 +/* The following is a copy of the original file for the benefit of build systems which grep for values + * in this file rather than preprocess it. This is just for backward compatibility */") + + file(READ ${input_file} file_contents) + set(hash_endif "#endif") + get_filename_component(file_name ${input_file} NAME) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/header_template.hpp.in ${ROCM_CORE_WRAPPER_INC_DIR}/${file_name}) +endfunction() + +#use header template file and generate wrapper header files +function(generate_wrapper_header) + file(MAKE_DIRECTORY ${ROCM_CORE_WRAPPER_INC_DIR}) + + #find all header files + file(GLOB include_files ${ROCM_CORE_BUILD_DIR}/*.h) + #Create wrapper files + foreach(header_file ${include_files}) + # set include guard + get_filename_component(INC_GAURD_NAME ${header_file} NAME_WE) + string(TOUPPER ${INC_GAURD_NAME} INC_GAURD_NAME) + set(include_guard "ROCM_CORE_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) + set(include_statements "#include \"${headerfile_dir}/${file_name}\"\n") + set_file_contents(${header_file}) + endforeach() + +endfunction() + +#Use template header file and generater wrapper header files +generate_wrapper_header() +install(DIRECTORY ${ROCM_CORE_WRAPPER_INC_DIR} DESTINATION . COMPONENT runtime) + From 478270cb11849a94a61e6f6b2d00486b08311b42 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Thu, 31 Aug 2023 14:28:49 -0500 Subject: [PATCH 27/61] SWDEV-310152 : Adding script to convert RUNPATH to RPATH in libs/bins Change-Id: Ic6c49544cb7450384592b4f5609fb394f1f12f02 --- CHANGELOG.md | 11 +++- CMakeLists.txt | 3 ++ runpath_to_rpath.py | 127 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 runpath_to_rpath.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 294b597e90..7be9b06418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ Change Logs for rocm-core -Unreleased for ROCm5.5.0 + +Unreleased ROCm6.0.0 release + - Added script to convert RUNPATH in libraries and binaries to RPATH. + - Disabled ROCm file reorg backward compatibility + +ROCm5.6.0 release + - Added initial support for Adress Sanitizer(ASAN) enabled builds. + - Full support of ASAN will be coming in later release + +ROCm5.5.0 release - Added module file support for ROCm. - From ROCm5.5.0 release ROCm module files can be loaded as rocm/5.5.0 diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a2763a10b..3597012ca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,7 @@ install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT ${COMP_TYPE} ) install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core COMPONENT runtime ) +install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runpath_to_rpath.py DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/rocm-core COMPONENT runtime ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) # License file @@ -173,12 +174,14 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) +set ( CPACK_DEBIAN_PACKAGE_DEPENDS "patchelf" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) +set ( CPACK_RPM_PACKAGE_REQUIRES "patchelf" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) diff --git a/runpath_to_rpath.py b/runpath_to_rpath.py new file mode 100644 index 0000000000..0b93b51694 --- /dev/null +++ b/runpath_to_rpath.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +################################################################################ +## +## MIT License +## +## Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included in all +## copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. +## +################################################################################ + +import os +import sys +import subprocess +import argparse +import pathlib + +try: + from elftools.elf.elffile import ELFFile + from elftools.elf.dynamic import DynamicSection + from elftools.common.exceptions import ELFError +except ImportError: + print("Error : pyelftools failed to import.\n" + "Run \'pip3 install pyelftools\' to install the prerequisite\n") + +# Function remove the runpath from the binary +def remove_runpath(filename) : + ''' Remove the DT_RUNPATH tag from filename''' + REMOVE_RPATH_COMMAND = ['patchelf', '--remove-rpath', filename] + print("Executing the command : ", REMOVE_RPATH_COMMAND) + subprocess.run(REMOVE_RPATH_COMMAND, check=True) + +def add_rpath(filename, runpath) : + ''' Use runpath and add it as DT_PATH tag in filename''' + ADD_RPATH_COMMAND = ['patchelf', '--force-rpath', '--set-rpath', runpath, filename] + print("Executing the command : ", ADD_RPATH_COMMAND) + subprocess.run(ADD_RPATH_COMMAND, check=True) + +def update_rpath(search_path, excludes) : + ''' Function helps to change DT_RUNPATH in libraries and binaries in search_path to DT_RPATH. + Its done with the following steps : + 1. Check all if the file is an ELF except in excludes folder + 2. Read and store the DT_RUNPATH from the binaries/libraries. + 3. Delete DT_RUNPATH and readd it as DT_RPATH ''' + for path, dirs, files in os.walk(search_path, topdown=True, followlinks=True): + dirs[:] = [d for d in dirs if d not in excludes] + print( dirs ) + for filename in files: + filename = os.path.join(path, filename) + print("Opening file ", filename) + # Open the file and check if its ELF file + try : + with open(filename, 'rb') as file: + elffile = ELFFile(file) + for section in elffile.iter_sections(): + if not isinstance(section, DynamicSection): + continue + for tag in section.iter_tags(): + if tag.entry.d_tag == 'DT_RUNPATH': + runpath = tag.runpath + print(runpath) + remove_runpath(filename) + add_rpath(filename, runpath) + break + break + except ELFError: + print("Discarding file as its not an ELF file", filename) + continue + except FileNotFoundError: + print("Discarding file with bad links", filename) + continue + except OSError: + print("Discarding file with OS error", filename) + continue + except Exception as ex: + print("Discarding file ", filename, ex) + continue + +def main(): + # The script expect a search folder as parameter. It finds all ELF files and updates RPATH + argparser = argparse.ArgumentParser( + usage='usage: %(prog)s ', + description='Find the ELF files in the specified folder and convert the RUNPATH to RPATH. \n', + add_help=False, + prog='runpath_to_rpath.py') + + argparser.add_argument('searchdir', + nargs='?', type=pathlib.Path, default=None, + help='Folder to search for ELF file. \nPlease note: Any folder with name llvm in that path will be discarded') + argparser.add_argument('-h', '--help', + action='store_true', dest='help', + help='Display this information') + + args = argparser.parse_args() + if args.help or not args.searchdir: + argparser.print_help() + sys.exit(0) + + # pyelftools is a mandatory requirement for this script. Exit if requirement is not met + if 'ELFFile' not in globals(): + print('Please install pyelftools using \'pip3 install pyelftools\' ' + + 'before using the script : runpath_to_rpath.py') + sys.exit(0) + + # Find the elf files in the serach path and update RPATH + excludes = ['llvm', 'rocm-llvm', 'llvm-alt'] + update_rpath(args.searchdir, excludes) + print("Done with rpath update") + +if __name__ == "__main__": + main() From d448048fa7e72fd78eac827f4b69f9c3a0254154 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Mon, 16 Oct 2023 15:23:53 -0500 Subject: [PATCH 28/61] SWDEV-427268 SWDEV-427256 : Changing the patchelf package from requirement to recommends Change-Id: I2c909f2a7a7fc601be1890bfbcef50177695931b --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3597012ca9..69b6e07288 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,14 +174,14 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -set ( CPACK_DEBIAN_PACKAGE_DEPENDS "patchelf" ) +set ( CPACK_DEBIAN_PACKAGE_RECOMMENDS "patchelf" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -set ( CPACK_RPM_PACKAGE_REQUIRES "patchelf" ) +set ( CPACK_RPM_PACKAGE_SUGGESTS "patchelf" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) From 1544e398c601f757eece7faa0ac726b691e40d5a Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Wed, 18 Oct 2023 17:23:42 -0500 Subject: [PATCH 29/61] SWDEV-427268 SWDEV-427256 : Removing dependency with patchelf completely Change-Id: I71ccebdbbd9b3c79ea8412acd54a71a96af3e26f --- CMakeLists.txt | 2 -- runpath_to_rpath.py | 45 ++++++++++++++++++--------------------------- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69b6e07288..3400824a47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,14 +174,12 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -set ( CPACK_DEBIAN_PACKAGE_RECOMMENDS "patchelf" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -set ( CPACK_RPM_PACKAGE_SUGGESTS "patchelf" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) diff --git a/runpath_to_rpath.py b/runpath_to_rpath.py index 0b93b51694..99875981ac 100644 --- a/runpath_to_rpath.py +++ b/runpath_to_rpath.py @@ -35,29 +35,17 @@ try: from elftools.elf.elffile import ELFFile from elftools.elf.dynamic import DynamicSection from elftools.common.exceptions import ELFError + from elftools.elf.dynamic import ENUM_D_TAG except ImportError: print("Error : pyelftools failed to import.\n" "Run \'pip3 install pyelftools\' to install the prerequisite\n") -# Function remove the runpath from the binary -def remove_runpath(filename) : - ''' Remove the DT_RUNPATH tag from filename''' - REMOVE_RPATH_COMMAND = ['patchelf', '--remove-rpath', filename] - print("Executing the command : ", REMOVE_RPATH_COMMAND) - subprocess.run(REMOVE_RPATH_COMMAND, check=True) - -def add_rpath(filename, runpath) : - ''' Use runpath and add it as DT_PATH tag in filename''' - ADD_RPATH_COMMAND = ['patchelf', '--force-rpath', '--set-rpath', runpath, filename] - print("Executing the command : ", ADD_RPATH_COMMAND) - subprocess.run(ADD_RPATH_COMMAND, check=True) - def update_rpath(search_path, excludes) : ''' Function helps to change DT_RUNPATH in libraries and binaries in search_path to DT_RPATH. Its done with the following steps : 1. Check all if the file is an ELF except in excludes folder - 2. Read and store the DT_RUNPATH from the binaries/libraries. - 3. Delete DT_RUNPATH and readd it as DT_RPATH ''' + 2. Find the DT_RUNPATH tag and its offset from file. + 3. Toggle the DT_RUNPATH(0x1d) tag byte to DT_RPATH(0xf) and write back to file ''' for path, dirs, files in os.walk(search_path, topdown=True, followlinks=True): dirs[:] = [d for d in dirs if d not in excludes] print( dirs ) @@ -66,19 +54,22 @@ def update_rpath(search_path, excludes) : print("Opening file ", filename) # Open the file and check if its ELF file try : - with open(filename, 'rb') as file: + with open(filename, 'rb+') as file: elffile = ELFFile(file) - for section in elffile.iter_sections(): - if not isinstance(section, DynamicSection): - continue - for tag in section.iter_tags(): - if tag.entry.d_tag == 'DT_RUNPATH': - runpath = tag.runpath - print(runpath) - remove_runpath(filename) - add_rpath(filename, runpath) - break - break + # Find the dynamic section and look for DT_RUNPATH tag + section = elffile.get_section_by_name('.dynamic') + if not section: break + n = 0 + for tag in section.iter_tags(): + # DT_RUNPATH tag found. Toggle the byte to DT_RPATH + if tag.entry.d_tag == 'DT_RUNPATH': + offset = section.header.sh_offset + n* section._tagsize + section.stream.seek(offset) + section.stream.write(bytes([ENUM_D_TAG['DT_RPATH']])) # DT_PATH + print("DT_RUNPATH changed to DT_RPATH ") + break + # DT_RUNPATH tag not found. Loop to the next tag + n = n + 1 except ELFError: print("Discarding file as its not an ELF file", filename) continue From 1e6cde347801317b021e3d87664b8522865e306b Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Thu, 3 Aug 2023 14:26:45 -0700 Subject: [PATCH 30/61] SWDEV-415345 - Correct the installation path of rocm_version.h header file Added file reorg backward compatibility support by creating wrapper header file. Change-Id: Iee4644c8ae51ba508c21abb765a1e1d974dc6e97 --- CMakeLists.txt | 27 ++++++++++++++ header_template.hpp.in | 48 +++++++++++++++++++++++++ rocm-core-backward-compat.cmake | 63 +++++++++++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 header_template.hpp.in create mode 100644 rocm-core-backward-compat.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 61e65d4ba8..7a2763a10b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,6 +45,10 @@ set( CPACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "package types to be produced " set( COPYRIGHT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/copyright" ) set( BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} ) +if(NOT ENABLE_ASAN_PACKAGING) + option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compatibility" OFF) +endif() + ## Set variables set_variables() @@ -64,6 +68,29 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.prerm ${BUILD_DIR}/prerm @ #Generate BUILD_INFO configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in ${BUILD_DIR}/rocm_version.h @ONLY ) +#File reorg Backward compatibility function +if(NOT WIN32) + if(FILE_REORG_BACKWARD_COMPATIBILITY) + # To enabe/disable #error in wrapper header files + if(NOT DEFINED ROCM_HEADER_WRAPPER_WERROR) + if(DEFINED ENV{ROCM_HEADER_WRAPPER_WERROR}) + set(ROCM_HEADER_WRAPPER_WERROR "$ENV{ROCM_HEADER_WRAPPER_WERROR}" + CACHE STRING "Header wrapper warnings as errors.") + else() + set(ROCM_HEADER_WRAPPER_WERROR "OFF" CACHE STRING "Header wrapper warnings as errors.") + endif() + endif() + + if(ROCM_HEADER_WRAPPER_WERROR) + set(deprecated_error 1) + else() + set(deprecated_error 0) + endif() + + include(rocm-core-backward-compat.cmake) + endif() #FILE_REORG_BACKWARD_COMPATIBILITY +endif() + #Make the rocmlib set( SRCS rocm_version.cpp ) add_library( ${CORE_TARGET} ${SRCS} ) diff --git a/header_template.hpp.in b/header_template.hpp.in new file mode 100644 index 0000000000..0d8c481e90 --- /dev/null +++ b/header_template.hpp.in @@ -0,0 +1,48 @@ +/* + MIT License + + Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + */ +#ifndef @include_guard@ +#define @include_guard@ + +#ifndef ROCM_HEADER_WRAPPER_WERROR +#define ROCM_HEADER_WRAPPER_WERROR @deprecated_error@ +#endif +#if ROCM_HEADER_WRAPPER_WERROR /* ROCM_HEADER_WRAPPER_WERROR 1 */ +#error "@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ " +#else /* ROCM_HEADER_WRAPPER_WERROR 0 */ +#if defined(__GNUC__) +#warning "@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ " +#else +#pragma message ("@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ ") +#endif +#endif /* ROCM_HEADER_WRAPPER_WERROR */ + +@include_statements@ + +@hashzero_check@ + +@file_contents@ + +@hash_endif@ + +#endif diff --git a/rocm-core-backward-compat.cmake b/rocm-core-backward-compat.cmake new file mode 100644 index 0000000000..e96572e669 --- /dev/null +++ b/rocm-core-backward-compat.cmake @@ -0,0 +1,63 @@ +# Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +cmake_minimum_required(VERSION 3.16.8) + +set(ROCM_CORE_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) +set(ROCM_CORE_WRAPPER_DIR ${ROCM_CORE_BUILD_DIR}/wrapper_dir) +set(ROCM_CORE_WRAPPER_INC_DIR ${ROCM_CORE_WRAPPER_DIR}/include) +set(headerfile_dir "rocm-core") + +#Function to set actual file contents in wrapper files +#Some components grep for the contents in the file +function(set_file_contents input_file) + set(hashzero_check "#if 0 +/* The following is a copy of the original file for the benefit of build systems which grep for values + * in this file rather than preprocess it. This is just for backward compatibility */") + + file(READ ${input_file} file_contents) + set(hash_endif "#endif") + get_filename_component(file_name ${input_file} NAME) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/header_template.hpp.in ${ROCM_CORE_WRAPPER_INC_DIR}/${file_name}) +endfunction() + +#use header template file and generate wrapper header files +function(generate_wrapper_header) + file(MAKE_DIRECTORY ${ROCM_CORE_WRAPPER_INC_DIR}) + + #find all header files + file(GLOB include_files ${ROCM_CORE_BUILD_DIR}/*.h) + #Create wrapper files + foreach(header_file ${include_files}) + # set include guard + get_filename_component(INC_GAURD_NAME ${header_file} NAME_WE) + string(TOUPPER ${INC_GAURD_NAME} INC_GAURD_NAME) + set(include_guard "ROCM_CORE_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") + #set #include statement + get_filename_component(file_name ${header_file} NAME) + set(include_statements "#include \"${headerfile_dir}/${file_name}\"\n") + set_file_contents(${header_file}) + endforeach() + +endfunction() + +#Use template header file and generater wrapper header files +generate_wrapper_header() +install(DIRECTORY ${ROCM_CORE_WRAPPER_INC_DIR} DESTINATION . COMPONENT runtime) + From 5f59a6e538659f08eb6e9babaf337423e2ff8535 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Thu, 31 Aug 2023 14:28:49 -0500 Subject: [PATCH 31/61] SWDEV-310152 : Adding script to convert RUNPATH to RPATH in libs/bins Change-Id: Ic6c49544cb7450384592b4f5609fb394f1f12f02 --- CHANGELOG.md | 5 ++ CMakeLists.txt | 3 ++ runpath_to_rpath.py | 127 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100644 runpath_to_rpath.py diff --git a/CHANGELOG.md b/CHANGELOG.md index dacf8140a8..7be9b06418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ Change Logs for rocm-core + +Unreleased ROCm6.0.0 release + - Added script to convert RUNPATH in libraries and binaries to RPATH. + - Disabled ROCm file reorg backward compatibility + ROCm5.6.0 release - Added initial support for Adress Sanitizer(ASAN) enabled builds. - Full support of ASAN will be coming in later release diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a2763a10b..3597012ca9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -122,6 +122,7 @@ install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT ${COMP_TYPE} ) install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core COMPONENT runtime ) +install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runpath_to_rpath.py DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/rocm-core COMPONENT runtime ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) # License file @@ -173,12 +174,14 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) +set ( CPACK_DEBIAN_PACKAGE_DEPENDS "patchelf" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) +set ( CPACK_RPM_PACKAGE_REQUIRES "patchelf" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) diff --git a/runpath_to_rpath.py b/runpath_to_rpath.py new file mode 100644 index 0000000000..0b93b51694 --- /dev/null +++ b/runpath_to_rpath.py @@ -0,0 +1,127 @@ +#!/usr/bin/env python3 +################################################################################ +## +## MIT License +## +## Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. +## +## Permission is hereby granted, free of charge, to any person obtaining a copy +## of this software and associated documentation files (the "Software"), to deal +## in the Software without restriction, including without limitation the rights +## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +## copies of the Software, and to permit persons to whom the Software is +## furnished to do so, subject to the following conditions: +## +## The above copyright notice and this permission notice shall be included in all +## copies or substantial portions of the Software. +## +## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +## IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +## AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +## SOFTWARE. +## +################################################################################ + +import os +import sys +import subprocess +import argparse +import pathlib + +try: + from elftools.elf.elffile import ELFFile + from elftools.elf.dynamic import DynamicSection + from elftools.common.exceptions import ELFError +except ImportError: + print("Error : pyelftools failed to import.\n" + "Run \'pip3 install pyelftools\' to install the prerequisite\n") + +# Function remove the runpath from the binary +def remove_runpath(filename) : + ''' Remove the DT_RUNPATH tag from filename''' + REMOVE_RPATH_COMMAND = ['patchelf', '--remove-rpath', filename] + print("Executing the command : ", REMOVE_RPATH_COMMAND) + subprocess.run(REMOVE_RPATH_COMMAND, check=True) + +def add_rpath(filename, runpath) : + ''' Use runpath and add it as DT_PATH tag in filename''' + ADD_RPATH_COMMAND = ['patchelf', '--force-rpath', '--set-rpath', runpath, filename] + print("Executing the command : ", ADD_RPATH_COMMAND) + subprocess.run(ADD_RPATH_COMMAND, check=True) + +def update_rpath(search_path, excludes) : + ''' Function helps to change DT_RUNPATH in libraries and binaries in search_path to DT_RPATH. + Its done with the following steps : + 1. Check all if the file is an ELF except in excludes folder + 2. Read and store the DT_RUNPATH from the binaries/libraries. + 3. Delete DT_RUNPATH and readd it as DT_RPATH ''' + for path, dirs, files in os.walk(search_path, topdown=True, followlinks=True): + dirs[:] = [d for d in dirs if d not in excludes] + print( dirs ) + for filename in files: + filename = os.path.join(path, filename) + print("Opening file ", filename) + # Open the file and check if its ELF file + try : + with open(filename, 'rb') as file: + elffile = ELFFile(file) + for section in elffile.iter_sections(): + if not isinstance(section, DynamicSection): + continue + for tag in section.iter_tags(): + if tag.entry.d_tag == 'DT_RUNPATH': + runpath = tag.runpath + print(runpath) + remove_runpath(filename) + add_rpath(filename, runpath) + break + break + except ELFError: + print("Discarding file as its not an ELF file", filename) + continue + except FileNotFoundError: + print("Discarding file with bad links", filename) + continue + except OSError: + print("Discarding file with OS error", filename) + continue + except Exception as ex: + print("Discarding file ", filename, ex) + continue + +def main(): + # The script expect a search folder as parameter. It finds all ELF files and updates RPATH + argparser = argparse.ArgumentParser( + usage='usage: %(prog)s ', + description='Find the ELF files in the specified folder and convert the RUNPATH to RPATH. \n', + add_help=False, + prog='runpath_to_rpath.py') + + argparser.add_argument('searchdir', + nargs='?', type=pathlib.Path, default=None, + help='Folder to search for ELF file. \nPlease note: Any folder with name llvm in that path will be discarded') + argparser.add_argument('-h', '--help', + action='store_true', dest='help', + help='Display this information') + + args = argparser.parse_args() + if args.help or not args.searchdir: + argparser.print_help() + sys.exit(0) + + # pyelftools is a mandatory requirement for this script. Exit if requirement is not met + if 'ELFFile' not in globals(): + print('Please install pyelftools using \'pip3 install pyelftools\' ' + + 'before using the script : runpath_to_rpath.py') + sys.exit(0) + + # Find the elf files in the serach path and update RPATH + excludes = ['llvm', 'rocm-llvm', 'llvm-alt'] + update_rpath(args.searchdir, excludes) + print("Done with rpath update") + +if __name__ == "__main__": + main() From 0f9d27335180d5af1cc09ccfac1ae54d919612fb Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Mon, 16 Oct 2023 15:23:53 -0500 Subject: [PATCH 32/61] SWDEV-427268 SWDEV-427256 : Changing the patchelf package from requirement to recommends Change-Id: I2c909f2a7a7fc601be1890bfbcef50177695931b --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3597012ca9..69b6e07288 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,14 +174,14 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -set ( CPACK_DEBIAN_PACKAGE_DEPENDS "patchelf" ) +set ( CPACK_DEBIAN_PACKAGE_RECOMMENDS "patchelf" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -set ( CPACK_RPM_PACKAGE_REQUIRES "patchelf" ) +set ( CPACK_RPM_PACKAGE_SUGGESTS "patchelf" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) From 628b2c04f6736fb787a9e84bdf1f368acd5a2baa Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Wed, 18 Oct 2023 17:23:42 -0500 Subject: [PATCH 33/61] SWDEV-427268 SWDEV-427256 : Removing dependency with patchelf completely Change-Id: I71ccebdbbd9b3c79ea8412acd54a71a96af3e26f --- CMakeLists.txt | 2 -- runpath_to_rpath.py | 45 ++++++++++++++++++--------------------------- 2 files changed, 18 insertions(+), 29 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69b6e07288..3400824a47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -174,14 +174,12 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -set ( CPACK_DEBIAN_PACKAGE_RECOMMENDS "patchelf" ) set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -set ( CPACK_RPM_PACKAGE_SUGGESTS "patchelf" ) set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) diff --git a/runpath_to_rpath.py b/runpath_to_rpath.py index 0b93b51694..99875981ac 100644 --- a/runpath_to_rpath.py +++ b/runpath_to_rpath.py @@ -35,29 +35,17 @@ try: from elftools.elf.elffile import ELFFile from elftools.elf.dynamic import DynamicSection from elftools.common.exceptions import ELFError + from elftools.elf.dynamic import ENUM_D_TAG except ImportError: print("Error : pyelftools failed to import.\n" "Run \'pip3 install pyelftools\' to install the prerequisite\n") -# Function remove the runpath from the binary -def remove_runpath(filename) : - ''' Remove the DT_RUNPATH tag from filename''' - REMOVE_RPATH_COMMAND = ['patchelf', '--remove-rpath', filename] - print("Executing the command : ", REMOVE_RPATH_COMMAND) - subprocess.run(REMOVE_RPATH_COMMAND, check=True) - -def add_rpath(filename, runpath) : - ''' Use runpath and add it as DT_PATH tag in filename''' - ADD_RPATH_COMMAND = ['patchelf', '--force-rpath', '--set-rpath', runpath, filename] - print("Executing the command : ", ADD_RPATH_COMMAND) - subprocess.run(ADD_RPATH_COMMAND, check=True) - def update_rpath(search_path, excludes) : ''' Function helps to change DT_RUNPATH in libraries and binaries in search_path to DT_RPATH. Its done with the following steps : 1. Check all if the file is an ELF except in excludes folder - 2. Read and store the DT_RUNPATH from the binaries/libraries. - 3. Delete DT_RUNPATH and readd it as DT_RPATH ''' + 2. Find the DT_RUNPATH tag and its offset from file. + 3. Toggle the DT_RUNPATH(0x1d) tag byte to DT_RPATH(0xf) and write back to file ''' for path, dirs, files in os.walk(search_path, topdown=True, followlinks=True): dirs[:] = [d for d in dirs if d not in excludes] print( dirs ) @@ -66,19 +54,22 @@ def update_rpath(search_path, excludes) : print("Opening file ", filename) # Open the file and check if its ELF file try : - with open(filename, 'rb') as file: + with open(filename, 'rb+') as file: elffile = ELFFile(file) - for section in elffile.iter_sections(): - if not isinstance(section, DynamicSection): - continue - for tag in section.iter_tags(): - if tag.entry.d_tag == 'DT_RUNPATH': - runpath = tag.runpath - print(runpath) - remove_runpath(filename) - add_rpath(filename, runpath) - break - break + # Find the dynamic section and look for DT_RUNPATH tag + section = elffile.get_section_by_name('.dynamic') + if not section: break + n = 0 + for tag in section.iter_tags(): + # DT_RUNPATH tag found. Toggle the byte to DT_RPATH + if tag.entry.d_tag == 'DT_RUNPATH': + offset = section.header.sh_offset + n* section._tagsize + section.stream.seek(offset) + section.stream.write(bytes([ENUM_D_TAG['DT_RPATH']])) # DT_PATH + print("DT_RUNPATH changed to DT_RPATH ") + break + # DT_RUNPATH tag not found. Loop to the next tag + n = n + 1 except ELFError: print("Discarding file as its not an ELF file", filename) continue From 8723cc52a2f2ae7a1f3d95e6901e77d6a5c31df4 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Fri, 10 Nov 2023 17:56:16 -0600 Subject: [PATCH 34/61] SWDEV-310152 : Updating llvm config file to default to RPATH after running this script Change-Id: I67d1a4b1d19032cfe187fadc5f7b6ee540d08672 --- runpath_to_rpath.py | 65 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 2 deletions(-) diff --git a/runpath_to_rpath.py b/runpath_to_rpath.py index 99875981ac..c4415124f7 100644 --- a/runpath_to_rpath.py +++ b/runpath_to_rpath.py @@ -30,6 +30,7 @@ import sys import subprocess import argparse import pathlib +import re try: from elftools.elf.elffile import ELFFile @@ -83,6 +84,64 @@ def update_rpath(search_path, excludes) : print("Discarding file ", filename, ex) continue +def update_config_file(cfg_path): + ''' Function helps to update rocm llvm config file to default to DT_RPATH. ''' + print("Updating cfg file in", cfg_path) + config_file_exist = os.path.exists(cfg_path) + if config_file_exist: + print("cfg file exist in path, going ahead with update ") + search_str = "enable-new-dtags" + replace_str = "disable-new-dtags" + try: + # Read contents from file as a single string + file_string = '' + with open(cfg_path, 'r') as f: + file_string = f.read() + + # Use RE package for string replacement + file_string = (re.sub(search_str, replace_str, file_string)) + + # Write contents back to file. Using mode 'w' truncates the file. + with open(cfg_path, 'w') as f: + f.write(file_string) + except Exception as ex: + print("Couldnt update rocm.cfg file. ", ex) + else: + print("Config path doesnt exist", cfg_path) + +def update_compiler_config(search_path): + ''' Function search for rocm llvm config(rocm.cfg) file in the search_path folder. + If the config file is not foung search in ROCM_PATH. Once the config file is found, + update llvm config to default to DT_RPATH ''' + cfg_file_name = "rocm.cfg" + found_cfg = False + print("Searching for ", cfg_file_name) + for path, dirs, files in os.walk(search_path): + # Search for rocm.cfg in the search path and default to DT_RPATH + if cfg_file_name in files: + cfg_path = os.path.join(path, cfg_file_name) + print(" Found cfg file cfg_path") + found_cfg = True + update_config_file(cfg_path) + # Continue with the search as there could be cfg files in llvm and llvm/alt + continue; + if found_cfg: + return + # rocm.cfg config file not found in search path. Search in the ROCM_PATH. + print(cfg_file_name, " not found in search_path. Trying to search in ROCM_PATH") + try : + rocm_path = os.environ["ROCM_PATH"] + print(" Found ROCM_PATH trying for rocm.cfg") + # There are multiple possible paths for cfg file. + # ROCM_PATH/llvm/bin and ROCM_PATH/lib/llvm/bin. Also alt location + update_config_file(rocm_path + "/llvm/bin/" + cfg_file_name) + update_config_file(rocm_path + "/llvm/alt/bin/" + cfg_file_name) + update_config_file(rocm_path + "/lib/llvm/bin/" + cfg_file_name) + update_config_file(rocm_path + "/lib/llvm/alt/bin/" + cfg_file_name) + # Found config file. Change default DT_RUNPATH setting to DT_RPATH + except Exception as ex: + print("ROCM_PATH not found ", ex) + def main(): # The script expect a search folder as parameter. It finds all ELF files and updates RPATH argparser = argparse.ArgumentParser( @@ -109,9 +168,11 @@ def main(): 'before using the script : runpath_to_rpath.py') sys.exit(0) - # Find the elf files in the serach path and update RPATH - excludes = ['llvm', 'rocm-llvm', 'llvm-alt'] + # Find the elf files in the serach path and update DT_RUNPATH to DT_RPATH + excludes = ['llvm', 'rocm-llvm', 'rocm-llvm-alt'] update_rpath(args.searchdir, excludes) + # Update rocm clang configs to default to DT_RPATH + update_compiler_config(args.searchdir) print("Done with rpath update") if __name__ == "__main__": From d338714f4d3294f38e196158b140cc6632f91ca2 Mon Sep 17 00:00:00 2001 From: AravindanC Date: Mon, 22 Jan 2024 09:25:02 -0800 Subject: [PATCH 35/61] Adding Method to get ROCM Install Path Change-Id: Ib8ff920402e9f5d41c0ff8a0e4b76a18596e20e2 --- CHANGELOG.md | 6 +- CMakeLists.txt | 13 +++- rocm_getpath.cpp | 161 ++++++++++++++++++++++++++++++++++++++++++++++ rocm_getpath.h.in | 69 ++++++++++++++++++++ 4 files changed, 244 insertions(+), 5 deletions(-) create mode 100644 rocm_getpath.cpp create mode 100644 rocm_getpath.h.in diff --git a/CHANGELOG.md b/CHANGELOG.md index 7be9b06418..ec10512fc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ Change Logs for rocm-core - -Unreleased ROCm6.0.0 release +Unreleased ROCm6.1.0 release + - Added new API to get ROCm install Path (getROCmInstallPath()) at runtime + using dlinfo of rocm-core Target Library. +ROCm6.0.0 release - Added script to convert RUNPATH in libraries and binaries to RPATH. - Disabled ROCm file reorg backward compatibility diff --git a/CMakeLists.txt b/CMakeLists.txt index 3400824a47..35ec1229e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,6 +29,9 @@ set( CORE_TARGET "rocm-core" ) project( ${CORE_TARGET} CXX ) +## Define Lib Target Name and Lib Target Install Dir to be available to c++ source +add_definitions( -DTARGET_LIBRARY_NAME=\"${CORE_TARGET}\" -DTARGET_LIBRARY_INSTALL_DIR=\"${CMAKE_INSTALL_LIBDIR}\" ) + ## Verbose output. set( CMAKE_VERBOSE_MAKEFILE on ) @@ -67,7 +70,7 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.prerm ${BUILD_DIR}/prerm @ #Generate BUILD_INFO configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in ${BUILD_DIR}/rocm_version.h @ONLY ) - +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm_getpath.h.in ${BUILD_DIR}/rocm_getpath.h @ONLY ) #File reorg Backward compatibility function if(NOT WIN32) if(FILE_REORG_BACKWARD_COMPATIBILITY) @@ -92,12 +95,13 @@ if(NOT WIN32) endif() #Make the rocmlib -set( SRCS rocm_version.cpp ) +set( SRCS rocm_version.cpp rocm_getpath.cpp) add_library( ${CORE_TARGET} ${SRCS} ) set( CXX_FLAGS ${CXX_FLAGS} -g -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=c++11 ) set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete -Wl,-no-undefined" ) target_include_directories( ${CORE_TARGET} PRIVATE ${BUILD_DIR} ) +target_link_libraries( ${CORE_TARGET} PRIVATE dl ) ## Set the VERSION and SOVERSION values set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${ROCM_LIBPATCH_VERSION}" ) @@ -121,7 +125,10 @@ install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT ${COMP_TYPE} ) -install ( FILES ${BUILD_DIR}/rocm_version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core COMPONENT runtime ) +install ( FILES ${BUILD_DIR}/rocm_version.h ${BUILD_DIR}/rocm_getpath.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core + COMPONENT runtime ) + install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runpath_to_rpath.py DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/rocm-core COMPONENT runtime ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) diff --git a/rocm_getpath.cpp b/rocm_getpath.cpp new file mode 100644 index 0000000000..52f2fdcdee --- /dev/null +++ b/rocm_getpath.cpp @@ -0,0 +1,161 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// MIT License +// +// Copyright (c) 2017 - 2024 Advanced Micro Devices, Inc. All rights Reserved. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// +//////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include /* PATH_MAX */ +#include +#include +#include +#include "rocm_getpath.h" + +/* Macro for NULL CHECK */ +#define NULL_CHECK(ptr) if(!ptr) return PathIncorrecPararmeters; + + +/* Target Library Install Dir */ +#define TARGET_LIB_INSTALL_DIR TARGET_LIBRARY_INSTALL_DIR + +/* Target Library Name Buf Size */ +#define LIBRARY_FILENAME_BUFSZ (PATH_MAX+1) + +/* Internal Function to get Base Path - Ref from Icarus Logic*/ +static int getROCmBase(char *buf); + +/* Public Function to get the ROCm Install Base Path +// Argument1 (out) : InstallPath (char** pointer which will return InstallPath found) +// Argument2 (out) : InstallPathLen (Pointer to integer (size of InstallPath) returned) +// Usage : +// char *installPath=NULL; +// int installPathLen = 0; +// installStatus = getROCmInstallPath( &installPath, &installPathLen ); +// if(installStatus !=PathSuccess ){ // error occured +// ... +// } +// free(installPath); //caller must free allocated memory after usage. +// ... + +*/ +PathErrors_t getROCmInstallPath( char** InstallPath, unsigned int *InstallPathLen ) { + + NULL_CHECK(InstallPath); + NULL_CHECK(InstallPathLen); + int ret = PathErrorMAX; + char *bufPtr = (char *)NULL; + unsigned int bufSz = 0; + + bufPtr = (char *)malloc( LIBRARY_FILENAME_BUFSZ * sizeof(char) ); + memset( bufPtr, 0, LIBRARY_FILENAME_BUFSZ ); + *InstallPathLen = 0; + *InstallPath = NULL; + + ret = getROCmBase(bufPtr); + if (0 > ret){ + free(bufPtr); + return (PathErrors_t)ret; + } + else if (0 == ret){ + free(bufPtr); + return PathFailedToGetBase; + } + else{ + bufSz = ret;//additional char for null termination + } + + *InstallPath = bufPtr; + *InstallPathLen = bufSz; + return PathSuccess; +} + +/* General purpose function that fills the directory to find rocm related stuff */ +/* returns the offset into the buffer for the terminating NUL or -1 for error */ +/* The buffer should be at least PATH_MAX */ +static int getROCmBase(char *buf) +{ + int len=0; + char *envStr=NULL; + char libFileName[LIBRARY_FILENAME_BUFSZ]; + char *end=NULL; + + if ((envStr = getenv("ROCM_PATH"))) { + /* User space override, essentially just copied through as long as it is not too long */ + len = strlen(envStr); + if (len > 0) { + if (envStr[len] == '/') { + /* Already has at least one terminating */ + len--; + } + if (len > PATH_MAX-1 ) { + return PathValuesTooLong; + } + strncpy(buf, envStr, len); + buf[len]='/'; + buf[len+1]='\0'; + + /* Length of string including trailing '/' */ + return len+1; + } + } + + sprintf(libFileName, "lib%s.so", TARGET_LIBRARY_NAME); + void *handle=dlopen(libFileName,RTLD_NOW); + if (!handle){ + /* We can't find the library */ + return PathLinuxRuntimeErrors; + } + /* Variable to hold the return value from dlinfo */ + struct link_map *map = (struct link_map*)NULL; + /* Query the runtime linker */ + dlinfo(handle,RTLD_DI_LINKMAP,&map); + if (map ->l_name && realpath(map ->l_name,buf)) { + /* Get Library Directory Path */ + char *end = strrchr(buf, '/'); + if (end && end > buf) { + *end = '\0'; + } + } + else{ + /* If l_name is NULL or realpath() failed + * Close handle before return error */ + dlclose(handle); + return PathLinuxRuntimeErrors; + } + + dlclose(handle); + /* find the start of substring TARGET_LIB_INSTALL_DIR + * To strip down Path up to Parent Directory of TARGET_LIB_INSTALL_DIR. */ + end=strstr(buf, TARGET_LIB_INSTALL_DIR); + if( NULL == end ){ + /* We can't find the library install directory*/ + return PathLinuxRuntimeErrors; + } + *end = '\0'; + + /* Length of Path String up to Parent Directoy (ROCm Base Path) + * with trailing '/'.*/ + len = strlen(buf); + return len; +} + diff --git a/rocm_getpath.h.in b/rocm_getpath.h.in new file mode 100644 index 0000000000..b4dab8e1d2 --- /dev/null +++ b/rocm_getpath.h.in @@ -0,0 +1,69 @@ +//////////////////////////////////////////////////////////////////////////////// +//// +//// MIT License +//// +//// Copyright (c) 2017 - 2024 Advanced Micro Devices, Inc. All rights Reserved. +//// +//// Permission is hereby granted, free of charge, to any person obtaining a copy +//// of this software and associated documentation files (the "Software"), to deal +//// in the Software without restriction, including without limitation the rights +//// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +//// copies of the Software, and to permit persons to whom the Software is +//// furnished to do so, subject to the following conditions: +//// +//// The above copyright notice and this permission notice shall be included in all +//// copies or substantial portions of the Software. +//// +//// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +//// +////////////////////////////////////////////////////////////////////////////////// + + +#ifndef _ROCM_GETPATH_H_ +#define _ROCM_GETPATH_H_ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define LIB_API_PUBLIC __attribute__ ((visibility ("default"))) + +/* Return Status Flag Definitions*/ +typedef enum { + PathSuccess=0, + PathIncorrecPararmeters = -994, + PathValuesNotDefined = -995, + PathValuesTooLong = -996, + PathFailedToGetBase = -997, + PathLinuxRuntimeErrors = -998, + PathErrorMAX = -999 //This should always be last value in the enumerations +} PathErrors_t; + +// API for getting the ROCmInstallPath +// Return val : PathErrors_t (API execution status) +// Argument1 (out) : InstallPath (char** pointer which will return InstallPath found ) +// Argument2 (out) : InstallPathLen (Pointer to integer (size of InstallPath) returned) +// Usage : +// char *installPath=NULL; +// int installPathLen = 0; +// installStatus = getROCmInstallPath( &installPath, &installPathLen ); +// if(installStatus !=PathSuccess ){ // error occured +// ... +// } +// free(installPath); //caller must free allocated memory after usage. +// ... +// } +LIB_API_PUBLIC PathErrors_t getROCmInstallPath(char **InstallPath, unsigned int *InstallPathLen) __attribute__((nonnull)) ; + +#ifdef __cplusplus +} // end extern "C" block +#endif + +#endif //_ROCM_GETPATH_H_ header guard + From 90846043b901421a9a4d53a618fa43a6cdb63e75 Mon Sep 17 00:00:00 2001 From: David Galiffi Date: Fri, 2 Feb 2024 14:13:22 -0500 Subject: [PATCH 36/61] SWDEV-437292 - Update CODEOWNERS file Add @nunnikri, @frepaul, @raramakr, @ashutom, and @amd-isparry as CODEOWNERS. Signed-off-by: David Galiffi Change-Id: I1b4fa626bda8012cac569917d1d2a79afada7168 --- CODEOWNERS | 1 + 1 file changed, 1 insertion(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000..89ea81341f --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1 @@ +* @nunnikri @frepaul @raramakr @ashutom @amd-isparry From c9058d2442442598b683563ae298d9c621f9125f Mon Sep 17 00:00:00 2001 From: AravindanC Date: Tue, 27 Feb 2024 08:43:40 -0800 Subject: [PATCH 37/61] SWDEV-354543 Remove explicit install permission, Enhanced comments Change-Id: Ie7a3b5b026666d65056e426eb7fa9c184a46eb07 --- CMakeLists.txt | 1 - rocm_getpath.cpp | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 35ec1229e3..e00ab5bc44 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,7 +123,6 @@ endif() file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT runtime ) install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} - PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT ${COMP_TYPE} ) install ( FILES ${BUILD_DIR}/rocm_version.h ${BUILD_DIR}/rocm_getpath.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core diff --git a/rocm_getpath.cpp b/rocm_getpath.cpp index 52f2fdcdee..d314c6a225 100644 --- a/rocm_getpath.cpp +++ b/rocm_getpath.cpp @@ -99,6 +99,8 @@ static int getROCmBase(char *buf) char libFileName[LIBRARY_FILENAME_BUFSZ]; char *end=NULL; + // Check Environment Variable is set for ROCM + // install base path, then use it directly. if ((envStr = getenv("ROCM_PATH"))) { /* User space override, essentially just copied through as long as it is not too long */ len = strlen(envStr); @@ -119,6 +121,9 @@ static int getROCmBase(char *buf) } } + // If Environment Variable is not set + // use dl APIs to get target lib path + // and get rocm base install path using the lib Path. sprintf(libFileName, "lib%s.so", TARGET_LIBRARY_NAME); void *handle=dlopen(libFileName,RTLD_NOW); if (!handle){ From c6a543aa20b29a3c3f1775279722d125078decec Mon Sep 17 00:00:00 2001 From: amd-jmacaran Date: Tue, 23 Apr 2024 21:27:39 -0400 Subject: [PATCH 38/61] Add support for external CI builds using Azure Pipelines Change-Id: Ie6fa59d635b5e942e72844d24f529cb363e89421 --- .azuredevops/rocm-ci.yml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 .azuredevops/rocm-ci.yml diff --git a/.azuredevops/rocm-ci.yml b/.azuredevops/rocm-ci.yml new file mode 100644 index 0000000000..ba720ab9da --- /dev/null +++ b/.azuredevops/rocm-ci.yml @@ -0,0 +1,38 @@ +resources: + repositories: + - repository: pipelines_repo + type: github + endpoint: External-CI-Token + name: ROCm/ROCm + +variables: +- group: common +- template: /.azuredevops/variables-global.yml@pipelines_repo + +trigger: + batch: true + branches: + include: + - master + paths: + exclude: + - 'CHANGELOG.md' + - 'CODEOWNERS' + - 'copyright' + - 'README.txt' + +pr: + autoCancel: true + branches: + include: + - master + paths: + exclude: + - 'CHANGELOG.md' + - 'CODEOWNERS' + - 'copyright' + - 'README.txt' + drafts: false + +jobs: + - template: ${{ variables.CI_COMPONENT_PATH }}/rocm-core.yml@pipelines_repo From c83bdca4bb1127d3cdd270245aa6f3cf19b13dee Mon Sep 17 00:00:00 2001 From: amd-jmacaran Date: Thu, 25 Apr 2024 04:00:30 -0400 Subject: [PATCH 39/61] Change token name to match IT-created token Change-Id: I2dd13b7f0f34a8e1a2a3db7b05cebaafb87b6fe3 --- .azuredevops/rocm-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azuredevops/rocm-ci.yml b/.azuredevops/rocm-ci.yml index ba720ab9da..8d61d8f456 100644 --- a/.azuredevops/rocm-ci.yml +++ b/.azuredevops/rocm-ci.yml @@ -2,7 +2,7 @@ resources: repositories: - repository: pipelines_repo type: github - endpoint: External-CI-Token + endpoint: ROCm name: ROCm/ROCm variables: From a5a437e48a210f5aa986a29747371028d478602d Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Wed, 1 May 2024 12:54:05 -0700 Subject: [PATCH 40/61] SWDEV-449560 - Backward compatibility support for deprected package rocm-clang-ocl rocm-clang-ocl has been deprected from ROCm 6.1 onwards. Uprading ROCm from 6.0 to latest release will result in stale files of rocm-clang-ocl. rocm-core will replaces/obsoletes rocm-clang-ocl package. This will ensure clean removal of the deprecated package Change-Id: Id5c16492273d8a0dcbbd5ac797daaef96c058f5b --- CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e00ab5bc44..fb1522876a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,6 +192,12 @@ set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/ if ( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) endif ( ) +# Backward compatibility support for deprecated package rocm-clang-ocl +# TODO: To be removed after two releases +set(CPACK_DEBIAN_RUNTIME_PACKAGE_REPLACES "rocm-clang-ocl") +set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONFLICTS "rocm-clang-ocl") + +set(CPACK_RPM_RUNTIME_PACKAGE_OBSOLETES "rocm-clang-ocl") ## Include packaging include ( CPack ) From be3728bd33e5136c1b3eaa626e8e53a1d771d197 Mon Sep 17 00:00:00 2001 From: AravindanC Date: Thu, 28 Mar 2024 08:14:22 -0700 Subject: [PATCH 41/61] CheryPick SWDEV-442738 - Static package generation for rocm-core Change-Id: I8e55f4cc3e476a9b4f3d73c02bab51c70b936bcc SWDEV-442738 - ROCM-CORE Static Package Pre/Post Script Change-Id: Ie55ffc98dfc60d9cb01b7a6df7a5fe1a890bc771 --- CMakeLists.txt | 107 +++++++++++++++++++++++++++++++++++----------- rocm_getpath.cpp | 2 + rocm_getpath.h.in | 3 ++ 3 files changed, 86 insertions(+), 26 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fb1522876a..8746fb43e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,7 +101,9 @@ add_library( ${CORE_TARGET} ${SRCS} ) set( CXX_FLAGS ${CXX_FLAGS} -g -fPIC -fvisibility=hidden -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wundef -Wshadow -Wpointer-arith -Wcast-qual -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=c++11 ) set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,nodelete -Wl,-no-undefined" ) target_include_directories( ${CORE_TARGET} PRIVATE ${BUILD_DIR} ) -target_link_libraries( ${CORE_TARGET} PRIVATE dl ) +if(BUILD_SHARED_LIBS) + target_link_libraries( ${CORE_TARGET} PRIVATE dl ) +endif() ## Set the VERSION and SOVERSION values set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${ROCM_LIBPATCH_VERSION}" ) @@ -110,30 +112,75 @@ set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" ) if(ENABLE_ASAN_PACKAGING) # Only libraries required for ASAN Package - set( CPACK_COMPONENTS_ALL asan ) - set( COMP_TYPE "asan" ) + set( CPACK_COMPONENTS_ALL CORE_ASAN ) + set( COMP_TYPE "CORE_ASAN" ) set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) AddressSanitizer Instrumented Runtime software stack" ) else() - set( CPACK_COMPONENTS_ALL runtime ) - set( COMP_TYPE "runtime" ) - set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) Runtime software stack" ) + if(BUILD_SHARED_LIBS) + set( CPACK_COMPONENTS_ALL CORE_RUNTIME ) + set( COMP_TYPE "CORE_RUNTIME" ) + set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) Runtime software stack" ) + else() + set( CPACK_COMPONENTS_ALL CORE_STATIC ) + set( STATIC_COMP_TYPE "CORE_STATIC" ) + set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) Static software stack" ) + endif() endif() #intallation directive file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) -install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT runtime ) -install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT ${COMP_TYPE} ) -install ( FILES ${BUILD_DIR}/rocm_version.h ${BUILD_DIR}/rocm_getpath.h - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core - COMPONENT runtime ) -install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runpath_to_rpath.py DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/rocm-core COMPONENT runtime ) -install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime ) +## Support for Static and Shared Target Packaging +if(BUILD_SHARED_LIBS) + install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT CORE_RUNTIME ) + + # Target Library needs to installed/packaged to same destination + # in both ASAN and nonASAN Shared library builds + install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} + PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE + COMPONENT ${COMP_TYPE} ) + install ( FILES ${BUILD_DIR}/rocm_version.h ${BUILD_DIR}/rocm_getpath.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core + COMPONENT CORE_RUNTIME ) + + install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runpath_to_rpath.py + DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/rocm-core + COMPONENT CORE_RUNTIME ) + install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT CORE_RUNTIME ) + + # License file + install ( FILES ${COPYRIGHT_FILE} + DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt + COMPONENT CORE_RUNTIME) + install ( FILES ${COPYRIGHT_FILE} DESTINATION + ${CMAKE_INSTALL_DOCDIR}-asan RENAME LICENSE.txt + COMPONENT CORE_ASAN) +else() + install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version + DESTINATION .info + COMPONENT ${STATIC_COMP_TYPE} ) + install ( TARGETS ${CORE_TARGET} + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT ${STATIC_COMP_TYPE} ) + + install ( FILES ${BUILD_DIR}/rocm_version.h ${BUILD_DIR}/rocm_getpath.h + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core + COMPONENT ${STATIC_COMP_TYPE} ) + + install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runpath_to_rpath.py + DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/rocm-core + COMPONENT ${STATIC_COMP_TYPE} ) + install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT ${STATIC_COMP_TYPE} ) + # License file + install ( FILES ${COPYRIGHT_FILE} + DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt + COMPONENT ${STATIC_COMP_TYPE}) +endif() -# License file -install(FILES ${COPYRIGHT_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt COMPONENT runtime) -install(FILES ${COPYRIGHT_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR}-asan RENAME LICENSE.txt COMPONENT asan) ## Packaging directives set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) @@ -152,17 +199,22 @@ endif() ## Debian package specific variables set ( CPACK_DEB_COMPONENT_INSTALL ON ) -set ( CPACK_DEBIAN_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) +set ( CPACK_DEBIAN_CORE_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) # ASAN package name -set ( CPACK_DEBIAN_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) +set ( CPACK_DEBIAN_CORE_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) +# STATIC package name - For Now, No change for static package Name from default +set ( CPACK_DEBIAN_CORE_STATIC_PACKAGE_NAME ${CORE_TARGET} ) message ( STATUS "Using CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) ## RPM package specific variables set ( CPACK_RPM_COMPONENT_INSTALL ON ) -set ( CPACK_RPM_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) +set ( CPACK_RPM_CORE_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) # ASAN package name -set ( CPACK_RPM_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) +set ( CPACK_RPM_CORE_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) +# STATIC package name - For Now, No change for static package Name from default +set ( CPACK_RPM_CORE_STATIC_PACKAGE_NAME ${CORE_TARGET} ) + ## 'dist' breaks manual builds on debian systems due to empty Provides execute_process( COMMAND rpm --eval %{?dist} @@ -178,16 +230,19 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) -set ( CPACK_DEBIAN_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) -set ( CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) +set ( CPACK_DEBIAN_CORE_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) +set ( CPACK_DEBIAN_CORE_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) +set ( CPACK_DEBIAN_CORE_STATIC_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) -set ( CPACK_RPM_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) -set ( CPACK_RPM_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) -set ( CPACK_RPM_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) +set ( CPACK_RPM_CORE_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) +set ( CPACK_RPM_CORE_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) +set ( CPACK_RPM_CORE_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) +set ( CPACK_RPM_CORE_STATIC_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) +set ( CPACK_RPM_CORE_STATIC_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) if ( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) diff --git a/rocm_getpath.cpp b/rocm_getpath.cpp index d314c6a225..182b0babea 100644 --- a/rocm_getpath.cpp +++ b/rocm_getpath.cpp @@ -124,6 +124,7 @@ static int getROCmBase(char *buf) // If Environment Variable is not set // use dl APIs to get target lib path // and get rocm base install path using the lib Path. +#if BUILD_SHARED_LIBS sprintf(libFileName, "lib%s.so", TARGET_LIBRARY_NAME); void *handle=dlopen(libFileName,RTLD_NOW); if (!handle){ @@ -157,6 +158,7 @@ static int getROCmBase(char *buf) return PathLinuxRuntimeErrors; } *end = '\0'; +#endif /* Length of Path String up to Parent Directoy (ROCm Base Path) * with trailing '/'.*/ diff --git a/rocm_getpath.h.in b/rocm_getpath.h.in index b4dab8e1d2..c0eb448f52 100644 --- a/rocm_getpath.h.in +++ b/rocm_getpath.h.in @@ -34,6 +34,9 @@ extern "C" { #define LIB_API_PUBLIC __attribute__ ((visibility ("default"))) +/* Get Library Target Build Type */ +#cmakedefine01 BUILD_SHARED_LIBS + /* Return Status Flag Definitions*/ typedef enum { PathSuccess=0, From 2cc55b27acb10e3c3aa7015a1de40566693b237c Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Tue, 11 Jun 2024 13:24:59 -0500 Subject: [PATCH 42/61] SWDEV-467155 : Add llvm to RPATH search path Change-Id: I3598d7938bd63b06fd9cf14906c4ed3e7cc52a82 --- runpath_to_rpath.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runpath_to_rpath.py b/runpath_to_rpath.py index c4415124f7..f6a9203402 100644 --- a/runpath_to_rpath.py +++ b/runpath_to_rpath.py @@ -169,7 +169,8 @@ def main(): sys.exit(0) # Find the elf files in the serach path and update DT_RUNPATH to DT_RPATH - excludes = ['llvm', 'rocm-llvm', 'rocm-llvm-alt'] + # SWDEV-467155 : remove the exclusion of llvm folder + excludes = [] update_rpath(args.searchdir, excludes) # Update rocm clang configs to default to DT_RPATH update_compiler_config(args.searchdir) From 749b656cf7ba52edcc0e1c2a7b5f4f2a9999a51f Mon Sep 17 00:00:00 2001 From: AravindanC Date: Thu, 5 Sep 2024 19:48:04 -0700 Subject: [PATCH 43/61] SWDEV-342167 - Remove Hard Coded Install Permission Change-Id: Ib8206e58f3f1772735e62c93ba8ac32e752bad83 --- CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8746fb43e7..417de24337 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,7 +137,6 @@ if(BUILD_SHARED_LIBS) # Target Library needs to installed/packaged to same destination # in both ASAN and nonASAN Shared library builds install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} - PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE COMPONENT ${COMP_TYPE} ) install ( FILES ${BUILD_DIR}/rocm_version.h ${BUILD_DIR}/rocm_getpath.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core From eedf4c1410813cc225c2a85d7e36167fe3cb71e3 Mon Sep 17 00:00:00 2001 From: AravindanC Date: Tue, 17 Sep 2024 10:16:24 -0700 Subject: [PATCH 44/61] Enable cmake module config/target for rocm-core Change-Id: Icbdd6d1e0e9a865dc86b6568bf0b7f7ff35b3b5c --- CMakeLists.txt | 45 ++++++++++++++++++++++++- cmake_modules/rocm-core-config.cmake.in | 18 ++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 cmake_modules/rocm-core-config.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 417de24337..baa7e47d39 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,9 @@ project( ${CORE_TARGET} CXX ) ## Define Lib Target Name and Lib Target Install Dir to be available to c++ source add_definitions( -DTARGET_LIBRARY_NAME=\"${CORE_TARGET}\" -DTARGET_LIBRARY_INSTALL_DIR=\"${CMAKE_INSTALL_LIBDIR}\" ) +## Build Type Settings +set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." ) + ## Verbose output. set( CMAKE_VERBOSE_MAKEFILE on ) @@ -136,7 +139,7 @@ if(BUILD_SHARED_LIBS) # Target Library needs to installed/packaged to same destination # in both ASAN and nonASAN Shared library builds - install ( TARGETS ${CORE_TARGET} DESTINATION ${CMAKE_INSTALL_LIBDIR} + install ( TARGETS ${CORE_TARGET} EXPORT rocmCoreTargets DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${COMP_TYPE} ) install ( FILES ${BUILD_DIR}/rocm_version.h ${BUILD_DIR}/rocm_getpath.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rocm-core @@ -161,6 +164,7 @@ else() DESTINATION .info COMPONENT ${STATIC_COMP_TYPE} ) install ( TARGETS ${CORE_TARGET} + EXPORT rocmCoreTargets DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${STATIC_COMP_TYPE} ) @@ -180,6 +184,45 @@ else() COMPONENT ${STATIC_COMP_TYPE}) endif() +## Cmake module config file configurations +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/" CACHE INTERNAL "Default module path.") + +## Export the package for use from the build-tree +## (this registers the build-tree with a global CMake-registry) +export(PACKAGE ${CORE_TARGET}) +set(CONF_LIB_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}") + +## Create the rocm-core-config.cmake and rocm-core-config-version files +include(CMakePackageConfigHelpers) +set(CONFIG_PACKAGE_INSTALL_DIR ${CONF_LIB_DIR}/cmake/${CORE_TARGET}) +set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") +set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") +set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}") + +## Generate Config File for rocm-core +configure_package_config_file( + ${CMAKE_MODULE_PATH}/${CORE_TARGET}-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${CORE_TARGET}-config.cmake + INSTALL_DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} + PATH_VARS LIB_INSTALL_DIR INCLUDE_INSTALL_DIR BIN_INSTALL_DIR +) + +## Generate config Version File for rocm-core +write_basic_package_version_file( + ${CMAKE_CURRENT_BINARY_DIR}/${CORE_TARGET}-config-version.cmake + VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" + COMPATIBILITY SameMajorVersion) + +## Install the rocm-core-config.cmake and rocm-core-config-version.cmake +install(FILES + "${PROJECT_BINARY_DIR}/${CORE_TARGET}-config.cmake" + "${PROJECT_BINARY_DIR}/${CORE_TARGET}-config-version.cmake" + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_TARGET}" + COMPONENT ${COMP_TYPE}) + +## Install the export set for use with the install-tree +install(EXPORT rocmCoreTargets DESTINATION + "${CMAKE_INSTALL_LIBDIR}/cmake/${CORE_TARGET}" COMPONENT ${COMP_TYPE}) ## Packaging directives set ( CPACK_PACKAGE_VENDOR "Advanced Micro Devices, Inc." ) diff --git a/cmake_modules/rocm-core-config.cmake.in b/cmake_modules/rocm-core-config.cmake.in new file mode 100644 index 0000000000..f5fe07c8bd --- /dev/null +++ b/cmake_modules/rocm-core-config.cmake.in @@ -0,0 +1,18 @@ +# - Config file for the rocm-core package +# It defines the following variables +# ROCM_CORE_INCLUDE_DIR - include directories for rocm-core +# ROCM_CORE_LIB_DIR - libraries to link against +# ROCM_PATH - Install Base Location for ROCM. + +@PACKAGE_INIT@ + +# Compute paths +set_and_check(rocm_core_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set_and_check(ROCM_CORE_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@") +set_and_check(rocm_core_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") +set_and_check(ROCM_CORE_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") +set_and_check(ROCM_PATH "${PACKAGE_PREFIX_DIR}") + +get_filename_component(ROCM_CORE_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +include("${ROCM_CORE_CMAKE_DIR}/rocmCoreTargets.cmake") + From b67be0d02c9c6e924546e8935cafb94c3586c432 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Tue, 15 Oct 2024 12:05:09 -0700 Subject: [PATCH 45/61] SWDEV-489527 - Remove hard coded paths in rocmmod This will make rocmmod relocatable Change-Id: Iefcdf158e975d6d757f55f8854f34d9b989002be --- rocmmod.in | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rocmmod.in b/rocmmod.in index ba5c23780d..3f0466d454 100644 --- a/rocmmod.in +++ b/rocmmod.in @@ -3,15 +3,16 @@ ## Rocm module ## -module-whatis "adds `@CPACK_PACKAGING_INSTALL_PREFIX@/bin' to your PATH environment variable" +module-whatis "Adds ROCm binary paths to your environment variable" proc ModulesHelp { } { puts stderr "\tThe ROCM Module." } +set ROOT [file normalize [file dirname [file normalize ${ModulesCurrentModulefile}/__]]/../..] -prepend-path PATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_BINDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/bin" -prepend-path MANPATH "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_MANDIR@:@CPACK_PACKAGING_INSTALL_PREFIX@/llvm/share/man1" -prepend-path CMAKE_PREFIX_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" -setenv ROCM_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" -setenv HIP_PATH "@CPACK_PACKAGING_INSTALL_PREFIX@" +prepend-path PATH "${ROOT}/@CMAKE_INSTALL_BINDIR@:${ROOT}/lib/llvm/bin" +prepend-path MANPATH "${ROOT}/@CMAKE_INSTALL_MANDIR@:${ROOT}/lib/llvm/share/man1" +prepend-path CMAKE_PREFIX_PATH "${ROOT}" +setenv ROCM_PATH "${ROOT}" +setenv HIP_PATH "${ROOT}" From f2208f6452ef3805d427abbdac51547285cff383 Mon Sep 17 00:00:00 2001 From: Ranjith Ramakrishnan Date: Fri, 11 Oct 2024 13:23:42 -0700 Subject: [PATCH 46/61] SWDEV-489527 - Create /opt/rocm softlink only for prefix paths that starts with /opt/rocm- USE $RPM_INSTALL_PREFIX0 rather than hard coded paths in the post/pre install scripts for rpm use case Change-Id: I56c66f0befd5502fd2a4218f0b661661259436ed --- rocm-core.postinst | 13 +++++++++++-- rocm-core.prerm | 11 +++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/rocm-core.postinst b/rocm-core.postinst index 9983886070..5ee9337454 100755 --- a/rocm-core.postinst +++ b/rocm-core.postinst @@ -34,13 +34,22 @@ do_update_alternatives(){ altscore=$((altscore*1000000+(now-1600000000)/60)) # Update the /opt/rocm symlink - update-alternatives --install "/opt/rocm" "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" "$altscore" + # For custom location installation of rpm package, /opt/rocm symlink is not required + # TBD: For custom location installation of deb package. + if [[ "$DISTRIB_ID" == "Ubuntu" ]] || [[ "$RPM_INSTALL_PREFIX0" == "/opt/rocm-"* ]] ; then + update-alternatives --install "/opt/rocm" "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" "$altscore" + fi + for loc in "/usr/share/modules/modulefiles" "/usr/local/Modules/modulefiles" "/usr/share/Modules/modulefiles" do if [ -d "$loc" ] then mkdir -p "$loc/rocm" - update-alternatives --install "$loc/rocm/@ROCM_VERSION@" "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore" + if [[ "$DISTRIB_ID" == "Ubuntu" ]] ; then + update-alternatives --install "$loc/rocm/@ROCM_VERSION@" "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore" + else + update-alternatives --install "$loc/rocm/@ROCM_VERSION@" "rocmmod@ROCM_VERSION@" "$RPM_INSTALL_PREFIX0/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore" + fi break; fi done diff --git a/rocm-core.prerm b/rocm-core.prerm index 1fba7c9752..f57109a435 100755 --- a/rocm-core.prerm +++ b/rocm-core.prerm @@ -4,8 +4,15 @@ do_update_alternatives(){ # skip update if program doesn't exist command -v update-alternatives >/dev/null || return 0 # Update the /opt/rocm symlink - update-alternatives --remove "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" - update-alternatives --remove "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod"|| true + if [[ "$DISTRIB_ID" == "Ubuntu" ]] || [[ "$RPM_INSTALL_PREFIX0" == "/opt/rocm-"* ]] ; then + update-alternatives --remove "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" + fi + + if [[ "$DISTRIB_ID" == "Ubuntu" ]] ; then + update-alternatives --remove "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod"|| true + else + update-alternatives --remove "rocmmod@ROCM_VERSION@" "$RPM_INSTALL_PREFIX0/@CMAKE_INSTALL_LIBDIR@/rocmmod"|| true + fi } if [ -e /etc/lsb-release ] && source /etc/lsb-release && [ "$DISTRIB_ID" = "Ubuntu" ] From 58d9a05f9530998bfbd94f3ac2b1a7ee267a5d67 Mon Sep 17 00:00:00 2001 From: Nirmal Unnikrishnan Date: Tue, 10 Sep 2024 15:29:28 -0500 Subject: [PATCH 47/61] SWDEV-484091 : Correcting LIB_PATCH_VERSION ROCM_LIBPATCH_VERSION will be set in ENV and should be using that for setting library patch version. Fixing the bug as the patch version was not taken from ENV Change-Id: I020e48ce5169c17b916be99311623198da1cabf7 --- CMakeLists.txt | 16 +++++++++++++--- utils.cmake | 17 ++++++++++++++--- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index baa7e47d39..afb0f752fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,13 @@ if( NOT DEFINED BUILD_ID ) set( BUILD_ID "9999") endif() -set( PACKAGE_BUILD_INFO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-${BUILD_ID}-${VERSION_HASH}" ) +#Add the libpatch version if available +if( DEFINED VERSION_POINT ) + set( PACKAGE_BUILD_INFO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}.${VERSION_COMMIT_COUNT}-${BUILD_ID}-${VERSION_HASH}" ) + message ( STATUS "PACKAGE_BUILD_INFO ${PACKAGE_BUILD_INFO}" ) +else () + set( PACKAGE_BUILD_INFO "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_COMMIT_COUNT}-${BUILD_ID}-${VERSION_HASH}" ) +endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocmmod.in ${BUILD_DIR}/rocmmod @ONLY ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.postinst ${BUILD_DIR}/postinst @ONLY ) @@ -130,8 +136,12 @@ else() endif() endif() -#intallation directive -file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) +#Add the libpatch version if available to the version file +if( DEFINED VERSION_POINT ) + file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}-${BUILD_ID}\n" ) +else() + file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) +endif() ## Support for Static and Shared Target Packaging if(BUILD_SHARED_LIBS) diff --git a/utils.cmake b/utils.cmake index 3b48f05bca..f9fb2fd319 100644 --- a/utils.cmake +++ b/utils.cmake @@ -57,6 +57,12 @@ function( parse_rocm_version VERSION_STRING ) set ( TEMP_VERSION_STRING "${TEMP_VERSION_STRING}.${PATCH}" ) endif () + if ( ${VERSION_COUNT} GREATER 3 ) + list ( GET VERSIONS 3 POINT ) + set ( VERSION_POINT ${POINT} PARENT_SCOPE ) + set ( TEMP_VERSION_STRING "${TEMP_VERSION_STRING}.${POINT}" ) + endif () + if ( DEFINED VERSION_BUILD ) set ( VERSION_BUILD "${VERSION_BUILD}" PARENT_SCOPE ) endif () @@ -113,7 +119,7 @@ function( set_variables ) endif() #set libpatch version - if(NOT DEFINED ROCM_LIBPATCH_VERSION) + if(NOT DEFINED ENV{ROCM_LIBPATCH_VERSION}) set(ROCM_LIBPATCH_VERSION "${VERSION_MAJOR}") string(LENGTH ${VERSION_MINOR} LENSTR) if(LENSTR EQUAL 1) # length of version cannot be zero hence it would be 1 or greater @@ -130,15 +136,17 @@ function( set_variables ) endif() set(ROCM_LIBPATCH_VERSION "${ROCM_LIBPATCH_VERSION}" PARENT_SCOPE ) + else() + set (ROCM_LIBPATCH_VERSION $ENV{ROCM_LIBPATCH_VERSION} PARENT_SCOPE ) endif() - if ( DEFINED CPACK_RPM_PACKAGE_RELEASE ) + if ( DEFINED ENV{CPACK_RPM_PACKAGE_RELEASE} ) set ( CPACK_RPM_PACKAGE_RELEASE ${CPACK_RPM_PACKAGE_RELEASE} PARENT_SCOPE ) else() set ( CPACK_RPM_PACKAGE_RELEASE "local" PARENT_SCOPE ) endif() - if ( DEFINED CPACK_DEBIAN_PACKAGE_RELEASE ) + if ( DEFINED ENV{CPACK_DEBIAN_PACKAGE_RELEASE} ) set ( CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE} PARENT_SCOPE ) else() set ( CPACK_DEBIAN_PACKAGE_RELEASE "local" PARENT_SCOPE ) @@ -146,13 +154,16 @@ function( set_variables ) set( VERSION_COMMIT_COUNT "${VERSION_COMMIT_COUNT}" PARENT_SCOPE ) set( VERSION_HASH "${VERSION_HASH}" PARENT_SCOPE ) + set( VERSION_BUILD "${VERSION_BUILD}" PARENT_SCOPE ) message(STATUS "VERSION_MAJOR : ${VERSION_MAJOR}" ) message(STATUS "VERSION_MINOR : ${VERSION_MINOR}" ) message(STATUS "VERSION_PATCH : ${VERSION_PATCH}" ) + message(STATUS "VERSION_POINT : ${VERSION_POINT}" ) message(STATUS "ROCM_LIBPATCH_VERSION : ${ROCM_LIBPATCH_VERSION}" ) message(STATUS "VERSION_COMMIT_COUNT : ${VERSION_COMMIT_COUNT}" ) message(STATUS "VERSION_HASH : ${VERSION_HASH}" ) + message(STATUS "VERSION_BUILD : ${VERSION_BUILD}" ) message(STATUS "CPACK_DEBIAN_PACKAGE_RELEASE : ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) message(STATUS "CPACK_RPM_PACKAGE_RELEASE : ${CPACK_RPM_PACKAGE_RELEASE}" ) From f08bbaf443aa84a31b8a242fe83bc8cac655cb66 Mon Sep 17 00:00:00 2001 From: AravindanC Date: Wed, 23 Oct 2024 14:37:19 -0700 Subject: [PATCH 48/61] Change Log Update for 6.3 Release Change-Id: I9e4295959e8de60600eaf93b5074dd8d3b66abc9 --- CHANGELOG.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ec10512fc3..a3f54112c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ Change Logs for rocm-core -Unreleased ROCm6.1.0 release +Unreleased ROCm6.3.0 release + - Enabled Support for CMAKE Module Config. +ROCm6.1.0 release - Added new API to get ROCm install Path (getROCmInstallPath()) at runtime using dlinfo of rocm-core Target Library. ROCm6.0.0 release From d11f5c20d500f729c393680a01fa902ebf92094b Mon Sep 17 00:00:00 2001 From: arvindcheru <90783369+arvindcheru@users.noreply.github.com> Date: Mon, 2 Dec 2024 23:24:44 -0500 Subject: [PATCH 49/61] Update ROCM-CORE contributing template and basics docs (#9) * Add Contributing documentation as per template, updated Readme documentation and Update codeowners * Moving Readme.txt to Readme.md format * Update Review Comments - CMAKE commands Updated, removed library dump and added API usage * Update Review Comments - Enhanced Text descriptions, prerequisites/install prefix descriptions * Update Review Comments - Added RPM Package Samples also and Enhanced Descriptions --- CODEOWNERS | 2 +- CONTRIBUTING.md | 161 +++++++++++++++++++++++++++++++++++ README.md | 217 ++++++++++++++++++++++++++++++++++++++++++++++++ README.txt | 105 ----------------------- copyright | 2 +- 5 files changed, 380 insertions(+), 107 deletions(-) create mode 100644 CONTRIBUTING.md create mode 100644 README.md delete mode 100644 README.txt diff --git a/CODEOWNERS b/CODEOWNERS index 89ea81341f..d239e886d7 100644 --- a/CODEOWNERS +++ b/CODEOWNERS @@ -1 +1 @@ -* @nunnikri @frepaul @raramakr @ashutom @amd-isparry +* @nunnikri @frepaul @raramakr @ashutom @amd-isparry @arvindcheru diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..002210e947 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,161 @@ +# ROCM-CORE Contributing Guide +To ensure the quality of the ROCM-CORE code base, the ROCM-CORE team has +established a code review process to inform developers of the steps +that are required to shepherd a change-set into the repository. + +#### Table Of Contents + +[How to get started](#How-to-get-started) + +[How do I contribute?](#how-do-i-contribute) + * [Reporting Issues](#reporting-issues) + * [Creating a Pull Request](#Creating-a-Pull-Request) + +[Responsibility of the Author](#Responsibility-of-the-Author) + +[Responsibility of the Reviewer](#Responsibility-of-the-Reviewer) + +[The Review](#the-review) + +[References](#References) +## How to get started +rocm-core is a utility which can be used to get ROCm release version. +It also provides the Lmod modules files for the ROCm release. +getROCmVersion function provides the ROCm version. + +## How do I contribute +### Deliverables +All contributions you make will be under the [MIT Software License](copyright). +For each new file in repository, +Please include the licensing header +``` +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 20xx Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +``` + +### Formatting the code + +All the code is formatted using `clang-format`. To format a file, use: + +```shell +clang-format-10 -style=file -i +``` + + +### Reporting Issues +We use [GitHub Issues](https://github.com/ROCm/rocm-core/issues) to track public **bugs** and **enhancement requests**. + +#### Bugs +Please follow the template below to report any bugs found in ROCM-CORE: + +1. Description: ***Please be clear and descriptive*** +2. How to Reproduce the issue: +* Hardware Information: +* Docker environment or Software Version: +* Expected behavior: +* Actual behavior: +3. Any additional information: + +#### Enhancement Requests +Please follow the template below to report any enhancement requests for ROCM-CORE: + +1. Description: ***Please be clear and descriptive*** +2. Value and Motivation: +* Feature and functionalities enabled: +* Any alternatives: +3. Any additional information: + +The author must set labels (and assigns a milestone) according to his/her own understanding. + +Other contributors can change these values if they disagree. That being said, +adding a small comment explaining the motivation is highly recommended. +In this way, we keep the process flexible while cultivating mutual understanding. + +[**Note**] Most likely, the labels like "bug", "feature" or "complexity*" +would not be changed. However, "value*" or "urgency*" might be from mutual +understanding. +### Creating a Pull Request + +No changes are allowed to be directly committed to the develop +branch of the ROCM-CORE repository. All authors are required to +develop their change sets on a separate branch and then create +a pull request (PR) to merge their changes into the develop branch. + +Once a PR has been created, a developer must choose two reviewers +to review the changes made. The first reviewer should be a +technical expert in the portion of the library that the changes +are being made in. You can find a list of these experts in +[CODEOWNERS](CODEOWNERS) list. +The second reviewer should be a peer reviewer. This reviewer +can be any other ROCM-CORE developer. + +## Responsibility of the Author +The author of a PR is responsible for: + * Writing clear, well documented code + * Meeting expectations of code quality + * Verifying that the changes do not break current functionality + * Writing tests to ensure code coverage + * Report on the impact to performance + +## Responsibility of the Reviewer +Each reviewer is responsible for verifying that the changes are +clearly written in keeping with the coding styles of the library, +are documented in a way that future developers will be able to +understand the intent of the added functionality, and will +maintain or improve the overall quality of the codebase. + +Reviewer's task checklist: +1. Has the PR passed? +2. Does the PR consist of a well-organized sequence of small commits, +each of which is designed to make one specific feature or fix ? +3. Does the PR only include a reviewable amount of changes? Or it is a +consolidation of already reviewed small batches? e.g. break it into smaller +testable and reviewable tasks instead of a huge chunk at once. +4. Does the PR have sufficient documentation and easy to read and understand, +feasible for test and future maintainence, related docs already in place? +if API or functionality has changed? +5. For bugfixes and new features, new regression test created? +6. Is every PR associated with a ticket or issue number for tracking purposes? + +## The Review +During the review, reviewers will look over the changes and make +suggestions or requests for changes. + +In order to assist the reviewer in prioritizing their efforts, +authors can take the following actions: + +* Set the urgency and value labels +* Set the milestone where the changes need to be delivered +* Describe the testing procedure and post the measured effect of + the change +* Remind reviewers via email if a PR needs attention +* If a PR needs to be reviewed as soon as possible, explain to + the reviewers why a review may need to take priority + +## References + +1. [ROCM-CORE Readme](README.md) + diff --git a/README.md b/README.md new file mode 100644 index 0000000000..110dfdd624 --- /dev/null +++ b/README.md @@ -0,0 +1,217 @@ +# ROCM-CORE Introduction + +ROCM-CORE is a package which can be used to get ROCm release version, get ROCm install path information etc. +It is also important to note that ROCM-CORE takes the role as a base component on which all of ROCm can depend, +to make it easy to remove all of ROCm with a package manager. + +getROCmVersion function provides the ROCm version. + +It also provides an example Lmod modules files for the ROCm release. + +Lmod module files can be loaded with the following commands. +``` shell +module load rocm/x.y or +module load rocm +``` + +You can find sources and binaries in our [GitHub repository](https://github.com/ROCm/rocm-core). + +> [!NOTE] +> As with all ROCm projects, the documentation is open source. For more information, see [Contribute to ROCm documentation](https://rocm.docs.amd.com/en/latest/contribute/contributing.html). + +## Installing ROCM-CORE + +Before we proceed with how to install, take a look on references given below to understand System requirements, ROCm Installation prerequisites, ROCm package repository set up etc. + +### Prerequisite References + +* Refer [System Requirements](https://rocm.docs.amd.com/projects/install-on-linux/en/docs-6.2.2/reference/system-requirements.html#supported-gpus) +* Refer [ROCm installation for Linux](https://rocm.docs.amd.com/projects/install-on-linux/en/docs-6.2.2/index.html) +* A [ROCm](https://rocm.docs.amd.com/)-enabled platform +* To be noted that ROCM-CORE library primarily depends on having the C library available for the respective platform. + +### Installing with pre-built packages + +You can install ROCM-CORE on Ubuntu using + +```shell +apt-get install rocm-core +``` + +## Building ROCM-CORE from source + +You can build ROCM-CORE form source + +First, get the sources from repository. + +```shell + git clone https://github.com/ROCm/rocm-core.git +``` + +Go to Root Directory, create a build directory: + +```shell + cd rocm-core; mkdir build; cd build +``` + +Next, configure CMake. Invoke cmake with the following variables define as deemed fit + +```shell +cmake -S $PWD/../ -B . \ + -DCMAKE_VERBOSE_MAKEFILE=1 \ + -DCMAKE_INSTALL_PREFIX=./ \ + -DROCM_VERSION="6.4.0" \ + .. +``` + +>[!NOTE] +>When specifying the path for the `CMAKE_PREFIX_PATH` variable, **do not** use the tilde (`~`) +>shorthand to represent the home directory. +### Setting up install locations +By default, the install location is set to `/opt/rocm`. You can change this using +`CMAKE_INSTALL_PREFIX`: +```shell +cmake -DCMAKE_INSTALL_PREFIX= .. +``` +where rocm-core-install-path is "./" in the cmake configure command shared above. + +### Install + +Once cmake configuration successfully completed, from the same build directory run build, install targets + +```shell +cmake --build . -- +cmake --build . -- install +``` + +### Package Generated + +Once cmake configuration and build successfully completed from the same build directory trigger package generation + +```shell +cmake --build . -- package +``` + +Once successfull execution of above command "rocm-core" RPM/DEBIAN packages will be generated (ex:rocm-core_6.4.0.60400-22.04_amd64.deb, rocm-core-6.4.0.60400-x86_64.rpm). The contents of the "rocm-core" package will include the following files: + +```shell +Debian Package Sample: +$ dpkg -I rocm-core_6.4.0.60400-crdnnh.15158~22.04_amd64.deb + new debian package, version 2.0. + size 13986 bytes: control archive=2083 bytes. + 305 bytes, 10 lines control + 917 bytes, 11 lines md5sums + 2871 bytes, 75 lines * postinst #!/bin/bash + 873 bytes, 32 lines * prerm #!/bin/bash + Architecture: amd64 + Description: Radeon Open Compute (ROCm) Runtime software stack + Homepage: https://github.com/RadeonOpenCompute/ROCm + Maintainer: ROCm Dev Support + Package: rocm-core + Priority: optional + Section: devel + Version: 6.4.0.60400-crdnnh.15158~22.04 + Installed-Size: 125 + +$ dpkg -c rocm-core_6.4.0.60400-crdnnh.15158~22.04_amd64.deb +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/ +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/ +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/.info/ +-rw-r--r-- root/root 12 2024-11-22 10:37 ./opt/rocm-6.4.0/.info/version +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/include/ +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/include/rocm-core/ +-rw-r--r-- root/root 2801 2024-11-22 10:37 ./opt/rocm-6.4.0/include/rocm-core/rocm_getpath.h +-rw-r--r-- root/root 2440 2024-11-22 10:37 ./opt/rocm-6.4.0/include/rocm-core/rocm_version.h +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/ +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/cmake/ +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/cmake/rocm-core/ +-rw-r--r-- root/root 2878 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/cmake/rocm-core/rocm-core-config-version.cmake +-rw-r--r-- root/root 1590 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/cmake/rocm-core/rocm-core-config.cmake +-rw-r--r-- root/root 842 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/cmake/rocm-core/rocmCoreTargets-release.cmake +-rw-r--r-- root/root 3774 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/cmake/rocm-core/rocmCoreTargets.cmake +lrwxrwxrwx root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/librocm-core.so -> librocm-core.so.1 +lrwxrwxrwx root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/librocm-core.so.1 -> librocm-core.so.1.0.60400 +-rw-r--r-- root/root 16640 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/librocm-core.so.1.0.60400 +-rw-r--r-- root/root 550 2024-11-22 10:37 ./opt/rocm-6.4.0/lib/rocmmod +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/libexec/ +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/libexec/rocm-core/ +-rw-r--r-- root/root 8208 2024-11-22 10:34 ./opt/rocm-6.4.0/libexec/rocm-core/runpath_to_rpath.py +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/share/ +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/share/doc/ +drwxr-xr-x root/root 0 2024-11-22 10:37 ./opt/rocm-6.4.0/share/doc/rocm-core/ +-rw-r--r-- root/root 1113 2024-11-22 10:34 ./opt/rocm-6.4.0/share/doc/rocm-core/LICENSE.txt + +RPM Package Sample: +$ rpm -qip rocm-core-6.4.0.60400-crdnnh.15158.el8.x86_64.rpm +Name : rocm-core +Version : 6.4.0.60400 +Release : crdnnh.15158.el8 +Architecture: x86_64 +Install Date: (not installed) +Group : unknown +Size : 37096 +License : MIT +Signature : (none) +Source RPM : rocm-core-6.4.0.60400-crdnnh.15158.el8.src.rpm +Build Date : Fri 22 Nov 2024 10:41:01 AM PST +Build Host : 514dbdf6c195 +Relocations : /opt/rocm-6.4.0 +Vendor : Advanced Micro Devices, Inc. +Summary : Radeon Open Compute (ROCm) Runtime software stack +Description : +DESCRIPTION +=========== + +This is an installer created using CPack (https://cmake.org). No additional installation instructions provided. +$ rpm -qlp rocm-core-6.4.0.60400-crdnnh.15158.el8.x86_64.rpm +/opt/rocm-6.4.0 +/opt/rocm-6.4.0/.info +/opt/rocm-6.4.0/.info/version +/opt/rocm-6.4.0/include +/opt/rocm-6.4.0/include/rocm-core +/opt/rocm-6.4.0/include/rocm-core/rocm_getpath.h +/opt/rocm-6.4.0/include/rocm-core/rocm_version.h +/opt/rocm-6.4.0/lib +/opt/rocm-6.4.0/lib/cmake +/opt/rocm-6.4.0/lib/cmake/rocm-core +/opt/rocm-6.4.0/lib/cmake/rocm-core/rocm-core-config-version.cmake +/opt/rocm-6.4.0/lib/cmake/rocm-core/rocm-core-config.cmake +/opt/rocm-6.4.0/lib/cmake/rocm-core/rocmCoreTargets-release.cmake +/opt/rocm-6.4.0/lib/cmake/rocm-core/rocmCoreTargets.cmake +/opt/rocm-6.4.0/lib/librocm-core.so +/opt/rocm-6.4.0/lib/librocm-core.so.1 +/opt/rocm-6.4.0/lib/librocm-core.so.1.0.60400 +/opt/rocm-6.4.0/lib/rocmmod +/opt/rocm-6.4.0/libexec +/opt/rocm-6.4.0/libexec/rocm-core +/opt/rocm-6.4.0/libexec/rocm-core/runpath_to_rpath.py +/opt/rocm-6.4.0/share +/opt/rocm-6.4.0/share/doc +/opt/rocm-6.4.0/share/doc/rocm-core +/opt/rocm-6.4.0/share/doc/rocm-core/LICENSE.txt + + +``` + + +## ROCM-CORE Library + +ROCM-CORE Library generated will be found in lib directory of the rocm-core package generated. + +```shell +find . -name "librocm-core.so.*" +``` + +### Sample Usage of APIs provided by rocm-core Library +#### Get ROCm Version + +For getting ROCm Version make use of getROCMVersion() API. +Sample Usage Example as shown below. + +```C +// Usage : + int mj=0,mn=0,p=0,ret=0; + ret=getROCMVersion(&mj,&mn,&p); + if(ret !=VerSuccess ) // error occured +``` + diff --git a/README.txt b/README.txt deleted file mode 100644 index 2636219c54..0000000000 --- a/README.txt +++ /dev/null @@ -1,105 +0,0 @@ -Introduction: -rocm-core is a utility which can be used to get ROCm release version. -It also provides the Lmod modules files for the ROCm release. -getROCmVersion function provides the ROCm version. - -Lmod module files can be loaded with the following commads. -module load rocm/x.y or -module load rocm - - -Build: - - git clone - - cd rocm-core; mkdir -p build ; cd build - - After this invoke cmake with the following variables define as deemed fit - - - cmake \ - -DCMAKE_CURRENT_BINARY_DIR=$PWD \ - -DCMAKE_CURRENT_SOURCE_DIR=$PWD/../ \ - -DCMAKE_VERBOSE_MAKEFILE=1 \ - -DCMAKE_INSTALL_PREFIX=./ \ - -DCPACK_GENERATOR=DEB \ - -DCPACK_DEBIAN_PACKAGE_RELEASE="local.9999~20.04" \ - -DCPACK_RPM_PACKAGE_RELEASE="local.9999" \ - -DROCM_VERSION="5.5.0" \ - .. - - make - make install - make package - -After this the package "rocm-core_1.0.0-local_amd64.deb" will be generated accordingly - -The content of which will be the following : - -$dpkg -I rocm-core_1.0.0-local_amd64.deb - new Debian package, version 2.0. - size 6604 bytes: control archive=1608 bytes. - 285 bytes, 10 lines control - 191 bytes, 3 lines md5sums - 2360 bytes, 65 lines * postinst #!/bin/bash - 593 bytes, 25 lines * prerm #!/bin/bash - Architecture: amd64 - Description: Radeon Open Compute (ROCm) Runtime software stack - Homepage: https://github.com/RadeonOpenCompute/ROCm - Maintainer: ROCm Dev Support - Package: rocm-core - Priority: optional - Section: devel - Version: 1.0.0-local - Installed-Size: 70 - - -$dpkg -c rocm-core_1.0.0-local_amd64.deb -drwxrwxr-x root/root 0 2022-11-09 09:02 ./opt/ -drwxrwxr-x root/root 0 2022-11-09 09:02 ./opt/rocm/ -drwxrwxr-x root/root 0 2022-11-09 09:02 ./opt/rocm/include/ --rw-r--r-- root/root 2970 2022-11-09 09:02 ./opt/rocm/include/rocm_version.h -drwxrwxr-x root/root 0 2022-11-09 09:02 ./opt/rocm/lib/ -lrwxrwxrwx root/root 0 2022-11-09 09:02 ./opt/rocm/lib/librocm-core.so -> librocm-core.so.1 -lrwxrwxrwx root/root 0 2022-11-09 09:02 ./opt/rocm/lib/librocm-core.so.1 -> librocm-core.so.1.0.0. --rwxr-xr-x root/root 17096 2022-11-09 09:02 ./opt/rocm/lib/librocm-core.so.1.0.0. --rw-r--r-- root/root 420 2022-11-09 09:02 ./opt/rocm/lib/rocmmod - - - -The flags for the lib would the following : - -$readelf -d ./opt/rocm/lib/librocm-core.so.1.0.0. - -Dynamic section at offset 0x2de0 contains 28 entries: - Tag Type Name/Value - 0x0000000000000001 (NEEDED) Shared library: [libstdc++.so.6] - 0x0000000000000001 (NEEDED) Shared library: [libgcc_s.so.1] - 0x0000000000000001 (NEEDED) Shared library: [libc.so.6] - 0x000000000000000e (SONAME) Library soname: [librocm-core.so.1] - 0x000000000000000c (INIT) 0x1000 - 0x000000000000000d (FINI) 0x12dc - 0x0000000000000019 (INIT_ARRAY) 0x3dd0 - 0x000000000000001b (INIT_ARRAYSZ) 8 (bytes) - 0x000000000000001a (FINI_ARRAY) 0x3dd8 - 0x000000000000001c (FINI_ARRAYSZ) 8 (bytes) - 0x000000006ffffef5 (GNU_HASH) 0x2f0 - 0x0000000000000005 (STRTAB) 0x480 - 0x0000000000000006 (SYMTAB) 0x318 - 0x000000000000000a (STRSZ) 558 (bytes) - 0x000000000000000b (SYMENT) 24 (bytes) - 0x0000000000000003 (PLTGOT) 0x4000 - 0x0000000000000002 (PLTRELSZ) 168 (bytes) - 0x0000000000000014 (PLTREL) RELA - 0x0000000000000017 (JMPREL) 0x820 - 0x0000000000000007 (RELA) 0x760 - 0x0000000000000008 (RELASZ) 192 (bytes) - 0x0000000000000009 (RELAENT) 24 (bytes) - 0x000000006ffffffb (FLAGS_1) Flags: NODELETE - 0x000000006ffffffe (VERNEED) 0x6d0 - 0x000000006fffffff (VERNEEDNUM) 3 - 0x000000006ffffff0 (VERSYM) 0x6ae - 0x000000006ffffff9 (RELACOUNT) 3 - 0x0000000000000000 (NULL) 0x0 - - diff --git a/copyright b/copyright index 33843f52b6..8dc3cc8167 100644 --- a/copyright +++ b/copyright @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. +Copyright (c) 2017 - 2024 Advanced Micro Devices, Inc. All rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 61ad6381aab88dc86fd23ccb4adaebec3e472e9b Mon Sep 17 00:00:00 2001 From: AravindanC Date: Wed, 4 Dec 2024 21:52:39 -0800 Subject: [PATCH 50/61] Enable distro id based checks in rocm-core post/pre scripts Change-Id: I1970dc3a36b8bd47d238b032afe5714c3e7f8e57 --- rocm-core.postinst | 6 +++--- rocm-core.prerm | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/rocm-core.postinst b/rocm-core.postinst index 5ee9337454..f72d384163 100755 --- a/rocm-core.postinst +++ b/rocm-core.postinst @@ -36,7 +36,7 @@ do_update_alternatives(){ # Update the /opt/rocm symlink # For custom location installation of rpm package, /opt/rocm symlink is not required # TBD: For custom location installation of deb package. - if [[ "$DISTRIB_ID" == "Ubuntu" ]] || [[ "$RPM_INSTALL_PREFIX0" == "/opt/rocm-"* ]] ; then + if [[ ${ID_LIKE:-$ID} == "debian" ]] || [[ "$RPM_INSTALL_PREFIX0" == "/opt/rocm-"* ]] ; then update-alternatives --install "/opt/rocm" "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" "$altscore" fi @@ -45,7 +45,7 @@ do_update_alternatives(){ if [ -d "$loc" ] then mkdir -p "$loc/rocm" - if [[ "$DISTRIB_ID" == "Ubuntu" ]] ; then + if [[ ${ID_LIKE:-$ID} == "debian" ]] ; then update-alternatives --install "$loc/rocm/@ROCM_VERSION@" "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore" else update-alternatives --install "$loc/rocm/@ROCM_VERSION@" "rocmmod@ROCM_VERSION@" "$RPM_INSTALL_PREFIX0/@CMAKE_INSTALL_LIBDIR@/rocmmod" "$altscore" @@ -56,7 +56,7 @@ do_update_alternatives(){ true } -if [ -e /etc/lsb-release ] && source /etc/lsb-release && [ "$DISTRIB_ID" = "Ubuntu" ] +if [ -e /etc/os-release ] && source /etc/os-release && [[ ${ID_LIKE:-$ID} == "debian" ]] then case "$1" in (configure) diff --git a/rocm-core.prerm b/rocm-core.prerm index f57109a435..c500ef831f 100755 --- a/rocm-core.prerm +++ b/rocm-core.prerm @@ -4,18 +4,18 @@ do_update_alternatives(){ # skip update if program doesn't exist command -v update-alternatives >/dev/null || return 0 # Update the /opt/rocm symlink - if [[ "$DISTRIB_ID" == "Ubuntu" ]] || [[ "$RPM_INSTALL_PREFIX0" == "/opt/rocm-"* ]] ; then + if [[ ${ID_LIKE:-$ID} == "debian" ]] || [[ "$RPM_INSTALL_PREFIX0" == "/opt/rocm-"* ]] ; then update-alternatives --remove "rocm" "@CPACK_PACKAGING_INSTALL_PREFIX@" fi - if [[ "$DISTRIB_ID" == "Ubuntu" ]] ; then + if [[ ${ID_LIKE:-$ID} == "debian" ]] ; then update-alternatives --remove "rocmmod@ROCM_VERSION@" "@CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@/rocmmod"|| true else update-alternatives --remove "rocmmod@ROCM_VERSION@" "$RPM_INSTALL_PREFIX0/@CMAKE_INSTALL_LIBDIR@/rocmmod"|| true fi } -if [ -e /etc/lsb-release ] && source /etc/lsb-release && [ "$DISTRIB_ID" = "Ubuntu" ] +if [ -e /etc/os-release ] && source /etc/os-release && [[ ${ID_LIKE:-$ID} == "debian" ]] then case "$1" in (remove | upgrade) From 79edda7cc88178756fee2b069be562afa971be0d Mon Sep 17 00:00:00 2001 From: Jonathan Luu Date: Fri, 31 Jan 2025 12:06:41 -0500 Subject: [PATCH 51/61] SWDEV-511848 - Update package description to the correct Name and source link Change-Id: Iee5d22ecd01a15dcfc5caff6f1ab8261d71fbb71 --- CMakeLists.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index afb0f752fb..fd268cda4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,16 +123,16 @@ if(ENABLE_ASAN_PACKAGING) # Only libraries required for ASAN Package set( CPACK_COMPONENTS_ALL CORE_ASAN ) set( COMP_TYPE "CORE_ASAN" ) - set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) AddressSanitizer Instrumented Runtime software stack" ) + set( PKG_DESCRIPTION "ROCm AddressSanitizer Instrumented Runtime software stack" ) else() if(BUILD_SHARED_LIBS) set( CPACK_COMPONENTS_ALL CORE_RUNTIME ) set( COMP_TYPE "CORE_RUNTIME" ) - set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) Runtime software stack" ) + set( PKG_DESCRIPTION "ROCm Runtime software stack" ) else() set( CPACK_COMPONENTS_ALL CORE_STATIC ) set( STATIC_COMP_TYPE "CORE_STATIC" ) - set( PKG_DESCRIPTION "Radeon Open Compute (ROCm) Static software stack" ) + set( PKG_DESCRIPTION "ROCm Static software stack" ) endif() endif() @@ -282,7 +282,7 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) -set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/RadeonOpenCompute/ROCm" ) +set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm/rocm-core" ) set ( CPACK_DEBIAN_CORE_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) set ( CPACK_DEBIAN_CORE_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) set ( CPACK_DEBIAN_CORE_STATIC_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) From dbab4d1afb23e70b9c9c8f4db30da8e8f8e05d6a Mon Sep 17 00:00:00 2001 From: Jonathan Luu Date: Tue, 4 Feb 2025 11:59:40 -0500 Subject: [PATCH 52/61] SWDEV-511848 - update readme Change-Id: Icf590d17f4c1988850f0056e0ec8bc88f921b3be --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 110dfdd624..68868bbe3c 100644 --- a/README.md +++ b/README.md @@ -104,8 +104,8 @@ $ dpkg -I rocm-core_6.4.0.60400-crdnnh.15158~22.04_amd64.deb 2871 bytes, 75 lines * postinst #!/bin/bash 873 bytes, 32 lines * prerm #!/bin/bash Architecture: amd64 - Description: Radeon Open Compute (ROCm) Runtime software stack - Homepage: https://github.com/RadeonOpenCompute/ROCm + Description: ROCm Runtime software stack + Homepage: https://github.com/ROCm/rocm-core Maintainer: ROCm Dev Support Package: rocm-core Priority: optional @@ -157,7 +157,7 @@ Build Date : Fri 22 Nov 2024 10:41:01 AM PST Build Host : 514dbdf6c195 Relocations : /opt/rocm-6.4.0 Vendor : Advanced Micro Devices, Inc. -Summary : Radeon Open Compute (ROCm) Runtime software stack +Summary : ROCm Runtime software stack Description : DESCRIPTION =========== From fd1470bf0c94853872e05331411f7360e1f9b627 Mon Sep 17 00:00:00 2001 From: Jonathan Luu Date: Tue, 1 Apr 2025 16:46:04 -0400 Subject: [PATCH 53/61] SWDEV-521313 - Streamline Version Management: Retain Only version-rocm File --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd268cda4c..743341100b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,9 +138,9 @@ endif() #Add the libpatch version if available to the version file if( DEFINED VERSION_POINT ) - file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}-${BUILD_ID}\n" ) + file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}\n" ) else() - file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) + file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}\n" ) endif() ## Support for Static and Shared Target Packaging From 95f9deb27ca545fb7bf7ed2a50d3d952cd02d08f Mon Sep 17 00:00:00 2001 From: "Cheruvally, Aravindan" Date: Thu, 3 Apr 2025 11:46:00 -0400 Subject: [PATCH 54/61] =?UTF-8?q?Revert=20"SWDEV-521313=20-=20Streamline?= =?UTF-8?q?=20Version=20Management:=20Retain=20Only=20version-roc=E2=80=A6?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 743341100b..fd268cda4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,9 +138,9 @@ endif() #Add the libpatch version if available to the version file if( DEFINED VERSION_POINT ) - file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}\n" ) + file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}-${BUILD_ID}\n" ) else() - file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}\n" ) + file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) endif() ## Support for Static and Shared Target Packaging From 515a826caba7b4814535783b5bd653edc40b88ca Mon Sep 17 00:00:00 2001 From: "Cheruvally, Aravindan" Date: Tue, 29 Apr 2025 15:49:53 -0400 Subject: [PATCH 55/61] Update Pre/Post File Permissions to 0755 (#12) --- CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fd268cda4c..34feaa55c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,8 +74,12 @@ else () endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocmmod.in ${BUILD_DIR}/rocmmod @ONLY ) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.postinst ${BUILD_DIR}/postinst @ONLY ) -configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.prerm ${BUILD_DIR}/prerm @ONLY ) + +# Setting Permission 0755 for pre/post install scripts +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.postinst ${BUILD_DIR}/postinst + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE @ONLY ) +configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.prerm ${BUILD_DIR}/prerm + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE @ONLY ) #Generate BUILD_INFO configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in ${BUILD_DIR}/rocm_version.h @ONLY ) From 339034734ff19d4a98299592ef885a71080910cd Mon Sep 17 00:00:00 2001 From: "Cheruvally, Aravindan" Date: Wed, 30 Apr 2025 18:56:11 -0400 Subject: [PATCH 56/61] Re Enable SWDEV-521313 Streamline Version Management (#10) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "Revert "SWDEV-521313 - Streamline Version Management: Retain Only version-roc…"" This reverts commit 39bd62e592e1591176c2c343d2433e99e29fbc2e. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34feaa55c9..699e8a719e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,9 +142,9 @@ endif() #Add the libpatch version if available to the version file if( DEFINED VERSION_POINT ) - file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}-${BUILD_ID}\n" ) + file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}\n" ) else() - file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}-${BUILD_ID}\n" ) + file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}\n" ) endif() ## Support for Static and Shared Target Packaging From 476b76997dbc76a45b83a817a0bb1efdb25ffadd Mon Sep 17 00:00:00 2001 From: "Ramakrishnan, Ranjith" Date: Tue, 6 May 2025 08:43:03 -0700 Subject: [PATCH 57/61] Remove the backward compatibility code for file reorganization (#14) Remove the backward compatibilty code for file reorganization File reorg backward compatibility support is no longer required --- CMakeLists.txt | 26 -------------- header_template.hpp.in | 48 ------------------------- rocm-core-backward-compat.cmake | 63 --------------------------------- 3 files changed, 137 deletions(-) delete mode 100644 header_template.hpp.in delete mode 100644 rocm-core-backward-compat.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 699e8a719e..991170d88f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,10 +51,6 @@ set( CPACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "package types to be produced " set( COPYRIGHT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/copyright" ) set( BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} ) -if(NOT ENABLE_ASAN_PACKAGING) - option(FILE_REORG_BACKWARD_COMPATIBILITY "Enable File Reorg with backward compatibility" OFF) -endif() - ## Set variables set_variables() @@ -84,28 +80,6 @@ configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm-core.prerm ${BUILD_DIR}/prerm #Generate BUILD_INFO configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm_version.h.in ${BUILD_DIR}/rocm_version.h @ONLY ) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/rocm_getpath.h.in ${BUILD_DIR}/rocm_getpath.h @ONLY ) -#File reorg Backward compatibility function -if(NOT WIN32) - if(FILE_REORG_BACKWARD_COMPATIBILITY) - # To enabe/disable #error in wrapper header files - if(NOT DEFINED ROCM_HEADER_WRAPPER_WERROR) - if(DEFINED ENV{ROCM_HEADER_WRAPPER_WERROR}) - set(ROCM_HEADER_WRAPPER_WERROR "$ENV{ROCM_HEADER_WRAPPER_WERROR}" - CACHE STRING "Header wrapper warnings as errors.") - else() - set(ROCM_HEADER_WRAPPER_WERROR "OFF" CACHE STRING "Header wrapper warnings as errors.") - endif() - endif() - - if(ROCM_HEADER_WRAPPER_WERROR) - set(deprecated_error 1) - else() - set(deprecated_error 0) - endif() - - include(rocm-core-backward-compat.cmake) - endif() #FILE_REORG_BACKWARD_COMPATIBILITY -endif() #Make the rocmlib set( SRCS rocm_version.cpp rocm_getpath.cpp) diff --git a/header_template.hpp.in b/header_template.hpp.in deleted file mode 100644 index 0d8c481e90..0000000000 --- a/header_template.hpp.in +++ /dev/null @@ -1,48 +0,0 @@ -/* - MIT License - - Copyright (c) 2017 - 2023 Advanced Micro Devices, Inc. All rights Reserved. - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. - */ -#ifndef @include_guard@ -#define @include_guard@ - -#ifndef ROCM_HEADER_WRAPPER_WERROR -#define ROCM_HEADER_WRAPPER_WERROR @deprecated_error@ -#endif -#if ROCM_HEADER_WRAPPER_WERROR /* ROCM_HEADER_WRAPPER_WERROR 1 */ -#error "@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ " -#else /* ROCM_HEADER_WRAPPER_WERROR 0 */ -#if defined(__GNUC__) -#warning "@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ " -#else -#pragma message ("@file_name@ has moved to @CPACK_PACKAGING_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@headerfile_dir@ ") -#endif -#endif /* ROCM_HEADER_WRAPPER_WERROR */ - -@include_statements@ - -@hashzero_check@ - -@file_contents@ - -@hash_endif@ - -#endif diff --git a/rocm-core-backward-compat.cmake b/rocm-core-backward-compat.cmake deleted file mode 100644 index e96572e669..0000000000 --- a/rocm-core-backward-compat.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -cmake_minimum_required(VERSION 3.16.8) - -set(ROCM_CORE_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}) -set(ROCM_CORE_WRAPPER_DIR ${ROCM_CORE_BUILD_DIR}/wrapper_dir) -set(ROCM_CORE_WRAPPER_INC_DIR ${ROCM_CORE_WRAPPER_DIR}/include) -set(headerfile_dir "rocm-core") - -#Function to set actual file contents in wrapper files -#Some components grep for the contents in the file -function(set_file_contents input_file) - set(hashzero_check "#if 0 -/* The following is a copy of the original file for the benefit of build systems which grep for values - * in this file rather than preprocess it. This is just for backward compatibility */") - - file(READ ${input_file} file_contents) - set(hash_endif "#endif") - get_filename_component(file_name ${input_file} NAME) - configure_file(${CMAKE_CURRENT_SOURCE_DIR}/header_template.hpp.in ${ROCM_CORE_WRAPPER_INC_DIR}/${file_name}) -endfunction() - -#use header template file and generate wrapper header files -function(generate_wrapper_header) - file(MAKE_DIRECTORY ${ROCM_CORE_WRAPPER_INC_DIR}) - - #find all header files - file(GLOB include_files ${ROCM_CORE_BUILD_DIR}/*.h) - #Create wrapper files - foreach(header_file ${include_files}) - # set include guard - get_filename_component(INC_GAURD_NAME ${header_file} NAME_WE) - string(TOUPPER ${INC_GAURD_NAME} INC_GAURD_NAME) - set(include_guard "ROCM_CORE_WRAPPER_INCLUDE_${INC_GAURD_NAME}_H") - #set #include statement - get_filename_component(file_name ${header_file} NAME) - set(include_statements "#include \"${headerfile_dir}/${file_name}\"\n") - set_file_contents(${header_file}) - endforeach() - -endfunction() - -#Use template header file and generater wrapper header files -generate_wrapper_header() -install(DIRECTORY ${ROCM_CORE_WRAPPER_INC_DIR} DESTINATION . COMPONENT runtime) - From 9683e048895c20cdc8350206cd8ba2ec8543b306 Mon Sep 17 00:00:00 2001 From: "Cheruvally, Aravindan" Date: Wed, 7 May 2025 18:48:46 -0400 Subject: [PATCH 58/61] Add Lintian Debian Packaging Configuration (#13) * SWDEV-531658 / SWDEV-529762 * Add Lintian Debian Packaging Configuration * Updated Debian specific Lintian flag usage * Updated Debian Pkg Extended Description usage * Updated Debian Package ChangeLog * Update Review Comments * Update Review Comments - Renamed debian to DEBIAN folder * Review Comment Update - Extended Description to use common across deb/rpm * Update Review Comments - Change Log Test Updated * Review Comment Update - remove duplicate & enhanced deb copyright header * Update Change Log for the release --- CHANGELOG.md | 4 ++- CMakeLists.txt | 56 +++++++++++++++++++------------ DEBIAN/changelog.in | 5 +++ DEBIAN/copyright.in | 26 +++++++++++++++ utils.cmake | 81 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 149 insertions(+), 23 deletions(-) create mode 100644 DEBIAN/changelog.in create mode 100644 DEBIAN/copyright.in diff --git a/CHANGELOG.md b/CHANGELOG.md index a3f54112c2..2e86a42f2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ Change Logs for rocm-core -Unreleased ROCm6.3.0 release +ROCm6.4.1 release + - Added changelog.debian and copyright for debian packages. +ROCm6.3.0 release - Enabled Support for CMAKE Module Config. ROCm6.1.0 release - Added new API to get ROCm install Path (getROCmInstallPath()) at runtime diff --git a/CMakeLists.txt b/CMakeLists.txt index 991170d88f..d09b094e74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,8 +48,12 @@ parse_rocm_version( ${ROCM_VERSION} ) set( CPACK_PACKAGING_INSTALL_PREFIX "/opt/rocm" CACHE PATH "default cpack directory" ) set( BUILD_SHARED_LIBS ON CACHE BOOL "Build shared library (.so) or not." ) set( CPACK_GENERATOR "TGZ;DEB;RPM" CACHE STRING "package types to be produced " ) -set( COPYRIGHT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/copyright" ) +set( LICENSE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/copyright" ) set( BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR} ) +set( EXTENDED_PACKAGE_DESCRIPTION + "ROCM-CORE is a package which can be used to get ROCm release version, get ROCm install path information etc. + It is also important to note that ROCM-CORE takes the role as a base component on which all of ROCm can depend, + to make it easy to remove all of ROCm with a package manager." CACHE STRING "Debian Package Extended Description") ## Set variables set_variables() @@ -123,7 +127,7 @@ endif() ## Support for Static and Shared Target Packaging if(BUILD_SHARED_LIBS) - install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION .info COMPONENT CORE_RUNTIME ) + install ( FILES ${BUILD_DIR}/version DESTINATION .info COMPONENT CORE_RUNTIME ) # Target Library needs to installed/packaged to same destination # in both ASAN and nonASAN Shared library builds @@ -136,19 +140,19 @@ if(BUILD_SHARED_LIBS) install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runpath_to_rpath.py DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/rocm-core COMPONENT CORE_RUNTIME ) - install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod + install ( FILES ${BUILD_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT CORE_RUNTIME ) # License file - install ( FILES ${COPYRIGHT_FILE} + install ( FILES ${LICENSE_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt COMPONENT CORE_RUNTIME) - install ( FILES ${COPYRIGHT_FILE} DESTINATION + install ( FILES ${LICENSE_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR}-asan RENAME LICENSE.txt COMPONENT CORE_ASAN) else() - install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/version + install ( FILES ${BUILD_DIR}/version DESTINATION .info COMPONENT ${STATIC_COMP_TYPE} ) install ( TARGETS ${CORE_TARGET} @@ -163,11 +167,11 @@ else() install ( FILES ${CMAKE_CURRENT_SOURCE_DIR}/runpath_to_rpath.py DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/rocm-core COMPONENT ${STATIC_COMP_TYPE} ) - install ( FILES ${CMAKE_CURRENT_BINARY_DIR}/rocmmod + install ( FILES ${BUILD_DIR}/rocmmod DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${STATIC_COMP_TYPE} ) # License file - install ( FILES ${COPYRIGHT_FILE} + install ( FILES ${LICENSE_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt COMPONENT ${STATIC_COMP_TYPE}) endif() @@ -186,18 +190,20 @@ set(CONFIG_PACKAGE_INSTALL_DIR ${CONF_LIB_DIR}/cmake/${CORE_TARGET}) set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}") set(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}") set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}") +set(PKG_MAINTAINER_NM "ROCm Dev Support") +set(PKG_MAINTAINER_EMAIL "rocm-dev.support@amd.com") ## Generate Config File for rocm-core configure_package_config_file( ${CMAKE_MODULE_PATH}/${CORE_TARGET}-config.cmake.in - ${CMAKE_CURRENT_BINARY_DIR}/${CORE_TARGET}-config.cmake + ${BUILD_DIR}/${CORE_TARGET}-config.cmake INSTALL_DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR} PATH_VARS LIB_INSTALL_DIR INCLUDE_INSTALL_DIR BIN_INSTALL_DIR ) ## Generate config Version File for rocm-core write_basic_package_version_file( - ${CMAKE_CURRENT_BINARY_DIR}/${CORE_TARGET}-config-version.cmake + ${BUILD_DIR}/${CORE_TARGET}-config-version.cmake VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" COMPATIBILITY SameMajorVersion) @@ -218,9 +224,9 @@ set ( CPACK_PACKAGE_VERSION_MAJOR ${VERSION_MAJOR} ) set ( CPACK_PACKAGE_VERSION_MINOR ${VERSION_MINOR} ) set ( CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH} ) set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}" ) -set ( CPACK_PACKAGE_CONTACT "ROCm Dev Support " ) +set ( CPACK_PACKAGE_CONTACT "${PKG_MAINTAINER_NM} <${PKG_MAINTAINER_EMAIL}>" ) set ( CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PKG_DESCRIPTION}" ) -set ( CPACK_RESOURCE_FILE_LICENSE "${COPYRIGHT_FILE}" ) +set ( CPACK_RESOURCE_FILE_LICENSE "${LICENSE_FILE}" ) ## packaging variables if ( DEFINED ROCM_LIBPATCH_VERSION ) set ( CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION}.${ROCM_LIBPATCH_VERSION}" ) @@ -237,6 +243,9 @@ set ( CPACK_DEBIAN_CORE_STATIC_PACKAGE_NAME ${CORE_TARGET} ) message ( STATUS "Using CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELEASE}" ) set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) +# Debian specific packaging configuration +configure_debian_pkg( ${CORE_TARGET} ${COMP_TYPE} ${CPACK_PACKAGE_VERSION} ${PKG_MAINTAINER_NM} ${PKG_MAINTAINER_EMAIL} ) + ## RPM package specific variables set ( CPACK_RPM_COMPONENT_INSTALL ON ) set ( CPACK_RPM_CORE_RUNTIME_PACKAGE_NAME "${CORE_TARGET}" ) @@ -245,7 +254,6 @@ set ( CPACK_RPM_CORE_ASAN_PACKAGE_NAME ${CORE_TARGET}-asan ) # STATIC package name - For Now, No change for static package Name from default set ( CPACK_RPM_CORE_STATIC_PACKAGE_NAME ${CORE_TARGET} ) - ## 'dist' breaks manual builds on debian systems due to empty Provides execute_process( COMMAND rpm --eval %{?dist} RESULT_VARIABLE PROC_RESULT @@ -261,27 +269,31 @@ set ( CPACK_RPM_FILE_NAME "RPM-DEFAULT" ) # Debian package specific variables set ( CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS_STRING} ) set ( CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/ROCm/rocm-core" ) +set ( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) set ( CPACK_DEBIAN_CORE_ASAN_PACKAGE_DEPENDS ${CORE_TARGET} ) -set ( CPACK_DEBIAN_CORE_RUNTIME_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) -set ( CPACK_DEBIAN_CORE_STATIC_PACKAGE_CONTROL_EXTRA "${BUILD_DIR}/postinst;${BUILD_DIR}/prerm" ) +set ( CPACK_DEBIAN_CORE_RUNTIME_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" ) +set ( CPACK_DEBIAN_CORE_STATIC_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" ) +set ( CPACK_DEBIAN_PACKAGE_DESCRIPTION "${EXTENDED_PACKAGE_DESCRIPTION}" ) ## RPM package specific variables set ( CPACK_RPM_PACKAGE_REQUIRES ${RPM_DEPENDS_STRING} ) set ( CPACK_RPM_PACKAGE_LICENSE "MIT" ) set ( CPACK_RPM_CORE_ASAN_PACKAGE_REQUIRES ${CORE_TARGET} ) -set ( CPACK_RPM_CORE_RUNTIME_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) -set ( CPACK_RPM_CORE_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) -set ( CPACK_RPM_CORE_STATIC_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/postinst" ) -set ( CPACK_RPM_CORE_STATIC_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_BINARY_DIR}/prerm" ) +set ( CPACK_RPM_CORE_RUNTIME_POST_INSTALL_SCRIPT_FILE "${BUILD_DIR}/postinst" ) +set ( CPACK_RPM_CORE_RUNTIME_POST_UNINSTALL_SCRIPT_FILE "${BUILD_DIR}/prerm" ) +set ( CPACK_RPM_CORE_STATIC_POST_INSTALL_SCRIPT_FILE "${BUILD_DIR}/postinst" ) +set ( CPACK_RPM_CORE_STATIC_POST_UNINSTALL_SCRIPT_FILE "${BUILD_DIR}/prerm" ) +set ( CPACK_RPM_PACKAGE_DESCRIPTION "${EXTENDED_PACKAGE_DESCRIPTION}" ) if ( DEFINED CPACK_PACKAGING_INSTALL_PREFIX ) - set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) -endif ( ) + set ( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION + "${CPACK_PACKAGING_INSTALL_PREFIX} ${CPACK_PACKAGING_INSTALL_PREFIX}/.info" ) +endif() + # Backward compatibility support for deprecated package rocm-clang-ocl # TODO: To be removed after two releases set(CPACK_DEBIAN_RUNTIME_PACKAGE_REPLACES "rocm-clang-ocl") set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONFLICTS "rocm-clang-ocl") - set(CPACK_RPM_RUNTIME_PACKAGE_OBSOLETES "rocm-clang-ocl") ## Include packaging diff --git a/DEBIAN/changelog.in b/DEBIAN/changelog.in new file mode 100644 index 0000000000..95ba9572fb --- /dev/null +++ b/DEBIAN/changelog.in @@ -0,0 +1,5 @@ +@DEB_PACKAGE_NAME@ (@DEB_PACKAGE_VERSION@) stable; urgency=low + + * ROCm Runtime software stack Base Package. + -- @DEB_MAINTAINER_NAME@ <@DEB_MAINTAINER_EMAIL@> @DEB_TIMESTAMP@ + diff --git a/DEBIAN/copyright.in b/DEBIAN/copyright.in new file mode 100644 index 0000000000..e90d34aa20 --- /dev/null +++ b/DEBIAN/copyright.in @@ -0,0 +1,26 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: @DEB_PACKAGE_NAME@ +Upstream-Contact: @DEB_MAINTAINER_NAME@ <@DEB_MAINTAINER_EMAIL@> +Source: https://github.com/ROCm/@DEB_PACKAGE_NAME@ +Files: * +License: @DEB_LICENSE@ +Copyright: @DEB_COPYRIGHT_YEAR@ Advanced Micro Devices, Inc. All rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/utils.cmake b/utils.cmake index f9fb2fd319..42c075b30a 100644 --- a/utils.cmake +++ b/utils.cmake @@ -169,4 +169,85 @@ function( set_variables ) endfunction() +## Configure Copyright File for Debian Package +function( configure_debian_pkg PACKAGE_NAME_T COMPONENT_NAME_T PACKAGE_VERSION_T MAINTAINER_NM_T MAINTAINER_EMAIL_T) + # Check If Debian Platform + find_file (DEBIAN debian_version debconf.conf PATHS /etc) + if(DEBIAN) + set_debian_pkg_cmake_flags( ${PACKAGE_NAME_T} ${PACKAGE_VERSION_T} + ${MAINTAINER_NM_T} ${MAINTAINER_EMAIL_T} ) + # Create debian directory in build tree + file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/DEBIAN") + + # Configure the copyright file + configure_file( + "${CMAKE_SOURCE_DIR}/DEBIAN/copyright.in" + "${CMAKE_BINARY_DIR}/DEBIAN/copyright" + @ONLY + ) + + # Install copyright file + install ( FILES "${CMAKE_BINARY_DIR}/DEBIAN/copyright" + DESTINATION "${CMAKE_INSTALL_DOCDIR}" + COMPONENT ${COMPONENT_NAME_T} ) + + # Configure the changelog file + configure_file( + "${CMAKE_SOURCE_DIR}/DEBIAN/changelog.in" + "${CMAKE_BINARY_DIR}/DEBIAN/changelog.Debian" + @ONLY + ) + + # Install Change Log + find_program ( DEB_GZIP_EXEC gzip ) + if(EXISTS "${CMAKE_BINARY_DIR}/DEBIAN/changelog.Debian" ) + execute_process( + COMMAND ${DEB_GZIP_EXEC} -9 "${CMAKE_BINARY_DIR}/DEBIAN/changelog.Debian" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/DEBIAN" + RESULT_VARIABLE result + OUTPUT_VARIABLE output + ERROR_VARIABLE error + ) + if(NOT ${result} EQUAL 0) + message(FATAL_ERROR "Failed to compress: ${error}") + endif() + install ( FILES "${CMAKE_BINARY_DIR}/DEBIAN/${DEB_CHANGELOG_INSTALL_FILENM}" + DESTINATION ${CMAKE_INSTALL_DOCDIR} + COMPONENT ${COMPONENT_NAME_T}) + endif() + else() + message( STATUS "Ignore Configuring Debian Specific Packaging Configuration" ) + endif() +endfunction() + +# Set variables for changelog and copyright +# For Debian specific Packages +function( set_debian_pkg_cmake_flags DEB_PACKAGE_NAME_T DEB_PACKAGE_VERSION_T DEB_MAINTAINER_NM_T DEB_MAINTAINER_EMAIL_T ) + # Setting configure flags + set( DEB_PACKAGE_NAME "${DEB_PACKAGE_NAME_T}" CACHE STRING "Debian Package Name" ) + set( DEB_PACKAGE_VERSION "${DEB_PACKAGE_VERSION_T}" CACHE STRING "Debian Package Version String" ) + set( DEB_MAINTAINER_NAME "${DEB_MAINTAINER_NM_T}" CACHE STRING "Debian Package Maintainer Name" ) + set( DEB_MAINTAINER_EMAIL "${DEB_MAINTAINER_EMAIL_T}" CACHE STRING "Debian Package Maintainer Email" ) + set( DEB_COPYRIGHT_YEAR "2025" CACHE STRING "Debian Package Copyright Year" ) + set( DEB_LICENSE "MIT" CACHE STRING "Debian Package License Type" ) + set( DEB_CHANGELOG_INSTALL_FILENM "changelog.Debian.gz" CACHE STRING "Debian Package ChangeLog File Name" ) + + # Get TimeStamp + find_program( DEB_DATE_TIMESTAMP_EXEC date ) + set ( DEB_TIMESTAMP_FORMAT_OPTION "-R" ) + execute_process ( + COMMAND ${DEB_DATE_TIMESTAMP_EXEC} ${DEB_TIMESTAMP_FORMAT_OPTION} + OUTPUT_VARIABLE TIMESTAMP_T + ) + set( DEB_TIMESTAMP "${TIMESTAMP_T}" CACHE STRING "Current Time Stamp for Copyright/Changelog" ) + + message(STATUS "DEB_PACKAGE_NAME : ${DEB_PACKAGE_NAME}" ) + message(STATUS "DEB_PACKAGE_VERSION : ${DEB_PACKAGE_VERSION}" ) + message(STATUS "DEB_MAINTAINER_NAME : ${DEB_MAINTAINER_NAME}" ) + message(STATUS "DEB_MAINTAINER_EMAIL : ${DEB_MAINTAINER_EMAIL}" ) + message(STATUS "DEB_COPYRIGHT_YEAR : ${DEB_COPYRIGHT_YEAR}" ) + message(STATUS "DEB_LICENSE : ${DEB_LICENSE}" ) + message(STATUS "DEB_TIMESTAMP : ${DEB_TIMESTAMP}" ) + message(STATUS "DEB_CHANGELOG_INSTALL_FILENM : ${DEB_CHANGELOG_INSTALL_FILENM}" ) +endfunction() From 4ef3bfb450abc2c47e104d760422a04b5fe5e87e Mon Sep 17 00:00:00 2001 From: Ashutosh Mishra Date: Mon, 12 May 2025 11:45:20 +0530 Subject: [PATCH 59/61] Adding condition for static package type SWDEV-532030 : Static builds are failing for mainline and release because COMP_TYPE is empty in case of static builds. This patch fixes the same. Signed-off-by: Ashutosh Mishra --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index d09b094e74..3631e9b23d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,7 +244,11 @@ message ( STATUS "Using CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_DEBIAN_PACKAGE_RELE set ( CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT" ) # Debian specific packaging configuration +if(COMP_TYPE) configure_debian_pkg( ${CORE_TARGET} ${COMP_TYPE} ${CPACK_PACKAGE_VERSION} ${PKG_MAINTAINER_NM} ${PKG_MAINTAINER_EMAIL} ) +elseif(STATIC_COMP_TYPE) +configure_debian_pkg( ${CORE_TARGET} ${STATIC_COMP_TYPE} ${CPACK_PACKAGE_VERSION} ${PKG_MAINTAINER_NM} ${PKG_MAINTAINER_EMAIL} ) +endif() ## RPM package specific variables set ( CPACK_RPM_COMPONENT_INSTALL ON ) From b71510e25fb175ba257fcf8562b2086b6141c51a Mon Sep 17 00:00:00 2001 From: Ashutosh Mishra Date: Mon, 12 May 2025 17:22:02 +0530 Subject: [PATCH 60/61] Restoring the correct installation path SWDEV-532187: The installation was failing because of the same path used in all of the packages. This patch seprates the same. Signed-off-by: Ashutosh Mishra --- CMakeLists.txt | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3631e9b23d..9906ce92d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,9 +37,27 @@ set( CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options ar ## Verbose output. set( CMAKE_VERBOSE_MAKEFILE on ) +include( GNUInstallDirs ) + +if(ENABLE_ASAN_PACKAGING) + # Only libraries required for ASAN Package + set( CPACK_COMPONENTS_ALL CORE_ASAN ) + set( COMP_TYPE "CORE_ASAN" ) + set( PKG_DESCRIPTION "ROCm AddressSanitizer Instrumented Runtime software stack" ) + set( CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DOCDIR}-asan" ) +else() + if(BUILD_SHARED_LIBS) + set( CPACK_COMPONENTS_ALL CORE_RUNTIME ) + set( COMP_TYPE "CORE_RUNTIME" ) + set( PKG_DESCRIPTION "ROCm Runtime software stack" ) + else() + set( CPACK_COMPONENTS_ALL CORE_STATIC ) + set( STATIC_COMP_TYPE "CORE_STATIC" ) + set( PKG_DESCRIPTION "ROCm Static software stack" ) + endif() +endif() include( utils.cmake ) -include( GNUInstallDirs ) #Parse Version message( STATUS "ROCM_VERSION = ${ROCM_VERSION}" ) @@ -101,23 +119,6 @@ set( SO_VERSION_STRING "${SO_MAJOR}.${SO_MINOR}.${ROCM_LIBPATCH_VERSION}" ) set_property( TARGET ${CORE_TARGET} PROPERTY VERSION "${SO_VERSION_STRING}" ) set_property( TARGET ${CORE_TARGET} PROPERTY SOVERSION "${SO_MAJOR}" ) -if(ENABLE_ASAN_PACKAGING) - # Only libraries required for ASAN Package - set( CPACK_COMPONENTS_ALL CORE_ASAN ) - set( COMP_TYPE "CORE_ASAN" ) - set( PKG_DESCRIPTION "ROCm AddressSanitizer Instrumented Runtime software stack" ) -else() - if(BUILD_SHARED_LIBS) - set( CPACK_COMPONENTS_ALL CORE_RUNTIME ) - set( COMP_TYPE "CORE_RUNTIME" ) - set( PKG_DESCRIPTION "ROCm Runtime software stack" ) - else() - set( CPACK_COMPONENTS_ALL CORE_STATIC ) - set( STATIC_COMP_TYPE "CORE_STATIC" ) - set( PKG_DESCRIPTION "ROCm Static software stack" ) - endif() -endif() - #Add the libpatch version if available to the version file if( DEFINED VERSION_POINT ) file ( WRITE "${CMAKE_CURRENT_BINARY_DIR}/version" "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}.${VERSION_POINT}\n" ) @@ -148,9 +149,6 @@ if(BUILD_SHARED_LIBS) install ( FILES ${LICENSE_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt COMPONENT CORE_RUNTIME) - install ( FILES ${LICENSE_FILE} DESTINATION - ${CMAKE_INSTALL_DOCDIR}-asan RENAME LICENSE.txt - COMPONENT CORE_ASAN) else() install ( FILES ${BUILD_DIR}/version DESTINATION .info From 0575284367ebc783e531c0d1de3e59df8475192b Mon Sep 17 00:00:00 2001 From: "Cheruvally, Aravindan" Date: Mon, 12 May 2025 18:18:11 -0400 Subject: [PATCH 61/61] Update License File install for ASAN (#21) UT Fix - Update License File install for ASAN --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9906ce92d4..3277e4c8e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -148,7 +148,7 @@ if(BUILD_SHARED_LIBS) # License file install ( FILES ${LICENSE_FILE} DESTINATION ${CMAKE_INSTALL_DOCDIR} RENAME LICENSE.txt - COMPONENT CORE_RUNTIME) + COMPONENT ${COMP_TYPE}) else() install ( FILES ${BUILD_DIR}/version DESTINATION .info