Repository: spack/spack

Issue:
libxpm does not build on RHEL8
### Steps to reproduce

```
spack install libxpm@3.5.11
```
Using the latest develop branch.
In this case v 3.5.11 but got the same error with 3.5.12 too.


### Error message

```
==> libxpm: Executing phase: 'build'
==> Error: ProcessError: Command exited with status 2:
    'make' '-j16' 'V=1'

13 errors found in build log:
     292    /home/espen/programmer/spack/lib/spack/env/gcc/gcc -DHAVE_CONFIG_H -I. -I..  -I../src -I../include/X11  -Wall -Wpointer-arith -
            Wmissing-declarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-defi
            nition -Wdeclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wcast-qual -Wmissing-noreturn -Wmissing-format-attribut
            e -Wredundant-decls -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-poi
            nt -Werror=return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast
             -Werror=pointer-to-int-cast -fno-strict-aliasing -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/xpro
            to-7.0.31-tt7anppp5xnjnfo3m43qc64cquwzhdup/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/lib
            x11-1.8.4-mtkgtk4gt27m4vc7rxzzlnw3s6sawydv/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/kbp
            roto-1.0.7-ajuuuow4er76g25bcbczxiijllyyahn2/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/li
            bxcb-1.14-57alpbk2m2dwfez76msc6tl57zzjbepk/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/lib
            xau-1.0.8-c3sxpel2mla4utzuueyvmp6jubwwfogh/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/lib
            xdmcp-1.1.4-kkoueuibu45o3qg5rqiin5tsns67wuaa/include  -g -O2 -MT cxpm.o -MD -MP -MF .deps/cxpm.Tpo -c -o cxpm.o cxpm.c
     293    xgettext -c"L10N_Comments" -d cxpm -n ./cxpm.c
     294    mv -f .deps/cxpm.Tpo .deps/cxpm.Po
     295    /bin/sh ../libtool  --tag=CC   --mode=link /home/espen/programmer/spack/lib/spack/env/gcc/gcc -Wall -Wpointer-arith -Wmissing-d
            eclarations -Wformat=2 -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wd
            eclaration-after-statement -Wunused -Wuninitialized -Wshadow -Wcast-qual -Wmissing-noreturn -Wmissing-format-attribute -Wredund
            ant-decls -Werror=implicit -Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror
            =return-type -Werror=trigraphs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=p
            ointer-to-int-cast -fno-strict-aliasing -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/xproto-7.0.31-
            tt7anppp5xnjnfo3m43qc64cquwzhdup/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/libx11-1.8.4-
            mtkgtk4gt27m4vc7rxzzlnw3s6sawydv/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/kbproto-1.0.7
            -ajuuuow4er76g25bcbczxiijllyyahn2/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/libxcb-1.14-
            57alpbk2m2dwfez76msc6tl57zzjbepk/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/libxau-1.0.8-
            c3sxpel2mla4utzuueyvmp6jubwwfogh/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/libxdmcp-1.1.
            4-kkoueuibu45o3qg5rqiin5tsns67wuaa/include  -g -O2   -o cxpm cxpm.o
     296    libtool: link: /home/espen/programmer/spack/lib/spack/env/gcc/gcc -Wall -Wpointer-arith -Wmissing-declarations -Wformat=2 -Wstr
            ict-prototypes -Wmissing-prototypes -Wnested-externs -Wbad-function-cast -Wold-style-definition -Wdeclaration-after-statement -
            Wunused -Wuninitialized -Wshadow -Wcast-qual -Wmissing-noreturn -Wmissing-format-attribute -Wredundant-decls -Werror=implicit -
            Werror=nonnull -Werror=init-self -Werror=main -Werror=missing-braces -Werror=sequence-point -Werror=return-type -Werror=trigrap
            hs -Werror=array-bounds -Werror=write-strings -Werror=address -Werror=int-to-pointer-cast -Werror=pointer-to-int-cast -fno-stri
            ct-aliasing -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/xproto-7.0.31-tt7anppp5xnjnfo3m43qc64cquwz
            hdup/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/libx11-1.8.4-mtkgtk4gt27m4vc7rxzzlnw3s6sa
            wydv/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/kbproto-1.0.7-ajuuuow4er76g25bcbczxiijlly
            yahn2/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/libxcb-1.14-57alpbk2m2dwfez76msc6tl57zzj
            bepk/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/libxau-1.0.8-c3sxpel2mla4utzuueyvmp6jubww
            fogh/include -I/home/espen/programmer/spack/opt/spack/linux-rhel8-x86_64_v3/gcc-8.5.0/libxdmcp-1.1.4-kkoueuibu45o3qg5rqiin5tsns
            67wuaa/include -g -O2 -o cxpm cxpm.o
     297    cxpm.o: In function `ErrorMessage':
  >> 298    /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:105: undefined referenc
            e to `libintl_gettext'
  >> 299    /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:121: undefined referenc
            e to `libintl_gettext'
  >> 300    /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:116: undefined referenc
            e to `libintl_gettext'
  >> 301    /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:110: undefined referenc
            e to `libintl_gettext'
  >> 302    /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:128: undefined referenc
            e to `libintl_gettext'
  >> 303    cxpm.o:/tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:132: more undefi
            ned references to `libintl_gettext' follow
     304    cxpm.o: In function `main':
  >> 305    /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:149: undefined referenc
            e to `libintl_bindtextdomain'
  >> 306    /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:150: undefined referenc
            e to `libintl_textdomain'
  >> 307    /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm/cxpm.c:157: undefined referenc
            e to `libintl_gettext'
  >> 308    collect2: error: ld returned 1 exit status
  >> 309    make[2]: *** [Makefile:396: cxpm] Error 1
     310    make[2]: Leaving directory '/tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src/cxpm'
  >> 311    make[1]: *** [Makefile:467: all-recursive] Error 1
     312    make[1]: Leaving directory '/tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-src'
  >> 313    make: *** [Makefile:375: all] Error 2

See build log for details:
  /tmp/espen/spack-stage/spack-stage-libxpm-3.5.11-n2nwz5ljgr764n6xcgytjomoxkicwg6v/spack-build-out.txt

```

### Information on your system

```
* **Spack:** 0.20.0.dev0 (a2a6e65e279cb14c74eb008a90e4934a20c749fc)
* **Python:** 3.6.8
* **Platform:** linux-rhel8-x86_64_v3
* **Concretizer:** clingo

```

### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have searched the issues of this repo and believe this is not a duplicate
- [X] I have run the failing commands in debug mode and reported the output


Discussion:
https://github.com/spack/spack/pull/35450#issuecomment-1544582394 @scheibelp @greenc-FNAL 
Thanks!
As mentioned earlier in the thread from the above linked comment: if I revert the last commit to libxpm `packages.py` it builds without problems.
I second this error. 

Here is the debug info, 

```console
$> spack debug report 
* **Spack:** 0.20.0.dev0 (a2a6e65e279cb14c74eb008a90e4934a20c749fc)
* **Python:** 3.6.15
* **Platform:** linux-sles15-haswell
* **Concretizer:** clingo
```

The error I see is below, it's the same as reported in the above thread. 

```
     308    /usr/bin/ld: cxpm.o: in function `ErrorMessage':
  >> 309    /gpfs/scratch/pr28fa/di36pex/di36pex/haswell/spack-stage-libxpm-3.5.12-i2uj7pq4dbpa47wkwlw4rbhujpwnx454/spack-src/cxpm/cxpm.c:116: undefined reference to `libintl_gettext'
  >> 310    /usr/bin/ld: /gpfs/scratch/pr28fa/di36pex/di36pex/haswell/spack-stage-libxpm-3.5.12-i2uj7pq4dbpa47wkwlw4rbhujpwnx454/spack-src/cxpm/cxpm.c:105: undefined reference to `libintl_gettext'

```



Resolving patch:
diff --git a/var/spack/repos/builtin/packages/libxpm/package.py b/var/spack/repos/builtin/packages/libxpm/package.py
--- a/var/spack/repos/builtin/packages/libxpm/package.py
+++ b/var/spack/repos/builtin/packages/libxpm/package.py
@@ -27,6 +27,6 @@ class Libxpm(AutotoolsPackage, XorgPackage):
     depends_on("util-macros", type="build")
 
     def flag_handler(self, name, flags):
-        if name == "ldlibs" and "intl" in self.spec["gettext"].libs.names:
+        if name == "ldflags" and "intl" in self.spec["gettext"].libs.names:
             flags.append("-lintl")
         return env_flags(name, flags)


Test patch: