Repository: spack/spack

Issue:
Installation issue: whizard on AlmaLinux9+EPEL gcc12 Linking Error
### Steps to reproduce the issue

To be run inside `cern/alma9-base:latest` image. Example (error) output is available in my [gitlab CI MRE](https://gitlab.cern.ch/kkrizka/mre-spack-whizard-linking-tirpc/-/jobs/29989012).

```console
yum update -y
yum install -y epel-release
yum --enablerepo epel install -y gcc-toolset-12
source /opt/rh/gcc-toolset-12/enable
yum groupinstall -y "Development Tools"
yum install -y gcc-gfortran
git clone --depth=1 --branch develop https://github.com/spack/spack.git
source spack/share/spack/setup-env.sh
spack install whizard
```


### Error message

<details><summary>Error message</summary>

<pre>
libtool: link: /opt/rh/gcc-toolset-12/root/usr/bin/gfortran -g -O2 -o .libs/whizard -I/opt/spack/opt/spack/linux-almalinux9-x86_64/gcc-12.2.1/libtirpc-1.2.6-hin7vgkgxx2edogeykaidfqfjkpo4oeo/include/tirpc -Wl,-rpath -Wl,/opt/spack/opt/spack/linux-almalinux9-x86_64/gcc-12.2.1/hepmc3-3.2.5-yxkmuxepeit3vatzbycf6qubwbujesp5/lib64 -Wl,-rpath -Wl,/opt/spack/opt/spack/linux-almalinux9-x86_64/gcc-12.2.1/pythia8-8.306-dcjhzodclelvsneccjou2x36jezjdb6n/lib -Wl,-rpath -Wl,/opt/spack/opt/spack/linux-almalinux9-x86_64/gcc-12.2.1/pythia8-8.306-dcjhzodclelvsneccjou2x36jezjdb6n/lib  main/.libs/libwhizard_main.so -L/opt/spack/opt/spack/linux-almalinux9-x86_64/gcc-12.2.1/pythia8-8.306-dcjhzodclelvsneccjou2x36jezjdb6n/lib ./.libs/libwhizard.so -L/opt/spack/opt/spack/linux-almalinux9-x86_64/gcc-12.2.1/openloops-2.1.2-zxssflzfqsnbfr7dicorrn6e5c3bdbrd/lib /tmp/root/spack-stage/spack-stage-whizard-3.0.3-7gpuzqc2653tkxhhxhiljsxv4af2sqsx/spack-src/vamp/src/.libs/libvamp.so /tmp/root/spack-stage/spack-stage-whizard-3.0.3-7gpuzqc2653tkxhhxhiljsxv4af2sqsx/spack-src/circe1/src/.libs/libcirce1.so /tmp/root/spack-stage/spack-stage-whizard-3.0.3-7gpuzqc2653tkxhhxhiljsxv4af2sqsx/spack-src/circe2/src/.libs/libcirce2.so -lcuttools -lopenloops -loneloop -lolcommon -lrambo -ltrred prebuilt/.libs/libwhizard_prebuilt.so -L/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12 -L/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/opt/rh/gcc-toolset-12/root/usr/lib/gcc/x86_64-redhat-linux/12/../../.. -lstdc++ -lm -lgcc_s -ltirpc -L/opt/spack/opt/spack/linux-almalinux9-x86_64/gcc-12.2.1/hepmc3-3.2.5-yxkmuxepeit3vatzbycf6qubwbujesp5/lib64 -lHepMC3 -lpythia8 -ldl -Wl,-rpath -Wl,/opt/spack/opt/spack/linux-almalinux9-x86_64/gcc-12.2.1/whizard-3.0.3-7gpuzqc2653tkxhhxhiljsxv4af2sqsx/lib
/opt/rh/gcc-toolset-12/root/usr/libexec/gcc/x86_64-redhat-linux/12/ld: cannot find -ltirpc: No such file or directory
</pre></details>


### Information on your system

* **Spack:** 0.21.0.dev0 (dd00f50943247ed5f30591d8455f70a6288ab32f)
* **Python:** 3.9.16
* **Platform:** linux-almalinux9-broadwell
* **Concretizer:** clingo

### Additional information

@vvolkl

I don't see a way to upload the log files, but they are available here:
- [spack-build-out.txt](https://gitlab.cern.ch/kkrizka/mre-spack-whizard-linking-tirpc/-/jobs/29989012/artifacts/external_file/spack-stage/root/spack-stage-whizard-3.1.0-ubvmpyu6j64fhdzpd7tpbhsz7facdimg/spack-build-out.txt)
- [spack-build-env.txt](https://gitlab.cern.ch/kkrizka/mre-spack-whizard-linking-tirpc/-/jobs/29989012/artifacts/external_file/spack-stage/root/spack-stage-whizard-3.1.0-ubvmpyu6j64fhdzpd7tpbhsz7facdimg/spack-build-env.txt)

The error only happens when using gcc 12 from the EPEL repos. There is no problem using the default AlmaLinux9 gcc 11, ([example](https://gitlab.cern.ch/kkrizka/mre-spack-whizard-linking-tirpc/-/jobs/29989007)).

I don't see the library path (`-L`) for the Spack installation of `libtirpc`, like it is there for the other packages. Shouldn't it be included somehow? The weird part is that this used for work for us at this point, with the same argument.

### 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:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/whizard/package.py b/var/spack/repos/builtin/packages/whizard/package.py
--- a/var/spack/repos/builtin/packages/whizard/package.py
+++ b/var/spack/repos/builtin/packages/whizard/package.py
@@ -50,7 +50,7 @@ class Whizard(AutotoolsPackage):
     variant("openloops", default=False, description="builds with openloops")
     variant("latex", default=False, description="data visualization with latex")
 
-    depends_on("libtirpc")
+    depends_on("libtirpc", type=("build", "link", "run"))
     depends_on("ocaml@4.02.3:", type="build", when="@3:")
     depends_on("ocaml@4.02.3:~force-safe-string", type="build", when="@:2")
     depends_on("hepmc", when="hepmc=2")
@@ -107,7 +107,7 @@ def configure_args(self):
         spec = self.spec
         args = [
             "TIRPC_CFLAGS=-I%s" % spec["libtirpc"].prefix.include.tirpc,
-            "TIRPC_LIBS=-ltirpc",
+            f"TIRPC_LIBS= -L{spec['libtirpc'].prefix.lib} -ltirpc",
             "--enable-hepmc=%s" % ("no" if "hepmc=off" in spec else "yes"),
             "--enable-fastjet=%s" % ("yes" if "+fastjet" in spec else "no"),
             "--enable-pythia8=%s" % ("yes" if "+pythia8" in spec else "no"),


Test patch: