commit:     7dac65ea4155fa1f5a21bdd46dd9793d21911e0e
Author:     Yiyang Wu <xgreenlandforwyy <AT> gmail <DOT> com>
AuthorDate: Mon Jun 27 13:12:30 2022 +0000
Commit:     Benda XU <heroxbd <AT> gentoo <DOT> org>
CommitDate: Fri Jul  8 17:40:06 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=7dac65ea

dev-util/hip: add missing BDEPEND for USE=profile

Also fix ld warnings by patch out unecessary ldflag added by hipcc.pl

Closes: https://github.com/gentoo/gentoo/pull/26090
Closes: https://bugs.gentoo.org/843263
Reference: https://github.com/justxi/rocm/issues/8#issuecomment-1166193820
Signed-off-by: Yiyang Wu <xgreenlandforwyy <AT> gmail.com>
Signed-off-by: Benda Xu <heroxbd <AT> gentoo.org>

 dev-util/hip/files/hip-5.0.2-correct-ldflag.patch | 18 ++++++++++++++++++
 dev-util/hip/hip-5.0.2-r2.ebuild                  | 17 ++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

diff --git a/dev-util/hip/files/hip-5.0.2-correct-ldflag.patch 
b/dev-util/hip/files/hip-5.0.2-correct-ldflag.patch
new file mode 100644
index 000000000000..81d1bc3b8552
--- /dev/null
+++ b/dev-util/hip/files/hip-5.0.2-correct-ldflag.patch
@@ -0,0 +1,18 @@
+This removes ldflag -L"/usr/lib" and -Wl,-rpath=/usr/lib:/usr/lib which
+causes `ld: skipping incompatible /usr/lib/libm.so when searching for -lm`
+Reference: https://github.com/justxi/rocm/issues/8#issuecomment-1166193820
+===================================================================
+--- HIP-rocm-5.1.3.orig/bin/hipcc.pl
++++ HIP-rocm-5.1.3/bin/hipcc.pl
+@@ -703,9 +703,9 @@ if ($HIP_PLATFORM eq "amd") {
+ 
+     if (not $isWindows  and not $compileOnly) {
+       if ($linkType eq 0) {
+-        $toolArgs = " -L$HIP_LIB_PATH -lamdhip64 -L$ROCM_PATH/lib 
-lhsa-runtime64 -ldl -lnuma " . ${toolArgs};
++        $toolArgs = " -lamdhip64 -lhsa-runtime64 -ldl -lnuma " . ${toolArgs};
+       } else {
+-        $toolArgs = " -Wl,--enable-new-dtags 
-Wl,-rpath=$HIP_LIB_PATH:$ROCM_PATH/lib -lamdhip64 " . ${toolArgs};
++        $toolArgs = " -Wl,--enable-new-dtags -lamdhip64 " . ${toolArgs};
+       }
+       # To support __fp16 and _Float16, explicitly link with compiler-rt
+       
$HIP_CLANG_BUILTIN_LIB="/opt/gentoo/opt/gentoo/usr/lib/llvm/14/bin/../../../../lib/clang/14.0.6/lib/$HIP_CLANG_TARGET/libclang_rt.builtins.a";

diff --git a/dev-util/hip/hip-5.0.2-r2.ebuild b/dev-util/hip/hip-5.0.2-r2.ebuild
index 223386227084..fd069acfe4b4 100644
--- a/dev-util/hip/hip-5.0.2-r2.ebuild
+++ b/dev-util/hip/hip-5.0.2-r2.ebuild
@@ -2,7 +2,10 @@
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
-inherit cmake prefix
+
+PYTHON_COMPAT=( python3_{8..11} )
+
+inherit cmake prefix python-any-r1
 
 DESCRIPTION="C++ Heterogeneous-Compute Interface for Portability"
 HOMEPAGE="https://github.com/ROCm-Developer-Tools/hipamd";
@@ -29,6 +32,10 @@ DEPEND="
 RDEPEND="${DEPEND}
        dev-perl/URI-Encode
        dev-libs/roct-thunk-interface:${SLOT}"
+BDEPEND="profile? ( $(python_gen_any_dep '
+       dev-python/CppHeaderParser[${PYTHON_USEDEP}]
+       ') )
+"
 
 PATCHES=(
        "${FILESDIR}/${PN}-5.0.1-DisableTest.patch"
@@ -38,6 +45,12 @@ PATCHES=(
        "${FILESDIR}/${PN}-5.0.2-set-build-id.patch"
 )
 
+python_check_deps() {
+       if use profile; then
+               has_version "dev-python/CppHeaderParser[${PYTHON_USEDEP}]"
+       fi
+}
+
 S="${WORKDIR}/hipamd-rocm-${PV}"
 HIP_S="${WORKDIR}"/HIP-rocm-${PV}
 OCL_S="${WORKDIR}"/ROCm-OpenCL-Runtime-rocm-${PV}
@@ -65,11 +78,13 @@ src_prepare() {
        sed -e "/LIBRARY DESTINATION/s:lib:$(get_libdir):" -i 
src/CMakeLists.txt || die
 
        cd ${HIP_S} || die
+       eapply "${FILESDIR}/${PN}-5.0.2-correct-ldflag.patch"
        # Setting HSA_PATH to "/usr" results in setting "-isystem /usr/include"
        # which makes "stdlib.h" not found when using "#include_next" in header 
files;
        sed -e "/FLAGS .= \" -isystem \$HSA_PATH/d" \
                -e "/HIP.*FLAGS.*isystem.*HIP_INCLUDE_PATH/d" \
                -e "s:\$ENV{'DEVICE_LIB_PATH'}:'/usr/lib/amdgcn/bitcode':" \
+               -e "s:\$ENV{'HIP_LIB_PATH'}:'/usr/$(get_libdir)':" \
                -e "/rpath/s,--rpath=[^ ]*,," \
                -i bin/hipcc.pl || die
 

Reply via email to