Diff hip-5.1.3-r4 with a hip-5.3.3-r3

/usr/portage/dev-util/hip/hip-5.3.3-r3.ebuild 2023-10-09 14:52:30.972368387 +0300
3 3

  
4 4
EAPI=8
5 5

  
6
PYTHON_COMPAT=( python3_{9..11} )
7 6
DOCS_BUILDER="doxygen"
8 7
DOCS_DEPEND="media-gfx/graphviz"
9 8

  
10
inherit cmake docs llvm prefix python-any-r1
9
inherit cmake docs llvm prefix
11 10

  
12 11
LLVM_MAX_SLOT=15
13 12

  
......
16 15
SRC_URI="https://github.com/ROCm-Developer-Tools/hipamd/archive/rocm-${PV}.tar.gz -> rocm-hipamd-${PV}.tar.gz
17 16
	https://github.com/ROCm-Developer-Tools/HIP/archive/rocm-${PV}.tar.gz -> rocm-hip-${PV}.tar.gz
18 17
	https://github.com/ROCm-Developer-Tools/ROCclr/archive/rocm-${PV}.tar.gz -> rocclr-${PV}.tar.gz
19
	https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/archive/rocm-${PV}.tar.gz -> rocm-opencl-runtime-${PV}.tar.gz
20
	profile? ( https://github.com/ROCm-Developer-Tools/roctracer/archive/refs/tags/rocm-${PV}.tar.gz -> rocm-tracer-${PV}.tar.gz
21
			https://github.com/ROCm-Developer-Tools/hipamd/files/8991181/hip_prof_str_diff.gz -> ${P}-update-header.patch.gz
22
	)"
18
	https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime/archive/rocm-${PV}.tar.gz -> rocm-opencl-runtime-${PV}.tar.gz"
23 19

  
24 20
KEYWORDS="~amd64"
25 21
LICENSE="MIT"
26 22
SLOT="0/$(ver_cut 1-2)"
27 23

  
28
IUSE="debug profile"
24
IUSE="debug"
29 25

  
30 26
DEPEND="
31 27
	>=dev-util/rocminfo-5
......
37 33
	dev-perl/URI-Encode
38 34
	sys-devel/clang-runtime:=
39 35
	>=dev-libs/roct-thunk-interface-5"
40
BDEPEND="profile? ( $(python_gen_any_dep '
41
	dev-python/CppHeaderParser[${PYTHON_USEDEP}]
42
	') )
43
"
44 36

  
45 37
PATCHES=(
46 38
	"${FILESDIR}/${PN}-5.0.1-DisableTest.patch"
47
	"${FILESDIR}/${PN}-4.2.0-config-cmake-in.patch"
48 39
	"${FILESDIR}/${PN}-5.0.1-hip_vector_types.patch"
49
	"${FILESDIR}/${PN}-4.2.0-cancel-hcc-header-removal.patch"
50 40
	"${FILESDIR}/${PN}-5.0.2-set-build-id.patch"
51
	"${FILESDIR}/${PN}-5.1.3-fix-hip_prof_gen.patch"
52
	"${FILESDIR}/${PN}-5.1.3-correct-sample-install-location.patch"
53
	"${FILESDIR}/${PN}-5.1.3-remove-cmake-doxygen-commands.patch"
54
	"${FILESDIR}/0001-SWDEV-316128-HIP-surface-API-support.patch"
55
	"${FILESDIR}/${PN}-5.1.3-llvm-15-noinline-keyword.patch"
41
	"${FILESDIR}/${PN}-5.3.3-remove-cmake-doxygen-commands.patch"
42
	"${FILESDIR}/${PN}-5.3.3-disable-Werror.patch"
43
	"${FILESDIR}/0001-SWDEV-352878-LLVM-pkg-search-directly-using-find_dep.patch"
56 44
)
57 45

  
58
python_check_deps() {
59
	if use profile; then
60
		python_has_version "dev-python/CppHeaderParser[${PYTHON_USEDEP}]"
61
	fi
62
}
63

  
64 46
S="${WORKDIR}/hipamd-rocm-${PV}"
65 47
HIP_S="${WORKDIR}"/HIP-rocm-${PV}
66 48
OCL_S="${WORKDIR}"/ROCm-OpenCL-Runtime-rocm-${PV}
......
69 51
DOCS_DIR="${HIP_S}"/docs/doxygen-input
70 52
DOCS_CONFIG_NAME=doxy.cfg
71 53

  
54
pkg_setup() {
55
	# Ignore QA FLAGS check for library compiled from assembly sources
56
	QA_FLAGS_IGNORED="/usr/$(get_libdir)/libhiprtc-builtins.so.$(ver_cut 1-2)"
57
}
58

  
72 59
src_prepare() {
73 60
	cmake_src_prepare
74
	use profile && eapply "${WORKDIR}/${P}-update-header.patch"
75 61

  
76 62
	eapply_user
77 63

  
78 64
	# Use Gentoo slot number, otherwise git hash is attempted in vain.
79 65
	sed -e "/set (HIP_LIB_VERSION_STRING/cset (HIP_LIB_VERSION_STRING ${SLOT#*/})" -i CMakeLists.txt || die
80 66

  
81
	# disable PCH, because it results in a build error in ROCm 4.0.0
82
	sed -e "s:option(__HIP_ENABLE_PCH:#option(__HIP_ENABLE_PCH:" -i CMakeLists.txt || die
83

  
84 67
	# correctly find HIP_CLANG_INCLUDE_PATH using cmake
85 68
	local LLVM_PREFIX="$(get_llvm_prefix "${LLVM_MAX_SLOT}")"
86
	local CLANG_RESOURCE_DIR=$("${LLVM_PREFIX}/bin/clang" -print-resource-dir)
87 69
	sed -e "/set(HIP_CLANG_ROOT/s:\"\${ROCM_PATH}/llvm\":${LLVM_PREFIX}:" -i hip-config.cmake.in || die
88 70

  
89 71
	# correct libs and cmake install dir
90
	sed -e "/LIB_INSTALL_DIR/s:PREFIX}/lib:PREFIX}/$(get_libdir):" \
91
		-e "/\${HIP_COMMON_DIR}/s:cmake DESTINATION .):cmake/ DESTINATION share/cmake/Modules):" -i CMakeLists.txt || die
92
	sed -e "/LIBRARY DESTINATION/s:lib:$(get_libdir):" -i src/CMakeLists.txt || die
72
	sed -e "/\${HIP_COMMON_DIR}/s:cmake DESTINATION .):cmake/ DESTINATION share/cmake/Modules):" -i CMakeLists.txt || die
93 73

  
94 74
	sed -e "/\.hip/d" \
95
		-e "s,DESTINATION lib,DESTINATION $(get_libdir),g" \
96
		-e "/cmake DESTINATION/d" \
97 75
		-e "/CPACK_RESOURCE_FILE_LICENSE/d" -i packaging/CMakeLists.txt || die
98 76

  
99 77
	pushd ${HIP_S} || die
100
	eapply "${FILESDIR}/${PN}-5.1.3-clang-include-path.patch"
101 78
	eapply "${FILESDIR}/${PN}-5.1.3-rocm-path.patch"
102
	eapply "${FILESDIR}/${PN}-5.0.2-correct-ldflag.patch"
103 79
	eapply "${FILESDIR}/${PN}-5.1.3-fno-stack-protector.patch"
80
	eapply "${FILESDIR}/${PN}-5.3.3-correct-ldflag.patch"
81
	eapply "${FILESDIR}/0001-SWDEV-344620-hipcc-fails-to-parse-version-of-clang-i.patch"
82
	eapply "${FILESDIR}/0002-SWDEV-355608-Remove-clang-include-path-2996.patch"
83
	eapply "${FILESDIR}/0003-SWDEV-352878-Removed-relative-path-based-CLANG-inclu.patch"
84
	eapply "${FILESDIR}/${PN}-5.4.3-fix-HIP_CLANG_PATH-detection.patch"
104 85
	# Setting HSA_PATH to "/usr" results in setting "-isystem /usr/include"
105 86
	# which makes "stdlib.h" not found when using "#include_next" in header files;
106 87
	sed -e "/FLAGS .= \" -isystem \$HSA_PATH/d" \
107 88
		-e "/HIP.*FLAGS.*isystem.*HIP_INCLUDE_PATH/d" \
108 89
		-e "s:\$ENV{'DEVICE_LIB_PATH'}:'${EPREFIX}/usr/lib/amdgcn/bitcode':" \
109 90
		-e "s:\$ENV{'HIP_LIB_PATH'}:'${EPREFIX}/usr/$(get_libdir)':" \
110
		-e "/rpath/s,--rpath=[^ ]*,," \
111
		-e "s,\$HIP_CLANG_PATH/../lib/clang/\$HIP_CLANG_VERSION/,${CLANG_RESOURCE_DIR}/,g" \
112
		-i bin/hipcc.pl || die
91
		-e "/rpath/s,--rpath=[^ ]*,," -i bin/hipcc.pl || die
113 92

  
114 93
	# change --hip-device-lib-path to "/usr/lib/amdgcn/bitcode", must align with "dev-libs/rocm-device-libs"
115 94
	sed -e "s:\${AMD_DEVICE_LIBS_PREFIX}/lib:${EPREFIX}/usr/lib/amdgcn/bitcode:" \
......
119 98
	hprefixify $(grep -rl --exclude-dir=build/ --exclude="hip-config.cmake.in" "/usr" "${S}")
120 99
	hprefixify $(grep -rl --exclude-dir=build/ --exclude="hipcc.pl" "/usr" "${HIP_S}")
121 100

  
122
	cp "$(prefixify_ro "${FILESDIR}"/hipvars-5.1.3.pm)" bin/hipvars.pm || die "failed to replace hipvars.pm"
101
	cp "$(prefixify_ro "${FILESDIR}"/hipvars-5.3.3.pm)" bin/hipvars.pm || die "failed to replace hipvars.pm"
123 102
	sed -e "s,@HIP_BASE_VERSION_MAJOR@,$(ver_cut 1)," -e "s,@HIP_BASE_VERSION_MINOR@,$(ver_cut 2)," \
124 103
		-e "s,@HIP_VERSION_PATCH@,$(ver_cut 3)," \
125
		-e "s,@CLANG_INCLUDE_PATH@,${CLANG_RESOURCE_DIR}/include," \
126 104
		-e "s,@CLANG_PATH@,${LLVM_PREFIX}/bin," -i bin/hipvars.pm || die
127

  
128
	sed -e "/HIP_CLANG_INCLUDE_SEARCH_PATHS/s,\${_IMPORT_PREFIX}.*/include,${CLANG_RESOURCE_DIR}/include," -i hip-lang-config.cmake.in || die
129 105
	popd || die
130
	sed -e "/HIP_CLANG_INCLUDE_SEARCH_PATHS/s,\${HIP_CLANG_ROOT}.*/include,${CLANG_RESOURCE_DIR}/include," -i hip-config.cmake.in || die
131 106

  
132 107
	pushd ${CLR_S} || die
133
	eapply "${FILESDIR}/rocclr-5.3.3-fix-include.patch"
108
	eapply "${FILESDIR}/rocclr-${PV}-fix-include.patch"
109
	eapply "${FILESDIR}/rocclr-5.3.3-gcc13.patch"
134 110
}
135 111

  
136 112
src_configure() {
......
150 126
		-DHIP_PLATFORM=amd
151 127
		-DHIP_COMPILER=clang
152 128
		-DROCM_PATH="${EPREFIX}/usr"
153
		-DUSE_PROF_API=$(usex profile 1 0)
129
		-DUSE_PROF_API=0
130
		-DFILE_REORG_BACKWARD_COMPATIBILITY=OFF
154 131
		-DROCCLR_PATH=${CLR_S}
155 132
		-DHIP_COMMON_DIR=${HIP_S}
156 133
		-DAMD_OPENCL_PATH=${OCL_S}
157 134
	)
158 135

  
159
	use profile && mycmakeargs+=( -DPROF_API_HEADER_PATH="${RTC_S}"/inc/ext )
160

  
161 136
	cmake_src_configure
162 137
}
163 138

  
......
173 148
	rm "${ED}/usr/include/hip/hcc_detail" || die
174 149

  
175 150
	# Don't install .hipInfo and .hipVersion to bin/lib
176
	rm "${ED}/usr/lib/.hipInfo" "${ED}/usr/bin/.hipVersion" || die
151
	rm "${ED}/usr/bin/.hipVersion" || die
177 152
}
Thank you!