Repository: spack/spack

Issue:
Installation issue: apptainer fails to build with cflags="-O2" after 7dc485d2887c70e3e1ebdc6f680cda926444da72
### Steps to reproduce the issue

```console
$ spack spec -I apptainer@1.1.7
Input spec
--------------------------------
 -   apptainer@1.1.7

Concretized
--------------------------------
 -   apptainer@1.1.7%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +network+suid build_system=makefile arch=linux-rhel9-x86_64_v3
[+]      ^conmon@2.1.7%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=makefile arch=linux-rhel9-x86_64_v3
[+]          ^glib@2.76.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~libmount build_system=generic patches=fa31180 tracing=none arch=linux-rhel9-x86_64_v3
[+]              ^elfutils@0.189%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~debuginfod+nls build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^bzip2@1.0.8%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~debug~pic+shared build_system=generic arch=linux-rhel9-x86_64_v3
[+]                  ^xz@5.4.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~pic build_system=autotools libs=shared,static arch=linux-rhel9-x86_64_v3
[+]                  ^zstd@1.5.5%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +programs build_system=makefile compression=none libs=shared,static arch=linux-rhel9-x86_64_v3
[+]              ^gettext@0.21.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^libxml2@2.10.3%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~python build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^ncurses@6.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~symlinks+termlib abi=none build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^tar@1.34%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools zip=pigz arch=linux-rhel9-x86_64_v3
[+]                      ^pigz@2.7%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=makefile arch=linux-rhel9-x86_64_v3
[+]              ^libffi@3.3%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools patches=26f26c6 arch=linux-rhel9-x86_64_v3
[+]              ^libiconv@1.17%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools libs=shared,static arch=linux-rhel9-x86_64_v3
[+]              ^meson@1.1.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=python_pip patches=0f0b1bd arch=linux-rhel9-x86_64_v3
[+]              ^ninja@1.11.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +re2c build_system=generic arch=linux-rhel9-x86_64_v3
[+]                  ^python@3.10.10%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix+tkinter+uuid+zlib build_system=generic patches=0d98e93,f2fd060 arch=linux-rhel9-x86_64_v3
[+]                      ^libffi@3.4.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^re2c@2.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=generic arch=linux-rhel9-x86_64_v3
[+]              ^pcre2@10.42%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~jit+multibyte build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^perl@5.36.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +cpanm+open+shared+threads build_system=generic arch=linux-rhel9-x86_64_v3
[+]                  ^berkeley-db@18.1.40%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-rhel9-x86_64_v3
[+]                  ^gdbm@1.23%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^python@3.10.10%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis+optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tix+tkinter+uuid+zlib build_system=generic patches=0d98e93,f2fd060 arch=linux-rhel9-x86_64_v3
[+]                  ^libxcrypt@4.4.33%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~obsolete_api build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^sqlite@3.40.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^tcl@8.6.12%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^tk@8.6.11%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +xft+xss build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                      ^libx11@1.8.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^inputproto@2.3.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^kbproto@1.0.7%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^libxcb@1.14%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                              ^libpthread-stubs@0.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                              ^libxau@1.0.8%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                              ^libxdmcp@1.1.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                              ^xcb-proto@1.15.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^util-macros@1.19.3%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^xextproto@7.3.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^xproto@7.0.31%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^xtrans@1.4.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                      ^libxft@2.3.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^fontconfig@2.13.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                              ^font-util@1.4.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools fonts=encodings,font-adobe-100dpi,font-adobe-75dpi,font-adobe-utopia-100dpi,font-adobe-utopia-75dpi,font-adobe-utopia-type1,font-alias,font-arabic-misc,font-bh-100dpi,font-bh-75dpi,font-bh-lucidatypewriter-100dpi,font-bh-lucidatypewriter-75dpi,font-bh-type1,font-bitstream-100dpi,font-bitstream-75dpi,font-bitstream-speedo,font-bitstream-type1,font-cronyx-cyrillic,font-cursor-misc,font-daewoo-misc,font-dec-misc,font-ibm-type1,font-isas-misc,font-jis-misc,font-micro-misc,font-misc-cyrillic,font-misc-ethiopic,font-misc-meltho,font-misc-misc,font-mutt-misc,font-schumacher-misc,font-screen-cyrillic,font-sun-misc,font-winitzki-cyrillic,font-xfree86-type1 arch=linux-rhel9-x86_64_v3
[+]                                  ^bdftopcf@1.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                                      ^fontsproto@2.1.3%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                                      ^libxfont@1.5.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                                  ^mkfontdir@1.0.7%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                                  ^mkfontscale@1.2.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                                      ^libfontenc@1.1.7%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^freetype@2.11.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                              ^libpng@1.6.39%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~ipo build_system=cmake build_type=Release generator=make libs=shared,static arch=linux-rhel9-x86_64_v3
[+]                                  ^cmake@3.26.3%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=linux-rhel9-x86_64_v3
[+]                                  ^gmake@4.4.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~guile build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^libxrender@0.9.10%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                              ^renderproto@0.11.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                      ^libxscrnsaver@1.2.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^libxext@1.3.3%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                          ^scrnsaverproto@1.2.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]          ^go-md2man@2.0.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=generic arch=linux-rhel9-x86_64_v3
[+]      ^go@1.20.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=generic arch=linux-rhel9-x86_64_v3
[+]          ^git@2.40.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +man+nls+perl+subtree~svn~tcltk build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^autoconf@2.69%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools patches=35c4492,7793209,a49dd5b arch=linux-rhel9-x86_64_v3
[+]              ^automake@1.16.5%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^curl@8.0.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~gssapi~ldap~libidn2~librtmp~libssh~libssh2~nghttp2 build_system=autotools libs=shared,static tls=openssl arch=linux-rhel9-x86_64_v3
[+]              ^expat@2.5.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +libbsd build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^libbsd@0.11.7%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                      ^libmd@1.0.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^libidn2@2.3.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^libunistring@1.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^libtool@2.4.7%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^m4@1.4.19%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=linux-rhel9-x86_64_v3
[+]                  ^diffutils@3.9%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^openssh@9.3p1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +gssapi build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^krb5@1.20.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +shared build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                      ^bison@3.8.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^libedit@3.1-20210216%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^openssl@1.1.1t%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~docs~shared build_system=generic certs=mozilla arch=linux-rhel9-x86_64_v3
[+]                  ^ca-certificates-mozilla@2023-01-10%gcc@11.2.1 cflags="-O2 -O2" cppflags="-O2 -O2" cxxflags="-O2 -O2"  build_system=generic arch=linux-rhel9-x86_64_v3
[+]          ^go-bootstrap@1.17.13%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=generic arch=linux-rhel9-x86_64_v3
[+]      ^libgpg-error@1.47%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]          ^gawk@5.2.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" ~nls build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^gmp@6.2.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +cxx build_system=autotools libs=shared,static patches=69ad2e2 arch=linux-rhel9-x86_64_v3
[+]              ^libsigsegv@2.14%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^mpfr@4.2.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools libs=shared,static arch=linux-rhel9-x86_64_v3
[+]                  ^autoconf-archive@2023.02.20%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]                  ^texinfo@7.0.3%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]              ^readline@8.2%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools patches=bbf97f1 arch=linux-rhel9-x86_64_v3
[+]      ^libseccomp@2.5.4%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +python build_system=autotools arch=linux-rhel9-x86_64_v3
[+]          ^gperf@3.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]          ^py-cython@0.29.33%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=python_pip patches=71de066 arch=linux-rhel9-x86_64_v3
[+]              ^py-pip@23.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=generic arch=linux-rhel9-x86_64_v3
[+]              ^py-setuptools@59.4.0%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=generic arch=linux-rhel9-x86_64_v3
[+]              ^py-wheel@0.37.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=generic arch=linux-rhel9-x86_64_v3
[+]      ^pkgconf@1.9.5%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
[+]      ^squashfs@4.5.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +gzip~lz4~lzo~xz~zstd build_system=makefile default_compression=gzip arch=linux-rhel9-x86_64_v3
[+]          ^zlib@1.2.13%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2" +optimize+pic~shared build_system=makefile arch=linux-rhel9-x86_64_v3
[+]      ^util-linux-uuid@2.38.1%gcc@11.2.1 cflags="-O2" cppflags="-O2" cxxflags="-O2"  build_system=autotools arch=linux-rhel9-x86_64_v3
```


### Error message

<details><summary>Error message</summary>

<pre>
make: Entering directory '/tmp/root/spack-stage/spack-stage-apptainer-1.1.7-lbknpe6tp4kr2xp354hjxzpcp5lhyt4c/src/github.com/apptainer/apptainer/builddir'
 GEN GO DEP /tmp/root/spack-stage/spack-stage-apptainer-1.1.7-lbknpe6tp4kr2xp354hjxzpcp5lhyt4c/src/github.com/apptainer/apptainer/builddir/apptainer.deps
 GEN GO DEP /tmp/root/spack-stage/spack-stage-apptainer-1.1.7-lbknpe6tp4kr2xp354hjxzpcp5lhyt4c/src/github.com/apptainer/apptainer/builddir/starter.deps
 GEN /tmp/root/spack-stage/spack-stage-apptainer-1.1.7-lbknpe6tp4kr2xp354hjxzpcp5lhyt4c/src/github.com/apptainer/apptainer/scripts/go-generate
 GO apptainer
    [+] GO_TAGS "containers_image_openpgp sylog oci_engine apptainer_engine fakeroot_engine apparmor selinux seccomp"
# github.com/seccomp/libseccomp-golang
cgo-dwarf-inference:4:8: error: enumerator value for '__cgo_enum__2' is not an integer constant
cgo-dwarf-inference:6:8: error: enumerator value for '__cgo_enum__3' is not an integer constant
cgo-dwarf-inference:8:8: error: enumerator value for '__cgo_enum__4' is not an integer constant
cgo-dwarf-inference:10:8: error: enumerator value for '__cgo_enum__5' is not an integer constant
cgo-dwarf-inference:12:8: error: enumerator value for '__cgo_enum__6' is not an integer constant
cgo-dwarf-inference:14:8: error: enumerator value for '__cgo_enum__7' is not an integer constant
cgo-dwarf-inference:16:8: error: enumerator value for '__cgo_enum__8' is not an integer constant
cgo-dwarf-inference:18:8: error: enumerator value for '__cgo_enum__9' is not an integer constant
cgo-dwarf-inference:20:8: error: enumerator value for '__cgo_enum__10' is not an integer constant
cgo-dwarf-inference:22:8: error: enumerator value for '__cgo_enum__11' is not an integer constant
cgo-dwarf-inference:24:8: error: enumerator value for '__cgo_enum__12' is not an integer constant
cgo-dwarf-inference:26:8: error: enumerator value for '__cgo_enum__13' is not an integer constant
cgo-dwarf-inference:28:8: error: enumerator value for '__cgo_enum__14' is not an integer constant
cgo-dwarf-inference:30:8: error: enumerator value for '__cgo_enum__15' is not an integer constant
cgo-dwarf-inference:32:8: error: enumerator value for '__cgo_enum__16' is not an integer constant
cgo-dwarf-inference:34:8: error: enumerator value for '__cgo_enum__17' is not an integer constant
cgo-dwarf-inference:36:8: error: enumerator value for '__cgo_enum__18' is not an integer constant
cgo-dwarf-inference:38:8: error: enumerator value for '__cgo_enum__19' is not an integer constant
cgo-dwarf-inference:40:8: error: enumerator value for '__cgo_enum__20' is not an integer constant
cgo-dwarf-inference:42:8: error: enumerator value for '__cgo_enum__21' is not an integer constant
cgo-dwarf-inference:44:8: error: enumerator value for '__cgo_enum__22' is not an integer constant
cgo-dwarf-inference:46:8: error: enumerator value for '__cgo_enum__23' is not an integer constant
cgo-dwarf-inference:48:8: error: enumerator value for '__cgo_enum__24' is not an integer constant
cgo-dwarf-inference:50:8: error: enumerator value for '__cgo_enum__25' is not an integer constant
cgo-dwarf-inference:52:8: error: enumerator value for '__cgo_enum__26' is not an integer constant
cgo-dwarf-inference:54:8: error: enumerator value for '__cgo_enum__27' is not an integer constant
cgo-dwarf-inference:56:8: error: enumerator value for '__cgo_enum__28' is not an integer constant
cgo-dwarf-inference:58:8: error: enumerator value for '__cgo_enum__29' is not an integer constant
cgo-dwarf-inference:60:8: error: enumerator value for '__cgo_enum__30' is not an integer constant
cgo-dwarf-inference:62:8: error: enumerator value for '__cgo_enum__31' is not an integer constant
cgo-dwarf-inference:64:8: error: enumerator value for '__cgo_enum__32' is not an integer constant
cgo-dwarf-inference:66:8: error: enumerator value for '__cgo_enum__33' is not an integer constant
cgo-dwarf-inference:68:8: error: enumerator value for '__cgo_enum__34' is not an integer constant
cgo-dwarf-inference:70:8: error: enumerator value for '__cgo_enum__35' is not an integer constant
cgo-dwarf-inference:72:8: error: enumerator value for '__cgo_enum__36' is not an integer constant
cgo-dwarf-inference:74:8: error: enumerator value for '__cgo_enum__37' is not an integer constant
cgo-dwarf-inference:76:8: error: enumerator value for '__cgo_enum__38' is not an integer constant
cgo-dwarf-inference:78:8: error: enumerator value for '__cgo_enum__39' is not an integer constant
cgo-dwarf-inference:80:8: error: enumerator value for '__cgo_enum__40' is not an integer constant
cgo-dwarf-inference:82:8: error: enumerator value for '__cgo_enum__41' is not an integer constant
cgo-dwarf-inference:84:8: error: enumerator value for '__cgo_enum__42' is not an integer constant
cgo-dwarf-inference:86:8: error: enumerator value for '__cgo_enum__43' is not an integer constant
cgo-dwarf-inference:88:8: error: enumerator value for '__cgo_enum__44' is not an integer constant
cgo-dwarf-inference:90:8: error: enumerator value for '__cgo_enum__45' is not an integer constant
make: *** [Makefile:181: apptainer] Error 1
make: Leaving directory '/tmp/root/spack-stage/spack-stage-apptainer-1.1.7-lbknpe6tp4kr2xp354hjxzpcp5lhyt4c/src/github.com/apptainer/apptainer/builddir'
</pre></details>


### Information on your system

* **Spack:** 0.21.0.dev0 (5951bd3d04bf51613b5abf7223e4b385c24a6821)
* **Python:** 3.9.10
* **Platform:** linux-rhel9-zen2
* **Concretizer:** clingo

### Additional information

[spack-build-out.txt](https://github.com/spack/spack/files/11826583/spack-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/11826585/spack-build-env.txt)


### 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:
I'd added 1.1.9 yesterday (#38492) and it built fine, but after my PR was merged I noticed that I couldn't build it in develop, after doing a git bisect it seems to be something in #37376 leading to this issue, but I'm not sure what just yet.
I'm not able to reproduce this outside of my rhel9 container with the default spack config, so it may be something about el9 or (more likely) our environment.

```
spack config blame compilers
---                                         compilers:
/root/.spack/linux/compilers.yaml:2         - compiler:
/root/.spack/linux/compilers.yaml:3             spec: gcc@=13.1.0
/root/.spack/linux/compilers.yaml:4             paths:
/root/.spack/linux/compilers.yaml:5               cc: /opt/rit/el9/testing/app/linux-rhel9-x86_64_v3/gcc-11.2.1/gcc-13.1.0-ritjcsnae4tq4y6sie7yfxqxllli5gy4/bin/gcc
/root/.spack/linux/compilers.yaml:6               cxx: /opt/rit/el9/testing/app/linux-rhel9-x86_64_v3/gcc-11.2.1/gcc-13.1.0-ritjcsnae4tq4y6sie7yfxqxllli5gy4/bin/g++
/root/.spack/linux/compilers.yaml:7               f77: /opt/rit/el9/testing/app/linux-rhel9-x86_64_v3/gcc-11.2.1/gcc-13.1.0-ritjcsnae4tq4y6sie7yfxqxllli5gy4/bin/gfortran
/root/.spack/linux/compilers.yaml:8               fc: /opt/rit/el9/testing/app/linux-rhel9-x86_64_v3/gcc-11.2.1/gcc-13.1.0-ritjcsnae4tq4y6sie7yfxqxllli5gy4/bin/gfortran
/root/.spack/linux/compilers.yaml:9             flags: {}
/root/.spack/linux/compilers.yaml:10            operating_system: rhel9
/root/.spack/linux/compilers.yaml:11            target: x86_64
/root/.spack/linux/compilers.yaml:12            modules: []
/root/.spack/linux/compilers.yaml:13            environment: {}
/root/.spack/linux/compilers.yaml:14            extra_rpaths: []
/opt/rit/spack/etc/spack/compilers.yaml:2   - compiler:
/opt/rit/spack/etc/spack/compilers.yaml:3       modules: []
/opt/rit/spack/etc/spack/compilers.yaml:4       operating_system: rhel9
/opt/rit/spack/etc/spack/compilers.yaml:5       paths:
/opt/rit/spack/etc/spack/compilers.yaml:6         cc: /usr/bin/gcc
/opt/rit/spack/etc/spack/compilers.yaml:7         cxx: /usr/bin/g++
/opt/rit/spack/etc/spack/compilers.yaml:8         f77: /usr/bin/gfortran
/opt/rit/spack/etc/spack/compilers.yaml:9         fc: /usr/bin/gfortran
/opt/rit/spack/etc/spack/compilers.yaml:10      flags:
/opt/rit/spack/etc/spack/compilers.yaml:11        cflags: -O2
/opt/rit/spack/etc/spack/compilers.yaml:12        cxxflags: -O2
/opt/rit/spack/etc/spack/compilers.yaml:13        cppflags: -O2
/opt/rit/spack/etc/spack/compilers.yaml:14      spec: gcc@11.2.1
```
```
spack config blame packages
---                                         packages:
/opt/rit/spack/etc/spack/packages.yaml:2      all:
/opt/rit/spack/etc/spack/packages.yaml:3        compiler: [gcc@11.2.1]
/opt/rit/spack/etc/spack/packages.yaml:4        require:
/opt/rit/spack/etc/spack/packages.yaml:5        - one_of: ['%gcc@11.2.1', '%gcc@13.1.0']
/opt/rit/spack/etc/spack/packages.yaml:6        target: [x86_64_v3]
/opt/rit/spack/etc/spack/packages.yaml:7        providers:
/opt/rit/spack/etc/spack/packages.yaml:8          awk: [gawk]
/opt/rit/spack/etc/spack/packages.yaml:9          blas: [openblas, amdblis]
/opt/rit/spack/etc/spack/packages.yaml:10         D: [ldc]
/opt/rit/spack/etc/spack/packages.yaml:11         daal: [intel-daal]
/opt/rit/spack/etc/spack/packages.yaml:12         elf: [elfutils]
/opt/rit/spack/etc/spack/packages.yaml:13         fftw-api: [fftw, amdfftw]
/opt/rit/spack/etc/spack/packages.yaml:14         flame: [libflame, amdlibflame]
/opt/rit/spack/etc/spack/packages.yaml:15         fuse: [libfuse]
/opt/rit/spack/etc/spack/packages.yaml:16         gl: [glx, osmesa]
/opt/rit/spack/etc/spack/packages.yaml:17         glu: [mesa-glu, openglu]
/opt/rit/spack/etc/spack/packages.yaml:18         golang: [go, gcc]
/opt/rit/spack/etc/spack/packages.yaml:19         go-external-or-gccgo-bootstrap: [go-bootstrap, gcc]
/opt/rit/spack/etc/spack/packages.yaml:20         iconv: [libiconv]
/opt/rit/spack/etc/spack/packages.yaml:21         ipp: [intel-ipp]
/opt/rit/spack/etc/spack/packages.yaml:22         java: [openjdk, jdk, ibm-java]
/opt/rit/spack/etc/spack/packages.yaml:23         jpeg: [libjpeg-turbo, libjpeg]
/opt/rit/spack/etc/spack/packages.yaml:24         lapack: [openblas, amdlibflame]
/opt/rit/spack/etc/spack/packages.yaml:25         libglx: [mesa+glx, mesa18+glx]
/opt/rit/spack/etc/spack/packages.yaml:26         libllvm: [llvm]
/opt/rit/spack/etc/spack/packages.yaml:27         libosmesa: [mesa+osmesa, mesa18+osmesa]
/opt/rit/spack/etc/spack/packages.yaml:28         lua-lang: [lua, lua-luajit-openresty, lua-luajit]
/opt/rit/spack/etc/spack/packages.yaml:29         luajit: [lua-luajit-openresty, lua-luajit]
/opt/rit/spack/etc/spack/packages.yaml:30         mariadb-client: [mariadb, mariadb-c-client]
/opt/rit/spack/etc/spack/packages.yaml:31         mkl: [intel-oneapi-mkl]
/opt/rit/spack/etc/spack/packages.yaml:32         mpe: [mpe2]
/opt/rit/spack/etc/spack/packages.yaml:33         mpi: [openmpi, mpich]
/opt/rit/spack/etc/spack/packages.yaml:34         mysql-client: [mariadb, mariadb-c-client]
/opt/rit/spack/etc/spack/packages.yaml:35         opencl: [pocl]
/opt/rit/spack/etc/spack/packages.yaml:36         onedal: [intel-oneapi-dal]
/opt/rit/spack/etc/spack/packages.yaml:37         pbs: [openpbs, torque]
/opt/rit/spack/etc/spack/packages.yaml:38         pil: [py-pillow]
/opt/rit/spack/etc/spack/packages.yaml:39         pkgconfig: [pkgconf, pkg-config]
/opt/rit/spack/etc/spack/packages.yaml:40         rpc: [libtirpc]
/opt/rit/spack/etc/spack/packages.yaml:41         scalapack: [netlib-scalapack, amdscalapack]
/opt/rit/spack/etc/spack/packages.yaml:42         sycl: [hipsycl]
/opt/rit/spack/etc/spack/packages.yaml:43         szip: [libaec, libszip]
/opt/rit/spack/etc/spack/packages.yaml:44         tbb: [intel-tbb]
/opt/rit/spack/etc/spack/packages.yaml:45         unwind: [libunwind]
/opt/rit/spack/etc/spack/packages.yaml:46         uuid: [util-linux-uuid, libuuid]
/opt/rit/spack/etc/spack/packages.yaml:47         xxd: [xxd-standalone, vim]
/opt/rit/spack/etc/spack/packages.yaml:48         yacc: [bison, byacc]
/opt/rit/spack/etc/spack/packages.yaml:49         ziglang: [zig]
/opt/rit/spack/etc/spack/packages.yaml:50       permissions:
/opt/rit/spack/etc/spack/packages.yaml:51         read: world
/opt/rit/spack/etc/spack/packages.yaml:52     cuda:
/opt/rit/spack/etc/spack/packages.yaml:53       version:
/opt/rit/spack/etc/spack/packages.yaml:53       - 11.8.0
/opt/rit/spack/etc/spack/packages.yaml:53       - '11.6'
/opt/rit/spack/etc/spack/packages.yaml:54       require:
/opt/rit/spack/etc/spack/packages.yaml:55       - one_of: ['@11.6', '@11.8.0']
/opt/rit/spack/etc/spack/packages.yaml:56     cudnn:
/opt/rit/spack/etc/spack/packages.yaml:57       version: [8.4.0.27-11.6]
/opt/rit/spack/etc/spack/packages.yaml:58     fltk:
/opt/rit/spack/etc/spack/packages.yaml:59       variants: ~gl
/opt/rit/spack/etc/spack/packages.yaml:60     gaussian:
/opt/rit/spack/etc/spack/packages.yaml:61       permissions:
/opt/rit/spack/etc/spack/packages.yaml:62         read: group
/opt/rit/spack/etc/spack/packages.yaml:63         group: gaussian-user
/opt/rit/spack/etc/spack/packages.yaml:64     gdal:
/opt/rit/spack/etc/spack/packages.yaml:66       variants: +poppler+zstd+lz4+hdf5+curl+python
/opt/rit/spack/etc/spack/packages.yaml:67     gzip:
/opt/rit/spack/etc/spack/packages.yaml:68       version:
/opt/rit/spack/etc/spack/packages.yaml:68       - '1.11'
/opt/rit/spack/etc/spack/packages.yaml:69     hypre:
/opt/rit/spack/etc/spack/packages.yaml:70       require: ^openblas~ilp64
/opt/rit/spack/etc/spack/packages.yaml:71     openmpi:
/opt/rit/spack/etc/spack/packages.yaml:72       variants: fabrics=ofi,ucx schedulers=slurm +legacylaunchers
/opt/rit/spack/etc/spack/packages.yaml:73       require: fabrics=ofi,ucx schedulers=slurm +legacylaunchers
/opt/rit/spack/etc/spack/packages.yaml:74     libfabric:
/opt/rit/spack/etc/spack/packages.yaml:75       require: fabrics=sockets,tcp,udp,verbs
/opt/rit/spack/etc/spack/packages.yaml:76     mesa:
/opt/rit/spack/etc/spack/packages.yaml:77       require: ~llvm
/opt/rit/spack/etc/spack/packages.yaml:78     mpich:
/opt/rit/spack/etc/spack/packages.yaml:79       require: +slurm netmod=ucx pmi=pmix
/opt/rit/spack/etc/spack/packages.yaml:80     poppler:
/opt/rit/spack/etc/spack/packages.yaml:81       version: [21.09.0]
/opt/rit/spack/etc/spack/packages.yaml:82     python:
/opt/rit/spack/etc/spack/packages.yaml:83       require: +tkinter+optimizations
/opt/rit/spack/etc/spack/packages.yaml:84       variants: +tkinter+optimizations
/opt/rit/spack/etc/spack/packages.yaml:85     r:
/opt/rit/spack/etc/spack/packages.yaml:86       require: +X+external-lapack ^openblas threads=openmp
/opt/rit/spack/etc/spack/packages.yaml:87       variants: +X+external-lapack ^openblas threads=openmp
/opt/rit/spack/etc/spack/packages.yaml:89     hwloc:
/opt/rit/spack/etc/spack/packages.yaml:90       buildable: False
/opt/rit/spack/etc/spack/packages.yaml:91       externals:
/opt/rit/spack/etc/spack/packages.yaml:92       - spec: hwloc@2.4.1
/opt/rit/spack/etc/spack/packages.yaml:93         prefix: /usr
/opt/rit/spack/etc/spack/packages.yaml:94     linux-headers:
/opt/rit/spack/etc/spack/packages.yaml:95       buildable: False
/opt/rit/spack/etc/spack/packages.yaml:96       externals:
/opt/rit/spack/etc/spack/packages.yaml:97       - spec: linux-headers@5.14.0-70.30.1.el9_0
/opt/rit/spack/etc/spack/packages.yaml:98         prefix: /usr
/opt/rit/spack/etc/spack/packages.yaml:99     libevent:
/opt/rit/spack/etc/spack/packages.yaml:100      buildable: False
/opt/rit/spack/etc/spack/packages.yaml:101      externals:
/opt/rit/spack/etc/spack/packages.yaml:102      - spec: libevent@2.1.12
/opt/rit/spack/etc/spack/packages.yaml:103        prefix: /usr
/opt/rit/spack/etc/spack/packages.yaml:104    munge:
/opt/rit/spack/etc/spack/packages.yaml:105      buildable: False
/opt/rit/spack/etc/spack/packages.yaml:106      externals:
/opt/rit/spack/etc/spack/packages.yaml:107      - spec: munge@0.5.15
/opt/rit/spack/etc/spack/packages.yaml:108        prefix: /usr
/opt/rit/spack/etc/spack/packages.yaml:109      variants: localstatedir=/var
/opt/rit/spack/etc/spack/packages.yaml:110    matlab:
/opt/rit/spack/etc/spack/packages.yaml:111      buildable: False
/opt/rit/spack/etc/spack/packages.yaml:112      externals:
/opt/rit/spack/etc/spack/packages.yaml:113      - spec: matlab@R2022a
/opt/rit/spack/etc/spack/packages.yaml:114        prefix: /opt/rit/proprietary/matlab/R2022a
/opt/rit/spack/etc/spack/packages.yaml:115    mathematica:
/opt/rit/spack/etc/spack/packages.yaml:116      buildable: False
/opt/rit/spack/etc/spack/packages.yaml:117      externals:
/opt/rit/spack/etc/spack/packages.yaml:118      - spec: mathematica@13.0.1
/opt/rit/spack/etc/spack/packages.yaml:119        prefix: /opt/rit/proprietary/mathematica/13.0.1
/opt/rit/spack/etc/spack/packages.yaml:120    pmix:
/opt/rit/spack/etc/spack/packages.yaml:121      buildable: False
/opt/rit/spack/etc/spack/packages.yaml:122      externals:
/opt/rit/spack/etc/spack/packages.yaml:123      - spec: pmix@3.2.3
/opt/rit/spack/etc/spack/packages.yaml:124        prefix: /usr
/opt/rit/spack/etc/spack/packages.yaml:125    slurm:
/opt/rit/spack/etc/spack/packages.yaml:126      variants: +hwloc+mariadb+pmix+readline sysconfdir=/etc/slurm
/opt/rit/spack/etc/spack/packages.yaml:127      buildable: False
/opt/rit/spack/etc/spack/packages.yaml:128      externals:
/opt/rit/spack/etc/spack/packages.yaml:129      - spec: slurm@23-03-2-1
/opt/rit/spack/etc/spack/packages.yaml:130        prefix: /usr
```
Does not occur with centostream9 with default config.
Does not occur in my regular build environment when I remove the cflags, cxxflags, and cppflags config from the compilers.yaml. So something with cflag flag handling, I guess.
Still trying to figure out what's going wrong here, but it looks like the user CFLAGS may be being tacked on after a -l argument to gcc
There's a behavior change here for sure, but the actual issue seems to be some of the parts of apptainer require -O0, and blindly overriding that for everything causes the errors. I've made changes to the cc wrapper that ignore spack provided optimization flags if the package has specified -O0, but that seems extremely specific  and maybe not the best way to solve this problem.

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/apptainer/package.py b/var/spack/repos/builtin/packages/apptainer/package.py
--- a/var/spack/repos/builtin/packages/apptainer/package.py
+++ b/var/spack/repos/builtin/packages/apptainer/package.py
@@ -53,3 +53,8 @@ def config_options(self):
         if spec.satisfies("@1.1.0: +suid"):
             options.append("--with-suid")
         return options
+
+    def flag_handler(self, name, flags):
+        # Certain go modules this build pulls in cannot be built with anything
+        # other than -O0. Best to just discard any injected flags.
+        return (None, flags, None)


Test patch: