Repository: spack/spack

Issue:
llvm@16 +lldb: lib/liblldbCore.a(IOHandlerCursesGUI.cpp.o): undefined reference to symbol 'define_key@@@@NCURSES6_TINFO_5.0.19991023'
### Steps to reproduce the issue

`llvm +lld +clang +flang +lldb +llvm_dylib +link_llvm_dylib ^ncurses@6.3` fails to build using:
* `spack@develop` (14075f9f4cd82e7af138af0ad822fd9ddb8034fa from `Sat Apr 15 19:02:50 2023 -0700`)
* GCC 11.1.0
* Ubuntu 20.04, x86_64

Spack environment: [spack.yaml.txt](https://github.com/spack/spack/files/11244768/spack.yaml.txt)

<details><summary>Concretization</summary>
<pre>
==> Concretized llvm+clang+flang+link_llvm_dylib+lld+lldb+llvm_dylib ^ncurses@6.3
 -   hm44x3l  llvm@16.0.0%gcc@11.1.0+clang+compiler-rt~cuda+flang+gold+internal_unwind~ipo+libcxx+link_llvm_dylib+lld+lldb+llvm_dylib~mlir+omp_as_runtime~omp_debug~omp_tsan+polly~python~split_dwarf~z3~zstd build_system=cmake build_type=Release generator=ninja shlib_symbol_version=none targets=none version_suffix=none arch=linux-ubuntu20.04-x86_64
[+]  3xqzoem      ^binutils@2.40%gcc@11.1.0~gas+gold~gprofng~headers~interwork+ld~libiberty~lto~nls~pgo+plugins build_system=autotools libs=shared,static arch=linux-ubuntu20.04-x86_64
[+]  j2tlgt4          ^diffutils@3.9%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  5f66p4a              ^libiconv@1.17%gcc@11.1.0 build_system=autotools libs=shared,static arch=linux-ubuntu20.04-x86_64
[+]  j53y5lt          ^texinfo@7.0%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  so6noth          ^zstd@1.5.5%gcc@11.1.0+programs build_system=makefile compression=none libs=shared,static arch=linux-ubuntu20.04-x86_64
[+]  2eofaud      ^cmake@3.26.3%gcc@11.1.0~doc+ncurses+ownlibs~qt build_system=generic build_type=Release arch=linux-ubuntu20.04-x86_64
[+]  zcb236t          ^openssl@1.1.1t%gcc@11.1.0~docs~shared build_system=generic certs=mozilla arch=linux-ubuntu20.04-x86_64
[+]  w233qs7              ^ca-certificates-mozilla@2023-01-10%gcc@11.1.0 build_system=generic arch=linux-ubuntu20.04-x86_64
[+]  gytqrwk      ^hwloc@2.9.0%gcc@11.1.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl+pci~rocm build_system=autotools libs=shared,static arch=linux-ubuntu20.04-x86_64
[+]  3mmidga          ^libpciaccess@0.17%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  kagjqhf              ^libtool@2.4.7%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  e6fw62o                  ^m4@1.4.19%gcc@11.1.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=linux-ubuntu20.04-x86_64
[+]  b2tzsvo                      ^libsigsegv@2.14%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  i5p6x5b              ^util-macros@1.19.3%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  5pcn6vy          ^libxml2@2.10.3%gcc@11.1.0~python build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  kuor7e3      ^libedit@3.1-20210216%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  lwdu2k7      ^ncurses@6.3%gcc@11.1.0~symlinks+termlib abi=none build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  lqtudrr      ^ninja@1.11.1%gcc@11.1.0+re2c build_system=generic arch=linux-ubuntu20.04-x86_64
[+]  s4ngkq3          ^re2c@2.2%gcc@11.1.0 build_system=generic arch=linux-ubuntu20.04-x86_64
[+]  fzzx5kg      ^perl-data-dumper@2.173%gcc@11.1.0 build_system=perl arch=linux-ubuntu20.04-x86_64
[+]  roah3c6          ^perl@5.36.0%gcc@11.1.0+cpanm+open+shared+threads build_system=generic arch=linux-ubuntu20.04-x86_64
[+]  alkzfee              ^berkeley-db@18.1.40%gcc@11.1.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=linux-ubuntu20.04-x86_64
[+]  uorrjkf      ^pkgconf@1.8.0%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  dgwj4sc      ^python@3.10.10%gcc@11.1.0+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis~optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=0d98e93,7d40923,f2fd060 arch=linux-ubuntu20.04-x86_64
[+]  onsas2b          ^bzip2@1.0.8%gcc@11.1.0~debug~pic+shared build_system=generic arch=linux-ubuntu20.04-x86_64
[+]  ewn4mh2          ^expat@2.5.0%gcc@11.1.0+libbsd build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  bstssvl              ^libbsd@0.11.7%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  cb26zci                  ^libmd@1.0.4%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  qkfi67z          ^gdbm@1.23%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  7hham2b          ^gettext@0.21.1%gcc@11.1.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  2emlwb2              ^tar@1.34%gcc@11.1.0 build_system=autotools zip=pigz arch=linux-ubuntu20.04-x86_64
[+]  gojgmg4                  ^pigz@2.7%gcc@11.1.0 build_system=makefile arch=linux-ubuntu20.04-x86_64
[+]  d45vpa2          ^libffi@3.4.4%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  ghz4a3t          ^libxcrypt@4.4.33%gcc@11.1.0~obsolete_api build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  lui3zbo          ^readline@8.2%gcc@11.1.0 build_system=autotools patches=bbf97f1 arch=linux-ubuntu20.04-x86_64
[+]  6dlwhn3          ^sqlite@3.40.1%gcc@11.1.0+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  i5b6dq6          ^util-linux-uuid@2.38.1%gcc@11.1.0 build_system=autotools arch=linux-ubuntu20.04-x86_64
[+]  5g2lvqk          ^xz@5.4.1%gcc@11.1.0~pic build_system=autotools libs=shared,static arch=linux-ubuntu20.04-x86_64
[+]  hi2xsgc      ^zlib@1.2.13%gcc@11.1.0+optimize+pic+shared build_system=makefile arch=linux-ubuntu20.04-x86_64
</pre></details>

Error:
```
$> spack -e . install
...
==> Installing llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p
==> No binary for llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p found: installing from source
==> Fetching https://github.com/llvm/llvm-project/archive/llvmorg-16.0.0.tar.gz
==> No patches needed for llvm
==> llvm: Executing phase: 'cmake'
==> llvm: Executing phase: 'build'
==> Error: ProcessError: Command exited with status 1:
    '/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ninja-1.11.1-lqtudrrevq7pesl52udejfigqnkjbv2h/bin/ninja' '-j96' '-v'

40 errors found in build log:
     21536                     from /tmp/root/spack-stage/spack-stage-llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/spack-src/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h:20,
     21537                     from /tmp/root/spack-stage/spack-stage-llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/spack-src/mlir/lib/Dialect/Linalg/Transforms/EraseUnusedOperandsAndResults.c
              pp:9:
     21538    /tmp/root/spack-stage/spack-stage-llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/spack-src/mlir/include/mlir/Dialect/Vector/Transforms/VectorRewritePatterns.h:302:1: warning: mult
              i-line comment [-Wcomment]
     21539      302 | ///              /|\                        /|\
     21540          | ^
     21541    [6568/7383] : && /spack/lib/spack/env/gcc/g++ -std=c++11 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwr
              ite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pe
              ssimizing-move -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunc
              tion-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG -Wl,--gc-sections tools/lldb/tools/lld
              b-server/CMakeFiles/lldb-server.dir/Acceptor.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-gdbserver.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-serv
              er.dir/lldb-platform.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-server.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/LLDBServerUtilities.
              cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/SystemInitializerLLGS.cpp.o -o bin/lldb-server  -Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zli
              b-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib:/spack/opt/spack/linux-ubuntu
              20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/
              lib:/tmp/root/spack-stage/spack-stage-llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/spack-build-hm44x3l/lib:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
              :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
              :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
              :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
              :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  -lpthread  lib/liblldbHost.a  lib/liblldbInitializ
              ation.a  lib/liblldbVersion.a  lib/liblldbPluginProcessLinux.a  lib/liblldbPluginObjectFileELF.a  lib/liblldbPluginInstructionARM.a  lib/liblldbPluginInstructionLoongArch.a  lib
              /liblldbPluginInstructionMIPS.a  lib/liblldbPluginInstructionMIPS64.a  lib/liblldbPluginInstructionRISCV.a  lib/liblldbPluginProcessGDBRemote.a  /spack/opt/spack/linux-ubuntu20.
              04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib/libz.so  lib/liblldbPluginProcessPOSIX.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/
              liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a  lib
              /liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSystem
              Clang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPluginOb
              jCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblld
              bTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlus
              Language.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbP
              luginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/
              liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSymbo
              l.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldb
              PluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.
              a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbol
              FilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  l
              ib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression
              .a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPl
              uginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/libl
              ldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/l
              iblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/li
              blldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a
                lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDW
              ARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectF
              ilePDB.a  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libcurses.so  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.
              0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libform.so  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libpanel.so
               lib/liblldbVersion.a  lib/liblldbHost.a  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib/libedit.so  /spack/opt/s
              pack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib/liblzma.so  lib/liblldbUtility.a  -lpthread  lib/libclang-cpp.so.16  lib/libLLVM-16.so  -l
              dl && :
  >> 21542    FAILED: bin/lldb-server
     21543    : && /spack/lib/spack/env/gcc/g++ -std=c++11 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings
              -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-mo
              ve -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-section
              s -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG -Wl,--gc-sections tools/lldb/tools/lldb-server/CMa
              keFiles/lldb-server.dir/Acceptor.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-gdbserver.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-
              platform.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-server.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/LLDBServerUtilities.cpp.o tools/
              lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/SystemInitializerLLGS.cpp.o -o bin/lldb-server  -Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2
              xsgcpyaect4ojyrhzeqj56vg7ldvj/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64
              /gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib:/tmp/roo
              t/spack-stage/spack-stage-llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/spack-build-hm44x3l/lib:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
              :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
              :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
              :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
              :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  -lpthread  lib/liblldbHost.a  lib/liblldbInitialization.a  lib
              /liblldbVersion.a  lib/liblldbPluginProcessLinux.a  lib/liblldbPluginObjectFileELF.a  lib/liblldbPluginInstructionARM.a  lib/liblldbPluginInstructionLoongArch.a  lib/liblldbPlug
              inInstructionMIPS.a  lib/liblldbPluginInstructionMIPS64.a  lib/liblldbPluginInstructionRISCV.a  lib/liblldbPluginProcessGDBRemote.a  /spack/opt/spack/linux-ubuntu20.04-x86_64/gc
              c-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib/libz.so  lib/liblldbPluginProcessPOSIX.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPlugi
              nProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPlug
              inObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib
              /liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a
               lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  l
              ib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a
              lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSys
              temClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPlugi
              nObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/lib
              lldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusP
              lusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/libll
              dbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  l
              ib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSy
              mbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/libl
              ldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRunti
              me.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSym
              bolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a
                lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpress
              ion.a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblld
              bPluginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/l
              iblldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  /s
              pack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libcurses.so  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.
              3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libform.so  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libpanel.so  lib/liblldb
              Version.a  lib/liblldbHost.a  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib/libedit.so  /spack/opt/spack/linux-u
              buntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib/liblzma.so  lib/liblldbUtility.a  -lpthread  lib/libclang-cpp.so.16  lib/libLLVM-16.so  -ldl && :
  >> 21544    /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/binutils-2.40-3xqzoemoszmyc5kfpcpqgwr3v5q5dy2b/bin/ld: lib/liblldbCore.a(IOHandlerCursesGUI.cpp.o): undefined reference to s
              ymbol 'define_key@@@@NCURSES6_TINFO_5.0.19991023'
  >> 21545    /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/binutils-2.40-3xqzoemoszmyc5kfpcpqgwr3v5q5dy2b/bin/ld: /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu
              2k74qfmlxvfgtumdikel4xalp7dp/lib/libtinfo.so.6: error adding symbols: DSO missing from command line
  >> 21546    collect2: error: ld returned 1 exit status
...
```

Investigating:
```
$> spack build-env /hm44 sh -c "SPACK_TEST_COMMAND=dump-args /spack/lib/spack/env/gcc/g++ -std=c++11 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-declarations -Wno-unknown-pragmas -Wno-strict-aliasing -Wno-stringop-truncation -O3 -DNDEBUG -Wl,--gc-sections tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/Acceptor.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-gdbserver.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-platform.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-server.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/LLDBServerUtilities.cpp.o tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/SystemInitializerLLGS.cpp.o -o bin/lldb-server  -Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib:/tmp/root/spack-stage/spack-stage-llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/spack-build-hm44x3l/lib:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::  -lpthread  lib/liblldbHost.a  lib/liblldbInitialization.a  lib/liblldbVersion.a  lib/liblldbPluginProcessLinux.a  lib/liblldbPluginObjectFileELF.a  lib/liblldbPluginInstructionARM.a  lib/liblldbPluginInstructionLoongArch.a  lib/liblldbPluginInstructionMIPS.a  lib/liblldbPluginInstructionMIPS64.a  lib/liblldbPluginInstructionRISCV.a  lib/liblldbPluginProcessGDBRemote.a  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib/libz.so  lib/liblldbPluginProcessPOSIX.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  lib/liblldbCore.a  lib/liblldbSymbol.a  lib/liblldbTarget.a  lib/liblldbPluginProcessUtility.a  lib/liblldbInterpreter.a  lib/liblldbBreakpoint.a  lib/liblldbDataFormatters.a  lib/liblldbExpression.a  lib/liblldbPluginCPlusPlusLanguage.a  lib/liblldbPluginObjCLanguage.a  lib/liblldbCommands.a  lib/liblldbPluginObjectFileJIT.a  lib/liblldbPluginClangCommon.a  lib/liblldbPluginCPPRuntime.a  lib/liblldbPluginTypeSystemClang.a  lib/liblldbPluginAppleObjCRuntime.a  lib/liblldbPluginExpressionParserClang.a  lib/liblldbPluginSymbolFileDWARF.a  lib/liblldbPluginSymbolFilePDB.a  lib/liblldbPluginObjCRuntime.a  lib/liblldbPluginRenderScriptRuntime.a  lib/liblldbPluginSymbolFileNativePDB.a  lib/liblldbPluginObjectFilePDB.a  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libcurses.so  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libform.so  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libpanel.so  lib/liblldbVersion.a  lib/liblldbHost.a  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib/libedit.so  /spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib/liblzma.so  lib/liblldbUtility.a  -lpthread  lib/libclang-cpp.so.16  lib/libLLVM-16.so  -ldl"

/usr/bin/g++
-march=x86-64
-mtune=generic
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/hwloc-2.9.0-gytqrwkcclpbfi4m5bepisffoyclk4x6/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libpciaccess-0.17-3mmidgauleyk7arfikq33raxymzuraus/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/binutils-2.40-3xqzoemoszmyc5kfpcpqgwr3v5q5dy2b/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zstd-1.5.5-so6nothpdqyv4zfvxyuila56ka35vgta/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libxml2-2.10.3-5pcn6vyzkjwmdccnsytmzjnlhcwsepul/include/libxml2
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libxml2-2.10.3-5pcn6vyzkjwmdccnsytmzjnlhcwsepul/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/include
-I/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libiconv-1.17-5f66p4aoivmlxa7htmpsffk5ov62vgci/include
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/hwloc-2.9.0-gytqrwkcclpbfi4m5bepisffoyclk4x6/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libpciaccess-0.17-3mmidgauleyk7arfikq33raxymzuraus/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/binutils-2.40-3xqzoemoszmyc5kfpcpqgwr3v5q5dy2b/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zstd-1.5.5-so6nothpdqyv4zfvxyuila56ka35vgta/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libxml2-2.10.3-5pcn6vyzkjwmdccnsytmzjnlhcwsepul/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib
-L/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libiconv-1.17-5f66p4aoivmlxa7htmpsffk5ov62vgci/lib
-Wl,--disable-new-dtags
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib:/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib:/tmp/root/spack-stage/spack-stage-llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/spack-build-hm44x3l/lib:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/llvm-16.0.0-hm44x3lrxlrzgmafxaneyap3if6ha37p/lib64
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/hwloc-2.9.0-gytqrwkcclpbfi4m5bepisffoyclk4x6/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libpciaccess-0.17-3mmidgauleyk7arfikq33raxymzuraus/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/binutils-2.40-3xqzoemoszmyc5kfpcpqgwr3v5q5dy2b/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zstd-1.5.5-so6nothpdqyv4zfvxyuila56ka35vgta/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libxml2-2.10.3-5pcn6vyzkjwmdccnsytmzjnlhcwsepul/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib
-Wl,-rpath,/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libiconv-1.17-5f66p4aoivmlxa7htmpsffk5ov62vgci/lib
-std=c++11
-fPIC
-fno-semantic-interposition
-fvisibility-inlines-hidden
-Wno-error=date-time
-Wall
-Wextra
-Wno-unused-parameter
-Wwrite-strings
-Wcast-qual
-Wno-missing-field-initializers
-pedantic
-Wno-long-long
-Wimplicit-fallthrough
-Wno-maybe-uninitialized
-Wno-class-memaccess
-Wno-redundant-move
-Wno-pessimizing-move
-Wno-noexcept-type
-Wnon-virtual-dtor
-Wdelete-non-virtual-dtor
-Wsuggest-override
-Wno-misleading-indentation
-Wctad-maybe-unsupported
-fdiagnostics-color
-ffunction-sections
-fdata-sections
-Wno-deprecated-declarations
-Wno-unknown-pragmas
-Wno-strict-aliasing
-Wno-stringop-truncation
-O3
-DNDEBUG
-Wl,--gc-sections
tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/Acceptor.cpp.o
tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-gdbserver.cpp.o
tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-platform.cpp.o
tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/lldb-server.cpp.o
tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/LLDBServerUtilities.cpp.o
tools/lldb/tools/lldb-server/CMakeFiles/lldb-server.dir/SystemInitializerLLGS.cpp.o
-o
bin/lldb-server
-lpthread
lib/liblldbHost.a
lib/liblldbInitialization.a
lib/liblldbVersion.a
lib/liblldbPluginProcessLinux.a
lib/liblldbPluginObjectFileELF.a
lib/liblldbPluginInstructionARM.a
lib/liblldbPluginInstructionLoongArch.a
lib/liblldbPluginInstructionMIPS.a
lib/liblldbPluginInstructionMIPS64.a
lib/liblldbPluginInstructionRISCV.a
lib/liblldbPluginProcessGDBRemote.a
/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/zlib-1.2.13-hi2xsgcpyaect4ojyrhzeqj56vg7ldvj/lib/libz.so
lib/liblldbPluginProcessPOSIX.a
lib/liblldbCore.a
lib/liblldbSymbol.a
lib/liblldbTarget.a
lib/liblldbPluginProcessUtility.a
lib/liblldbInterpreter.a
lib/liblldbBreakpoint.a
lib/liblldbDataFormatters.a
lib/liblldbExpression.a
lib/liblldbPluginCPlusPlusLanguage.a
lib/liblldbPluginObjCLanguage.a
lib/liblldbCommands.a
lib/liblldbPluginObjectFileJIT.a
lib/liblldbPluginClangCommon.a
lib/liblldbPluginCPPRuntime.a
lib/liblldbPluginTypeSystemClang.a
lib/liblldbPluginAppleObjCRuntime.a
lib/liblldbPluginExpressionParserClang.a
lib/liblldbPluginSymbolFileDWARF.a
lib/liblldbPluginSymbolFilePDB.a
lib/liblldbPluginObjCRuntime.a
lib/liblldbPluginRenderScriptRuntime.a
lib/liblldbPluginSymbolFileNativePDB.a
lib/liblldbPluginObjectFilePDB.a
lib/liblldbCore.a
lib/liblldbSymbol.a
lib/liblldbTarget.a
lib/liblldbPluginProcessUtility.a
lib/liblldbInterpreter.a
lib/liblldbBreakpoint.a
lib/liblldbDataFormatters.a
lib/liblldbExpression.a
lib/liblldbPluginCPlusPlusLanguage.a
lib/liblldbPluginObjCLanguage.a
lib/liblldbCommands.a
lib/liblldbPluginObjectFileJIT.a
lib/liblldbPluginClangCommon.a
lib/liblldbPluginCPPRuntime.a
lib/liblldbPluginTypeSystemClang.a
lib/liblldbPluginAppleObjCRuntime.a
lib/liblldbPluginExpressionParserClang.a
lib/liblldbPluginSymbolFileDWARF.a
lib/liblldbPluginSymbolFilePDB.a
lib/liblldbPluginObjCRuntime.a
lib/liblldbPluginRenderScriptRuntime.a
lib/liblldbPluginSymbolFileNativePDB.a
lib/liblldbPluginObjectFilePDB.a
lib/liblldbCore.a
lib/liblldbSymbol.a
lib/liblldbTarget.a
lib/liblldbPluginProcessUtility.a
lib/liblldbInterpreter.a
lib/liblldbBreakpoint.a
lib/liblldbDataFormatters.a
lib/liblldbExpression.a
lib/liblldbPluginCPlusPlusLanguage.a
lib/liblldbPluginObjCLanguage.a
lib/liblldbCommands.a
lib/liblldbPluginObjectFileJIT.a
lib/liblldbPluginClangCommon.a
lib/liblldbPluginCPPRuntime.a
lib/liblldbPluginTypeSystemClang.a
lib/liblldbPluginAppleObjCRuntime.a
lib/liblldbPluginExpressionParserClang.a
lib/liblldbPluginSymbolFileDWARF.a
lib/liblldbPluginSymbolFilePDB.a
lib/liblldbPluginObjCRuntime.a
lib/liblldbPluginRenderScriptRuntime.a
lib/liblldbPluginSymbolFileNativePDB.a
lib/liblldbPluginObjectFilePDB.a
lib/liblldbCore.a
lib/liblldbSymbol.a
lib/liblldbTarget.a
lib/liblldbPluginProcessUtility.a
lib/liblldbInterpreter.a
lib/liblldbBreakpoint.a
lib/liblldbDataFormatters.a
lib/liblldbExpression.a
lib/liblldbPluginCPlusPlusLanguage.a
lib/liblldbPluginObjCLanguage.a
lib/liblldbCommands.a
lib/liblldbPluginObjectFileJIT.a
lib/liblldbPluginClangCommon.a
lib/liblldbPluginCPPRuntime.a
lib/liblldbPluginTypeSystemClang.a
lib/liblldbPluginAppleObjCRuntime.a
lib/liblldbPluginExpressionParserClang.a
lib/liblldbPluginSymbolFileDWARF.a
lib/liblldbPluginSymbolFilePDB.a
lib/liblldbPluginObjCRuntime.a
lib/liblldbPluginRenderScriptRuntime.a
lib/liblldbPluginSymbolFileNativePDB.a
lib/liblldbPluginObjectFilePDB.a
lib/liblldbCore.a
lib/liblldbSymbol.a
lib/liblldbTarget.a
lib/liblldbPluginProcessUtility.a
lib/liblldbInterpreter.a
lib/liblldbBreakpoint.a
lib/liblldbDataFormatters.a
lib/liblldbExpression.a
lib/liblldbPluginCPlusPlusLanguage.a
lib/liblldbPluginObjCLanguage.a
lib/liblldbCommands.a
lib/liblldbPluginObjectFileJIT.a
lib/liblldbPluginClangCommon.a
lib/liblldbPluginCPPRuntime.a
lib/liblldbPluginTypeSystemClang.a
lib/liblldbPluginAppleObjCRuntime.a
lib/liblldbPluginExpressionParserClang.a
lib/liblldbPluginSymbolFileDWARF.a
lib/liblldbPluginSymbolFilePDB.a
lib/liblldbPluginObjCRuntime.a
lib/liblldbPluginRenderScriptRuntime.a
lib/liblldbPluginSymbolFileNativePDB.a
lib/liblldbPluginObjectFilePDB.a
/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libcurses.so
/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libform.so
/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/ncurses-6.3-lwdu2k74qfmlxvfgtumdikel4xalp7dp/lib/libpanel.so
lib/liblldbVersion.a
lib/liblldbHost.a
/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/libedit-3.1-20210216-kuor7e3giqeyght6i5hcs7mjnfdrc5sb/lib/libedit.so
/spack/opt/spack/linux-ubuntu20.04-x86_64/gcc-11.1.0/xz-5.4.1-5g2lvqkjre55ktc5la4mocgg4i3g5h2m/lib/liblzma.so
lib/liblldbUtility.a
-lpthread
lib/libclang-cpp.so.16
lib/libLLVM-16.so
-ldl
```

If I manually invoke the failing command, but with `-ltinfo` at the end, it succeeds. Alternatively, so does setting `-Wl,--copy-dt-needed-entries` also fix the problem. Does anyone know why this is needed in my case? How can this be fixed?




### Error message

<details><summary>Error message</summary>
<pre>
see above
</pre></details>


### Information on your system

* **Spack:** 0.20.0.dev0 (14075f9f4cd82e7af138af0ad822fd9ddb8034fa)
* **Python:** 3.8.10
* **Platform:** linux-ubuntu20.04-cascadelake
* **Concretizer:** clingo

### Additional information

[spack-build-env.txt](https://github.com/spack/spack/files/11244788/spack-build-env.txt)
[spack-build-out.txt](https://github.com/spack/spack/files/11244789/spack-build-out.txt)

@haampie @trws @wspear

### 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:
Sounds awfully familiar, didn't I fix this https://github.com/llvm/llvm-project/commit/3c7bfbd6831b2144229734892182d403e46d7baf in LLVM 12 ;p

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py
--- a/var/spack/repos/builtin/packages/llvm/package.py
+++ b/var/spack/repos/builtin/packages/llvm/package.py
@@ -562,6 +562,16 @@ class Llvm(CMakePackage, CudaPackage):
     patch("add-include-for-libelf-llvm-12-14.patch", when="@12:14")
     patch("add-include-for-libelf-llvm-15.patch", when="@15")
 
+    @when("@14:17")
+    def patch(self):
+        # https://github.com/llvm/llvm-project/pull/69458
+        filter_file(
+            r"${TERMINFO_LIB}",
+            r"${Terminfo_LIBRARIES}",
+            "lldb/source/Core/CMakeLists.txt",
+            string=True,
+        )
+
     # The functions and attributes below implement external package
     # detection for LLVM. See:
     #


Test patch: