From 4635c813e07c88836ef5109cd4bb84208ec05fb2 Mon Sep 17 00:00:00 2001 From: "Mark W. Krentel" Date: Mon, 14 Mar 2022 05:30:55 -0500 Subject: [PATCH] hsa-rocr-dev, llvm-amdgpu: change dependency libelf to elf (#29408) * hsa-rocr-dev, llvm-amdgpu: change dependency libelf to elf Change the libelf dependency to the virtual elf for two rocm packages. This allows other packages (hpctoolkit) to combine rocm and dyninst (with elfutils) while still being able to build rocm with libelf when needed, eg darwin. * add comment describing include path for libelf vs elfutils --- .../repos/builtin/packages/hsa-rocr-dev/package.py | 10 ++++++++-- .../repos/builtin/packages/llvm-amdgpu/package.py | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/var/spack/repos/builtin/packages/hsa-rocr-dev/package.py b/var/spack/repos/builtin/packages/hsa-rocr-dev/package.py index 115956502ea..4e39ab274b2 100644 --- a/var/spack/repos/builtin/packages/hsa-rocr-dev/package.py +++ b/var/spack/repos/builtin/packages/hsa-rocr-dev/package.py @@ -4,6 +4,8 @@ # SPDX-License-Identifier: (Apache-2.0 OR MIT) +import os + from spack import * @@ -43,7 +45,7 @@ class HsaRocrDev(CMakePackage): # Note, technically only necessary when='@3.7: +image', but added to all # to work around https://github.com/spack/spack/issues/23951 depends_on('xxd', when='+image', type='build') - depends_on('libelf@0.8:', type='link') + depends_on('elf', type='link') for ver in ['3.5.0', '3.7.0', '3.8.0', '3.9.0', '3.10.0', '4.0.0', '4.1.0', '4.2.0', '4.3.0', '4.3.1', '4.5.0', '4.5.2', 'master']: @@ -61,7 +63,11 @@ class HsaRocrDev(CMakePackage): def cmake_args(self): spec = self.spec - libelf_include = spec['libelf'].prefix.include.libelf + # hsa-rocr-dev wants the directory containing the header files, but + # libelf adds an extra path (include/libelf) compared to elfutils + libelf_include = os.path.dirname( + find_headers('libelf', spec['elf'].prefix.include, recursive=True)[0]) + args = [ self.define('LIBELF_INCLUDE_DIRS', libelf_include), self.define_from_variant('BUILD_SHARED_LIBS', 'shared') diff --git a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py index ab329bd23b5..7da6846adc6 100644 --- a/var/spack/repos/builtin/packages/llvm-amdgpu/package.py +++ b/var/spack/repos/builtin/packages/llvm-amdgpu/package.py @@ -63,7 +63,7 @@ class LlvmAmdgpu(CMakePackage): # openmp dependencies depends_on("perl-data-dumper", type=("build"), when='+openmp') depends_on("hwloc", when='+openmp') - depends_on('libelf', type='link', when='+openmp') + depends_on('elf', type='link', when='+openmp') # Will likely only be fixed in LLVM 12 upstream patch('fix-system-zlib-ncurses.patch', when='@3.5.0:3.8.0')