Repository: spack/spack

Issue:
Installation issue: 
@TomTheBear 

Spack installs the shared library `libhwloc.so` under `lib64` but the `likwid` spec searches it under `lib`. I am aware of similar issues were already reported but have now been closed and there does not seem to be a solution. Could a quick fix consist in editing the likwid spack recipe and changing the path to the lib directory to lib64..?

### Steps to reproduce the issue

```console
$ spack spec -I likwid
Input spec
--------------------------------
 -   likwid

Concretized
--------------------------------
 -   likwid@5.2.2%gcc@11.3.0+cuda+fortran build_system=generic patches=af4ce27 arch=linux-rhel8-icelake
[^]      ^cuda@11.8.89%gcc@11.3.0~allow-unsupported-compilers~dev build_system=generic arch=linux-rhel8-icelake
[^]      ^hwloc@2.2.0%gcc@11.3.0~cairo+cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl+pci~rocm build_system=autotools cuda_arch=80 libs=shared,static arch=linux-rhel8-icelake
[+]      ^lua@5.4.4%gcc@11.3.0~pcfile+shared build_system=makefile fetcher=curl arch=linux-rhel8-icelake
[^]          ^curl@7.85.0%gcc@11.3.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2~nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-rhel8-icelake
[^]              ^openssl@1.1.1k%gcc@11.3.0~docs~shared build_system=generic certs=mozilla arch=linux-rhel8-icelake
[^]              ^pkgconf@1.8.0%gcc@11.3.0 build_system=autotools arch=linux-rhel8-icelake
[^]              ^zlib@1.2.13%gcc@11.3.0+optimize+pic+shared build_system=makefile arch=linux-rhel8-icelake
[^]          ^ncurses@6.3%gcc@11.3.0~symlinks+termlib abi=none build_system=autotools arch=linux-rhel8-icelake
[^]          ^readline@8.1.2%gcc@11.3.0 build_system=autotools arch=linux-rhel8-icelake
[+]          ^unzip@6.0%gcc@11.3.0 build_system=makefile arch=linux-rhel8-icelake
[^]      ^perl@5.36.0%gcc@11.3.0+cpanm+shared+threads build_system=generic arch=linux-rhel8-icelake
```


### Error message

<details><summary>Error message</summary>

<pre>
...
==> likwid: Executing phase: 'install'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j16'

3 errors found in build log:
     113    ===>  COMPILE  GCC/tree.o
     114    ===>  COMPILE  GCC/frequency_cpu.o
     115    ===>  COMPILE  GCC/loadData.o
     116    ===>  EXTERNAL HWLOC
     117    ===>  EXTERNAL LUA
     118    ===>  CREATE SHARED LIB  liblikwid.so
  >> 119    /usr/bin/ld: cannot find /usr/lib/libhwloc.so: No such file or directory
  >> 120    collect2: error: ld returned 1 exit status
  >> 121    make: *** [Makefile:234: liblikwid.so] Error 1
</pre></details>


### Information on your system

* **Spack:** 0.19.1 (ee04c0fc60d990da8f7d2970a41d6653866528f9)
* **Python:** 3.6.8
* **Platform:** linux-rhel8-icelake
* **Concretizer:** clingo

### Additional information

<details><summary>cat spack-build-out.txt
</summary>

<pre>
==> likwid: Executing phase: 'install'
==> [2023-08-10-17:34:33.491318] FILTER FILE: perl/feedGnuplot [replacing "^#!/usr/bin/perl"]
==> [2023-08-10-17:34:33.493969] FILTER FILE: filters/README [replacing "^#!/usr/bin/perl"]
==> [2023-08-10-17:34:33.494322] FILTER FILE: filters/json [replacing "^#!/usr/bin/perl"]
==> [2023-08-10-17:34:33.494892] FILTER FILE: filters/template [replacing "^#!/usr/bin/perl"]
==> [2023-08-10-17:34:33.495210] FILTER FILE: filters/xml [replacing "^#!/usr/bin/perl"]
==> [2023-08-10-17:34:33.502144] FILTER FILE: config.mk [replacing "^COMPILER .*"]
==> [2023-08-10-17:34:33.502867] FILTER FILE: config.mk [replacing "^PREFIX .*"]
==> [2023-08-10-17:34:33.503429] FILTER FILE: config.mk [replacing "^ACCESSMODE .*"]
==> [2023-08-10-17:34:33.503979] FILTER FILE: config.mk [replacing "^BUILDFREQ .*"]
==> [2023-08-10-17:34:33.504542] FILTER FILE: config.mk [replacing "^BUILDDAEMON .*"]
==> [2023-08-10-17:34:33.505351] FILTER FILE: config.mk [replacing "^FORTRAN_INTERFACE .*"]
==> [2023-08-10-17:34:33.505960] FILTER FILE: make/include_GCC.mk [replacing "ifort"]
==> [2023-08-10-17:34:33.506378] FILTER FILE: make/include_GCC.mk [replacing "-module"]
==> [2023-08-10-17:34:33.506870] FILTER FILE: config.mk [replacing "^NVIDIA_INTERFACE.*"]
==> [2023-08-10-17:34:33.507424] FILTER FILE: config.mk [replacing "^BUILDAPPDAEMON.*"]
==> [2023-08-10-17:34:33.508123] FILTER FILE: config.mk [replacing "^CUDAINCLUDE.*"]
==> [2023-08-10-17:34:33.740949] FILTER FILE: config.mk [replacing "^CUPTIINCLUDE.*"]
==> [2023-08-10-17:34:33.746829] FILTER FILE: config.mk [replacing "^#LUA_INCLUDE_DIR.*"]
==> [2023-08-10-17:34:33.747643] FILTER FILE: config.mk [replacing "^#LUA_LIB_DIR.*"]
==> [2023-08-10-17:34:33.748260] FILTER FILE: config.mk [replacing "^#LUA_LIB_NAME.*"]
==> [2023-08-10-17:34:33.748938] FILTER FILE: config.mk [replacing "^#LUA_BIN.*"]
==> [2023-08-10-17:34:33.752508] FILTER FILE: config.mk [replacing "^#HWLOC_INCLUDE_DIR.*"]
==> [2023-08-10-17:34:33.753267] FILTER FILE: config.mk [replacing "^#HWLOC_LIB_DIR.*"]
==> [2023-08-10-17:34:33.753880] FILTER FILE: config.mk [replacing "^#HWLOC_LIB_NAME.*"]
==> [2023-08-10-17:34:33.754911] 'make' '-j16'
Info: Compiling for perf_event interface. Measurements of thermal information is disabled
===>  GENERATE HEADER GCC/perfmon_zen_events.h
===>  GENERATE HEADER GCC/perfmon_nehalemEX_events.h
===>  GENERATE HEADER GCC/perfmon_skylake_events.h
===>  GENERATE HEADER GCC/perfmon_a15_events.h
===>  GENERATE HEADER GCC/perfmon_neon1_events.h
===>  GENERATE HEADER GCC/perfmon_haswell_events.h
===>  GENERATE HEADER GCC/perfmon_sandybridge_events.h
===>  GENERATE HEADER GCC/perfmon_core2_events.h
===>  GENERATE HEADER GCC/perfmon_sandybridgeEP_events.h
===>  GENERATE HEADER GCC/perfmon_p6_events.h
===>  GENERATE HEADER GCC/perfmon_zen2_events.h
===>  GENERATE HEADER GCC/perfmon_phi_events.h
===>  GENERATE HEADER GCC/perfmon_a64fx_events.h
===>  GENERATE HEADER GCC/perfmon_kabini_events.h
===>  GENERATE HEADER GCC/perfmon_zen3_events.h
===>  GENERATE HEADER GCC/perfmon_tigerlake_events.h
===>  GENERATE HEADER GCC/perfmon_power8_events.h
===>  GENERATE HEADER GCC/perfmon_icelake_events.h
===>  GENERATE HEADER GCC/perfmon_cavtx2_events.h
===>  GENERATE HEADER GCC/perfmon_goldmont_events.h
===>  GENERATE HEADER GCC/perfmon_k8_events.h
===>  GENERATE HEADER GCC/perfmon_ivybridge_events.h
===>  GENERATE HEADER GCC/perfmon_westmere_events.h
===>  GENERATE HEADER GCC/perfmon_nehalem_events.h
===>  GENERATE HEADER GCC/perfmon_silvermont_events.h
===>  GENERATE HEADER GCC/perfmon_k10_events.h
===>  GENERATE HEADER GCC/perfmon_ivybridgeEP_events.h
===>  GENERATE HEADER GCC/perfmon_knl_events.h
===>  GENERATE HEADER GCC/perfmon_haswellEP_events.h
===>  GENERATE HEADER GCC/perfmon_broadwellEP_events.h
===>  GENERATE HEADER GCC/perfmon_a57_events.h
===>  GENERATE HEADER GCC/perfmon_broadwelld_events.h
===>  GENERATE HEADER GCC/perfmon_cascadelakeX_events.h
===>  GENERATE HEADER GCC/perfmon_icelakeX_events.h
===>  GENERATE HEADER GCC/perfmon_skylakeX_events.h
===>  GENERATE HEADER GCC/perfmon_broadwell_events.h
===>  GENERATE HEADER GCC/perfmon_westmereEX_events.h
===>  GENERATE HEADER GCC/perfmon_pm_events.h
===>  GENERATE HEADER GCC/perfmon_power9_events.h
===>  GENERATE HEADER GCC/perfmon_interlagos_events.h
===>  GENERATE HEADER GCC/perfmon_atom_events.h
===>  COMPILE  GCC/access_x86.o
===>  COMPILE  GCC/calculator.o
===>  COMPILE  GCC/voltage.o
===>  COMPILE  GCC/access_x86_rdpmc.o
===>  COMPILE  GCC/access_x86_pci.o
===>  COMPILE  GCC/frequency_uncore.o
===>  COMPILE  GCC/numa.o
===>  COMPILE  GCC/pci_proc.o
===>  COMPILE  GCC/numa_proc.o
===>  COMPILE  GCC/perfmon.o
===>  COMPILE  GCC/numa_hwloc.o
===>  COMPILE  GCC/cpustring.o
===>  COMPILE  GCC/topology_proc.o
===>  COMPILE  GCC/perfgroup.o
===>  COMPILE  GCC/hashTable.o
===>  COMPILE  GCC/power.o
===>  COMPILE  GCC/nvmon.o
===>  COMPILE  GCC/luawid.o
===>  COMPILE  GCC/cpuFeatures.o
===>  COMPILE  GCC/pci_hwloc.o
===>  COMPILE  GCC/numa_virtual.o
===>  COMPILE  GCC/access_x86_msr.o
===>  COMPILE  GCC/topology.o
===>  COMPILE  GCC/thermal.o
===>  COMPILE  GCC/memsweep.o
===>  COMPILE  GCC/topology_hwloc.o
===>  COMPILE  GCC/bstrlib_helper.o
===>  COMPILE  GCC/bitUtil.o
===>  COMPILE  GCC/ghash.o
===>  COMPILE  GCC/topology_cpuid.o
===>  COMPILE  GCC/access_x86_clientmem.o
===>  COMPILE  GCC/configuration.o
===>  COMPILE  GCC/topology_gpu.o
===>  COMPILE  GCC/libnvctr.o
===>  COMPILE  GCC/affinity.o
===>  COMPILE  GCC/libperfctr.o
===>  COMPILE  GCC/access_x86_mmio.o
===>  COMPILE  GCC/timer.o
===>  COMPILE  GCC/calculator_stack.o
===>  COMPILE  GCC/access.o
===>  COMPILE  GCC/map.o
===>  COMPILE  GCC/access_client.o
===>  COMPILE  GCC/bstrlib.o
===>  COMPILE  GCC/likwid_f90_interface.o
===>  COMPILE  GCC/tree.o
===>  COMPILE  GCC/frequency_cpu.o
===>  COMPILE  GCC/loadData.o
===>  EXTERNAL HWLOC
===>  EXTERNAL LUA
===>  CREATE SHARED LIB  liblikwid.so
/usr/bin/ld: cannot find /usr/lib/libhwloc.so: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:234: liblikwid.so] Error 1
</pre></details>

<details><summary>cat spack-build-env.txt</summary>

<pre>
ACLOCAL_PATH=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/share/aclocal; export ACLOCAL_PATH
function BASH_FUNC__module_raw%%() {  eval "$(/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/tcl-8.6.12-rdtv2pt4tnckxsgwtowik3sbexmxolve/bin/tclsh '/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/environment-modules-5.2.0-rz47odw4phlhzhhbz7b65nv5s5othgmi/libexec/modulecmd.tcl' bash "$@")";
 _mlstatus=$?;
 return $_mlstatus
}; export -f BASH_FUNC__module_raw%%
function BASH_FUNC__spack_shell_wrapper%%() {  for var in LD_LIBRARY_PATH DYLD_LIBRARY_PATH DYLD_FALLBACK_LIBRARY_PATH;
 do
 eval "if [ -n \"\${${var}-}\" ]; then export SPACK_$var=\${${var}}; fi";
 done;
 if [ -n "${ZSH_VERSION:-}" ]; then
 emulate -L sh;
 fi;
 _sp_flags="";
 while [ ! -z ${1+x} ] && [ "${1#-}" != "${1}" ]; do
 _sp_flags="$_sp_flags $1";
 shift;
 done;
 if [ -n "$_sp_flags" ] && [ "${_sp_flags#*h}" != "${_sp_flags}" ] || [ "${_sp_flags#*V}" != "${_sp_flags}" ]; then
 command spack $_sp_flags "$@";
 return;
 fi;
 _sp_subcommand="";
 if [ ! -z ${1+x} ]; then
 _sp_subcommand="$1";
 shift;
 fi;
 case $_sp_subcommand in
 "cd")
 _sp_arg="";
 if [ -n "$1" ]; then
 _sp_arg="$1";
 shift;
 fi;
 if [ "$_sp_arg" = "-h" ] || [ "$_sp_arg" = "--help" ]; then
 command spack cd -h;
 else
 LOC="$(spack location $_sp_arg "$@")";
 if [ -d "$LOC" ]; then
 cd "$LOC";
 else
 return 1;
 fi;
 fi;
 return
 ;;
 "env")
 _sp_arg="";
 if [ -n "$1" ]; then
 _sp_arg="$1";
 shift;
 fi;
 if [ "$_sp_arg" = "-h" ] || [ "$_sp_arg" = "--help" ]; then
 command spack env -h;
 else
 case $_sp_arg in
 activate)
 _a=" $@";
 if [ -z ${1+x} ] || [ "${_a#* --sh}" != "$_a" ] || [ "${_a#* --csh}" != "$_a" ] || [ "${_a#* -h}" != "$_a" ] || [ "${_a#* --help}" != "$_a" ]; then
 command spack env activate "$@";
 else
 stdout="$(command spack $_sp_flags env activate --sh "$@")" || return;
 eval "$stdout";
 fi
 ;;
 deactivate)
 _a=" $@";
 if [ "${_a#* --sh}" != "$_a" ] || [ "${_a#* --csh}" != "$_a" ]; then
 command spack env deactivate "$@";
 else
 if [ -n "$*" ]; then
 command spack env deactivate -h;
 else
 stdout="$(command spack $_sp_flags env deactivate --sh)" || return;
 eval "$stdout";
 fi;
 fi
 ;;
 *)
 command spack env $_sp_arg "$@"
 ;;
 esac;
 fi;
 return
 ;;
 "load" | "unload")
 _a=" $@";
 if [ "${_a#* --sh}" != "$_a" ] || [ "${_a#* --csh}" != "$_a" ] || [ "${_a#* -h}" != "$_a" ] || [ "${_a#* --list}" != "$_a" ] || [ "${_a#* --help}" != "$_a" ]; then
 command spack $_sp_flags $_sp_subcommand "$@";
 else
 stdout="$(command spack $_sp_flags $_sp_subcommand --sh "$@")" || return;
 eval "$stdout";
 fi
 ;;
 *)
 command spack $_sp_flags $_sp_subcommand "$@"
 ;;
 esac
}; export -f BASH_FUNC__spack_shell_wrapper%%
function BASH_FUNC_ml%%() {  module ml "$@"
}; export -f BASH_FUNC_ml%%
function BASH_FUNC_module%%() {  local _mlredir=1;
 if [ -n "${MODULES_REDIRECT_OUTPUT+x}" ]; then
 if [ "$MODULES_REDIRECT_OUTPUT" = '0' ]; then
 _mlredir=0;
 else
 if [ "$MODULES_REDIRECT_OUTPUT" = '1' ]; then
 _mlredir=1;
 fi;
 fi;
 fi;
 case " $@ " in
 *' --no-redirect '*)
 _mlredir=0
 ;;
 *' --redirect '*)
 _mlredir=1
 ;;
 esac;
 if [ $_mlredir -eq 0 ]; then
 _module_raw "$@";
 else
 _module_raw "$@" 2>&1;
 fi
}; export -f BASH_FUNC_module%%
function BASH_FUNC_spack%%() {  : this is a shell function from: /leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/share/spack/setup-env.sh;
 : the real spack script is here: /leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/bin/spack;
 _spack_shell_wrapper "$@";
 return $?
}; export -f BASH_FUNC_spack%%
function BASH_FUNC_which%%() {  ( alias;
 eval ${which_declare} ) | /usr/bin/which --tty-only --read-alias --read-functions --show-tilde --show-dot $@
}; export -f BASH_FUNC_which%%
BA_MPM_PROFILE=base; export BA_MPM_PROFILE
CC=/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env/gcc/gcc; export CC
CINECA_SCRATCH=/leonardo_scratch/large/userinternal/mredenti; export CINECA_SCRATCH
CMAKE_PREFIX_PATH=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/readline-8.1.2-mjpt32g56ntqui5wvtshebb2mdlpyt3e:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/ncurses-6.3-ds3p2mf7p4jitjoj5rcp7mm523ahhyab:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/perl-5.36.0-o4vafosesiuglmfxtwoaiho4oqhyvj2o:/leonardo/prod/opt/compilers/cuda/11.8/none; export CMAKE_PREFIX_PATH
CUDAHOSTCXX=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/gcc-11.3.0-tm6phj7wkcw7cuy6gjixemkvh5x2mhza/bin/g++; export CUDAHOSTCXX
CXX=/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env/gcc/g++; export CXX
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/31544/bus; export DBUS_SESSION_BUS_ADDRESS
DRES=/CINECA01/home/DRES_cinstaff; export DRES
F77=/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env/gcc/gfortran; export F77
FC=/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env/gcc/gfortran; export FC
HISTCONTROL=ignoredups; export HISTCONTROL
HISTSIZE=1000; export HISTSIZE
HOME=/leonardo/home/userinternal/mredenti; export HOME
HOSTNAME=login01.leonardo.local; export HOSTNAME
HPC_SYSTEM=leonardo; export HPC_SYSTEM
LANG=en_US.UTF-8; export LANG
LC_ALL=C; export LC_ALL
LESSOPEN='||/usr/bin/lesspipe.sh %s'; export LESSOPEN
LOADEDMODULES=profile/base:spack/0.19.1-d71; export LOADEDMODULES
LOGNAME=mredenti; export LOGNAME
LS_COLORS='rs=0:di=38;5;33:ln=38;5;51:mh=00:pi=40;38;5;11:so=38;5;13:do=38;5;5:bd=48;5;232;38;5;11:cd=48;5;232;38;5;3:or=48;5;232;38;5;9:mi=01;05;37;41:su=48;5;196;38;5;15:sg=48;5;11;38;5;16:ca=48;5;196;38;5;226:tw=48;5;10;38;5;16:ow=48;5;10;38;5;21:st=48;5;21;38;5;15:ex=38;5;40:*.tar=38;5;9:*.tgz=38;5;9:*.arc=38;5;9:*.arj=38;5;9:*.taz=38;5;9:*.lha=38;5;9:*.lz4=38;5;9:*.lzh=38;5;9:*.lzma=38;5;9:*.tlz=38;5;9:*.txz=38;5;9:*.tzo=38;5;9:*.t7z=38;5;9:*.zip=38;5;9:*.z=38;5;9:*.dz=38;5;9:*.gz=38;5;9:*.lrz=38;5;9:*.lz=38;5;9:*.lzo=38;5;9:*.xz=38;5;9:*.zst=38;5;9:*.tzst=38;5;9:*.bz2=38;5;9:*.bz=38;5;9:*.tbz=38;5;9:*.tbz2=38;5;9:*.tz=38;5;9:*.deb=38;5;9:*.rpm=38;5;9:*.jar=38;5;9:*.war=38;5;9:*.ear=38;5;9:*.sar=38;5;9:*.rar=38;5;9:*.alz=38;5;9:*.ace=38;5;9:*.zoo=38;5;9:*.cpio=38;5;9:*.7z=38;5;9:*.rz=38;5;9:*.cab=38;5;9:*.wim=38;5;9:*.swm=38;5;9:*.dwm=38;5;9:*.esd=38;5;9:*.jpg=38;5;13:*.jpeg=38;5;13:*.mjpg=38;5;13:*.mjpeg=38;5;13:*.gif=38;5;13:*.bmp=38;5;13:*.pbm=38;5;13:*.pgm=38;5;13:*.ppm=38;5;13:*.tga=38;5;13:*.xbm=38;5;13:*.xpm=38;5;13:*.tif=38;5;13:*.tiff=38;5;13:*.png=38;5;13:*.svg=38;5;13:*.svgz=38;5;13:*.mng=38;5;13:*.pcx=38;5;13:*.mov=38;5;13:*.mpg=38;5;13:*.mpeg=38;5;13:*.m2v=38;5;13:*.mkv=38;5;13:*.webm=38;5;13:*.ogm=38;5;13:*.mp4=38;5;13:*.m4v=38;5;13:*.mp4v=38;5;13:*.vob=38;5;13:*.qt=38;5;13:*.nuv=38;5;13:*.wmv=38;5;13:*.asf=38;5;13:*.rm=38;5;13:*.rmvb=38;5;13:*.flc=38;5;13:*.avi=38;5;13:*.fli=38;5;13:*.flv=38;5;13:*.gl=38;5;13:*.dl=38;5;13:*.xcf=38;5;13:*.xwd=38;5;13:*.yuv=38;5;13:*.cgm=38;5;13:*.emf=38;5;13:*.ogv=38;5;13:*.ogx=38;5;13:*.aac=38;5;45:*.au=38;5;45:*.flac=38;5;45:*.m4a=38;5;45:*.mid=38;5;45:*.midi=38;5;45:*.mka=38;5;45:*.mp3=38;5;45:*.mpc=38;5;45:*.ogg=38;5;45:*.ra=38;5;45:*.wav=38;5;45:*.oga=38;5;45:*.opus=38;5;45:*.spx=38;5;45:*.xspf=38;5;45:'; export LS_COLORS
LUA_CPATH='/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/lib/lua/5.4/?.so;/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/lib64/lua/5.4/?.so;/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/share/lua/5.4/?.so'; export LUA_CPATH
LUA_PATH='/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/lib/lua/5.4/?.lua;/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/lib/lua/5.4/?/init.lua;/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/lib64/lua/5.4/?.lua;/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/lib64/lua/5.4/?/init.lua;/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/share/lua/5.4/?.lua;/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/share/lua/5.4/?/init.lua'; export LUA_PATH
MAIL=/var/spool/mail/mredenti; export MAIL
MANPATH=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/share/man:/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/man:; export MANPATH
MODULEPATH=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/modules:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/environment-modules-5.2.0-rz47odw4phlhzhhbz7b65nv5s5othgmi/modulefiles:/leonardo/prod/opt/modulefiles/profiles:/leonardo/prod/opt/modulefiles/base/archive:/leonardo/prod/opt/modulefiles/base/dependencies:/leonardo/prod/opt/modulefiles/base/data:/leonardo/prod/opt/modulefiles/base/environment:/leonardo/prod/opt/modulefiles/base/libraries:/leonardo/prod/opt/modulefiles/base/tools:/leonardo/prod/opt/modulefiles/base/compilers:/leonardo/prod/opt/modulefiles/base/applications; export MODULEPATH
MODULESHOME=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/environment-modules-5.2.0-rz47odw4phlhzhhbz7b65nv5s5othgmi; export MODULESHOME
MODULES_CMD=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/environment-modules-5.2.0-rz47odw4phlhzhhbz7b65nv5s5othgmi/libexec/modulecmd.tcl; export MODULES_CMD
MODULES_RUN_QUARANTINE='LD_LIBRARY_PATH LD_PRELOAD'; export MODULES_RUN_QUARANTINE
MODULES_SITECONFIG=/leonardo/prod/opt/environment/module/current/etc/siteconfig.tcl; export MODULES_SITECONFIG
#OLDPWD=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs; export OLDPWD
PATH=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/bin:/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/unzip-6.0-g3zgx32a5bs6ofjlya6mc6pabnbgdu7d/bin:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/curl-7.85.0-yuinpuj3accsdwschioymxj3ghl2wm3v/bin:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/perl-5.36.0-o4vafosesiuglmfxtwoaiho4oqhyvj2o/bin:/leonardo/prod/opt/compilers/cuda/11.8/none/bin:/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env/gcc:/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env/case-insensitive:/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env:/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/bin:/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/bin:/leonardo/home/userinternal/mredenti/.local/bin:/leonardo/home/userinternal/mredenti/bin:/cineca/bin:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/environment-modules-5.2.0-rz47odw4phlhzhhbz7b65nv5s5othgmi/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin; export PATH
PKG_CONFIG_PATH=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/readline-8.1.2-mjpt32g56ntqui5wvtshebb2mdlpyt3e/lib/pkgconfig:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/ncurses-6.3-ds3p2mf7p4jitjoj5rcp7mm523ahhyab/lib/pkgconfig:/leonardo/prod/opt/compilers/cuda/11.8/none/lib64/pkgconfig:/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/share/pkgconfig:/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/lib64/pkgconfig:/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/lib/pkgconfig; export PKG_CONFIG_PATH
PUBLIC=/leonardo/pub/userinternal/mredenti; export PUBLIC
#PWD=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid; export PWD
SCRATCH=/leonardo_scratch/large/userinternal/mredenti; export SCRATCH
SELINUX_LEVEL_REQUESTED=''; export SELINUX_LEVEL_REQUESTED
SELINUX_ROLE_REQUESTED=''; export SELINUX_ROLE_REQUESTED
SELINUX_USE_CURRENT_RANGE=''; export SELINUX_USE_CURRENT_RANGE
SHELL=/bin/bash; export SHELL
SHLVL=1; export SHLVL
SPACK_CC=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/gcc-11.3.0-tm6phj7wkcw7cuy6gjixemkvh5x2mhza/bin/gcc; export SPACK_CC
SPACK_CC_RPATH_ARG=-Wl,-rpath,; export SPACK_CC_RPATH_ARG
SPACK_COMPILER_IMPLICIT_RPATHS=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/gcc-11.3.0-tm6phj7wkcw7cuy6gjixemkvh5x2mhza/lib/gcc/x86_64-pc-linux-gnu/11.3.0:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/gcc-11.3.0-tm6phj7wkcw7cuy6gjixemkvh5x2mhza/lib64; export SPACK_COMPILER_IMPLICIT_RPATHS
SPACK_COMPILER_SPEC=gcc@11.3.0; export SPACK_COMPILER_SPEC
SPACK_CXX=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/gcc-11.3.0-tm6phj7wkcw7cuy6gjixemkvh5x2mhza/bin/g++; export SPACK_CXX
SPACK_CXX_RPATH_ARG=-Wl,-rpath,; export SPACK_CXX_RPATH_ARG
SPACK_DEBUG_LOG_DIR=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid; export SPACK_DEBUG_LOG_DIR
SPACK_DEBUG_LOG_ID=likwid-qos542h; export SPACK_DEBUG_LOG_ID
SPACK_DEPLOY_CLUSTER_NAME=''; export SPACK_DEPLOY_CLUSTER_NAME
SPACK_DTAGS_TO_ADD=--disable-new-dtags; export SPACK_DTAGS_TO_ADD
SPACK_DTAGS_TO_STRIP=--enable-new-dtags; export SPACK_DTAGS_TO_STRIP
SPACK_ENV=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid; export SPACK_ENV
SPACK_ENV_PATH=/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env:/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env/case-insensitive:/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base/lib/spack/env/gcc; export SPACK_ENV_PATH
SPACK_F77=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/gcc-11.3.0-tm6phj7wkcw7cuy6gjixemkvh5x2mhza/bin/gfortran; export SPACK_F77
SPACK_F77_RPATH_ARG=-Wl,-rpath,; export SPACK_F77_RPATH_ARG
SPACK_FC=/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/gcc-11.3.0-tm6phj7wkcw7cuy6gjixemkvh5x2mhza/bin/gfortran; export SPACK_FC
SPACK_FC_RPATH_ARG=-Wl,-rpath,; export SPACK_FC_RPATH_ARG
SPACK_HOME=/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base; export SPACK_HOME
SPACK_INCLUDE_DIRS=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/include:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/readline-8.1.2-mjpt32g56ntqui5wvtshebb2mdlpyt3e/include:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/ncurses-6.3-ds3p2mf7p4jitjoj5rcp7mm523ahhyab/include:/leonardo/prod/opt/compilers/cuda/11.8/none/include; export SPACK_INCLUDE_DIRS
SPACK_LD_LIBRARY_PATH=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/lib64:/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/lib; export SPACK_LD_LIBRARY_PATH
SPACK_LINKER_ARG=-Wl,; export SPACK_LINKER_ARG
SPACK_LINK_DIRS=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/lib:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/readline-8.1.2-mjpt32g56ntqui5wvtshebb2mdlpyt3e/lib:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/ncurses-6.3-ds3p2mf7p4jitjoj5rcp7mm523ahhyab/lib:/leonardo/prod/opt/compilers/cuda/11.8/none/lib64; export SPACK_LINK_DIRS
SPACK_MODULE_VERSION=preprod_base_0.19.1_d7101d28658cf37f674efb91910db35ae8255929; export SPACK_MODULE_VERSION
SPACK_OLD_PS1='[\u@\h \W]\$ '; export SPACK_OLD_PS1
SPACK_PYTHON=/usr/bin/python3; export SPACK_PYTHON
SPACK_ROOT=/leonardo/prod/spack/03/spack_sources/0.19.1_preprod_base; export SPACK_ROOT
SPACK_ROOT_CACHE=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/cache; export SPACK_ROOT_CACHE
SPACK_ROOT_INSTALL=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install; export SPACK_ROOT_INSTALL
SPACK_ROOT_MODULES=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/modules; export SPACK_ROOT_MODULES
SPACK_ROOT_MODULES_TEMPLATES_SUFFIX=local; export SPACK_ROOT_MODULES_TEMPLATES_SUFFIX
SPACK_RPATH_DIRS=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/likwid-5.2.2-qos542hbqaougunviz6jyi3hzcudooj7/lib:/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/likwid-5.2.2-qos542hbqaougunviz6jyi3hzcudooj7/lib64:/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/install/linux-rhel8-icelake/gcc-11.3.0/lua-5.4.4-wr7rsyoapvm2j5nzjfu3qpiuubuajlot/lib:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/readline-8.1.2-mjpt32g56ntqui5wvtshebb2mdlpyt3e/lib:/leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-11.3.0/ncurses-6.3-ds3p2mf7p4jitjoj5rcp7mm523ahhyab/lib:/leonardo/prod/opt/compilers/cuda/11.8/none/lib64; export SPACK_RPATH_DIRS
SPACK_SHORT_SPEC='likwid@5.2.2%gcc@11.3.0+cuda+fortran build_system=generic patches=af4ce27 arch=linux-rhel8-icelake/qos542h'; export SPACK_SHORT_SPEC
SPACK_SYSTEM_DIRS=/bin:/usr/bin:/usr/local/bin:/bin64:/usr/bin64:/usr/local/bin64:/include:/usr/include:/usr/local/include:/lib:/usr/lib:/usr/local/lib:/lib64:/usr/lib64:/usr/local/lib64:/:/usr:/usr/local; export SPACK_SYSTEM_DIRS
SPACK_TARGET_ARGS='-march=icelake-client -mtune=icelake-client'; export SPACK_TARGET_ARGS
SPACK_UPSTREAM_CACHE_DIR=/leonardo/prod/spack/03/cache; export SPACK_UPSTREAM_CACHE_DIR
SPACK_UPSTREAM_INSTALL_DIR=/leonardo/prod/spack/03/install/0.19; export SPACK_UPSTREAM_INSTALL_DIR
SPACK_UPSTREAM_MODULES_DIR=/leonardo/prod/spack/03/modules/0.19.1_preprod_base; export SPACK_UPSTREAM_MODULES_DIR
SPACK_UPSTREAM_MODULE_DIR=/leonardo/prod/spack/03/modules/0.19.1_preprod_base; export SPACK_UPSTREAM_MODULE_DIR
SPACK_UPSTREAM_USER_CACHE_PATH=/leonardo/prod/spack/03/user_cache/0.19.1_preprod_base; export SPACK_UPSTREAM_USER_CACHE_PATH
SPACK_USER_CACHE_PATH=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/user_cache; export SPACK_USER_CACHE_PATH
SPACK_USER_CONFIG_PATH=/leonardo/pub/userinternal/mredenti/spack-0.19.1-03/user_cache; export SPACK_USER_CONFIG_PATH
SSH_CLIENT='130.186.19.42 61478 22'; export SSH_CLIENT
SSH_CONNECTION='130.186.19.42 61478 10.137.0.5 22'; export SSH_CONNECTION
SSH_TTY=/dev/pts/41; export SSH_TTY
TERM=xterm-256color; export TERM
TMPDIR=/scratch_local; export TMPDIR
USER=mredenti; export USER
WORK=/leonardo_work/cin_staff; export WORK
XDG_RUNTIME_DIR=/run/user/31544; export XDG_RUNTIME_DIR
XDG_SESSION_ID=58798; export XDG_SESSION_ID
_INC=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/include; export _INC
_INCLUDE=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/include; export _INCLUDE
_LIB=/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/lib64:/leonardo/home/userinternal/mredenti/spack-0.19.1-03/spack_envs/likwid/.spack-env/view/lib; export _LIB
_LMFILES_=/leonardo/prod/opt/modulefiles/profiles/profile/base:/leonardo/prod/opt/modulefiles/base/tools/spack/0.19.1-d71; export _LMFILES_
__MODULES_LMALTNAME='profile/base&profile/default&profile:spack/0.19.1-d71&as|spack/default&as|spack/latest'; export __MODULES_LMALTNAME
__MODULES_LMCONFLICT='spack/0.19.1-d71&spack'; export __MODULES_LMCONFLICT
__MODULES_LMINIT='module use --append /leonardo/prod/spack/03/install/0.19/linux-rhel8-icelake/gcc-8.5.0/environment-modules-5.2.0-rz47odw4phlhzhhbz7b65nv5s5othgmi/modulefiles'; export __MODULES_LMINIT
which_declare='declare -f'; export which_declare
</pre></details>

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:
Hi, sounds reasonable but I tried to make the recipe as flexible as possible, so it uses the path provided by hwloc:
```
filter_file(
                "^#HWLOC_LIB_DIR.*",
                "HWLOC_LIB_DIR = {0}".format(spec["hwloc"].prefix.lib),
                "config.mk",
            )
```
According to you output, it is also executed:
```
==> [2023-08-10-17:34:33.753267] FILTER FILE: config.mk [replacing "^#HWLOC_LIB_DIR.*"]
```

Not sure where the problem is. Either LIKWID does anything wrong or hwloc is not providing the proper library directory through `spec["hwloc"]`.
It seems it is the latter: I verified that `spec["hwloc"].prefix.lib` equals `/usr/lib/` instead of `usr/lib64/`. As a quick fix I have changed `spec["hwloc"].prefix.lib` to `spec["hwloc"].prefix.lib64` in the likwid recipe (and installation is successful) but perhaps there is a better way. 
Thanks for testing. That's the stuff a package manager should abstract.

I checked the hwloc recipe and there is no specification of `lib64` as library path during the installation. So it might be dependent on the hwloc version whether it uses `$prefix/lib` or `$prefix/lib64`. No easy way to find out, just installing all and checking the library folder.

The better way is probably to use `find_libraries("libhwloc", spec["hwloc"].prefix, shared=True, recursive=True)` and use the results to set up LIKWID's build.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/likwid/package.py b/var/spack/repos/builtin/packages/likwid/package.py
--- a/var/spack/repos/builtin/packages/likwid/package.py
+++ b/var/spack/repos/builtin/packages/likwid/package.py
@@ -188,12 +188,18 @@ def install(self, spec, prefix):
                 "HWLOC_INCLUDE_DIR = {0}".format(spec["hwloc"].prefix.include),
                 "config.mk",
             )
-            filter_file(
-                "^#HWLOC_LIB_DIR.*",
-                "HWLOC_LIB_DIR = {0}".format(spec["hwloc"].prefix.lib),
-                "config.mk",
-            )
-            filter_file("^#HWLOC_LIB_NAME.*", "HWLOC_LIB_NAME = hwloc", "config.mk")
+            ll = spec["hwloc"].libs
+            if len(ll.directories) > 0 and len(ll.names) > 0:
+                filter_file(
+                    "^#HWLOC_LIB_DIR.*",
+                    "HWLOC_LIB_DIR = {0}".format(ll.directories[0]),
+                    "config.mk",
+                )
+                filter_file(
+                    "^#HWLOC_LIB_NAME.*", "HWLOC_LIB_NAME = {0}".format(ll.names[0]), "config.mk"
+                )
+            else:
+                raise InstallError("Failed to find library path and/or name of hwloc dependency")
 
         # https://github.com/RRZE-HPC/likwid/issues/287
         if self.spec.satisfies("@:5.0.2 %gcc@10:"):


Test patch: