Repository: spack/spack

Issue:
Installation issue: LLVM 14 with Apple Clang 15
### Steps to reproduce the issue

I need to build LLVM 14 for llvmlite but it fails to build with Apple Clang 15. It built fine with Apple Clang 14. LLVM 16 builds fine with Apple Clang 15. So something must have been fixed at some point. We just need to find the patch that solved this issue.
```console
> spack spec -I llvm@14
Input spec
--------------------------------
 -   llvm@14

Concretized
--------------------------------
 -   llvm@14.0.6%apple-clang@15.0.0+clang~code_signing~cuda~flang~gold~ipo~libomptarget~libomptarget_debug~link_llvm_dylib+lld+lldb+llvm_dylib+lua~mlir+polly~python~split_dwarf~z3 build_system=cmake build_type=Release compiler-rt=runtime generator=ninja libcxx=runtime libunwind=runtime openmp=runtime patches=1f42874,25bc503,8248141,b216cff,cb8e645 shlib_symbol_version=none targets=all version_suffix=none arch=darwin-ventura-m2
[+]      ^cmake@3.27.4%apple-clang@15.0.0~doc+ncurses+ownlibs build_system=generic build_type=Release arch=darwin-ventura-m2
[+]          ^curl@8.1.2%apple-clang@15.0.0~gssapi~ldap~libidn2~librtmp~libssh~libssh2+nghttp2 build_system=autotools libs=shared,static tls=secure_transport arch=darwin-ventura-m2
[+]              ^nghttp2@1.52.0%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]      ^hwloc@2.9.1%apple-clang@15.0.0~cairo~cuda~gl~libudev+libxml2~netloc~nvml~oneapi-level-zero~opencl~pci~rocm build_system=autotools libs=shared,static arch=darwin-ventura-m2
[+]          ^gnuconfig@2022-09-17%apple-clang@15.0.0 build_system=generic arch=darwin-ventura-m2
[+]      ^libedit@3.1-20210216%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]      ^libxml2@2.10.3%apple-clang@15.0.0+pic~python+shared build_system=autotools arch=darwin-ventura-m2
[+]          ^libiconv@1.17%apple-clang@15.0.0 build_system=autotools libs=shared,static arch=darwin-ventura-m2
[+]      ^lua@5.3.6%apple-clang@15.0.0~pcfile+shared build_system=makefile fetcher=curl arch=darwin-ventura-m2
[+]          ^readline@8.2%apple-clang@15.0.0 build_system=autotools patches=bbf97f1 arch=darwin-ventura-m2
[+]          ^unzip@6.0%apple-clang@15.0.0 build_system=makefile arch=darwin-ventura-m2
[+]      ^ncurses@6.4%apple-clang@15.0.0~symlinks+termlib abi=none build_system=autotools arch=darwin-ventura-m2
[+]      ^ninja@1.11.1%apple-clang@15.0.0+re2c build_system=generic arch=darwin-ventura-m2
[-]          ^python@3.8.17%apple-clang@15.0.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,4c24573,f2fd060 arch=darwin-ventura-m2
[+]              ^bzip2@1.0.8%apple-clang@15.0.0~debug~pic+shared build_system=generic arch=darwin-ventura-m2
[+]              ^gettext@0.21.1%apple-clang@15.0.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=darwin-ventura-m2
[+]                  ^libiconv@1.17%apple-clang@15.0.0 build_system=autotools libs=shared,static arch=darwin-ventura-m2
[+]                  ^libxml2@2.10.3%apple-clang@15.0.0~python build_system=autotools arch=darwin-ventura-m2
[+]                  ^tar@1.34%apple-clang@15.0.0 build_system=autotools zip=pigz arch=darwin-ventura-m2
[+]              ^libxcrypt@4.4.35%apple-clang@15.0.0~obsolete_api build_system=autotools patches=4885da3 arch=darwin-ventura-m2
[+]              ^openssl@3.1.2%apple-clang@15.0.0~docs+shared build_system=generic certs=mozilla arch=darwin-ventura-m2
[+]              ^xz@5.4.1%apple-clang@15.0.0~pic build_system=autotools libs=shared,static arch=darwin-ventura-m2
[+]          ^re2c@2.2%apple-clang@15.0.0 build_system=generic arch=darwin-ventura-m2
[+]      ^perl-data-dumper@2.173%apple-clang@15.0.0 build_system=perl arch=darwin-ventura-m2
[+]          ^perl@5.38.0%apple-clang@15.0.0+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=darwin-ventura-m2
[+]              ^berkeley-db@18.1.40%apple-clang@15.0.0+cxx~docs+stl build_system=autotools patches=26090f4,b231fcc arch=darwin-ventura-m2
[+]      ^pkgconf@1.9.5%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]      ^python@3.11.4%apple-clang@15.0.0+bz2+crypt+ctypes+dbm~debug+libxml2+lzma~nis+optimizations+pic+pyexpat+pythoncmd+readline+shared+sqlite3+ssl~tkinter+uuid+zlib build_system=generic patches=13fa8bf,b0615b2,f2fd060 arch=darwin-ventura-m2
[e]          ^apple-libuuid@1353.100.2%apple-clang@15.0.0 build_system=bundle arch=darwin-ventura-m2
[+]          ^bzip2@1.0.8%apple-clang@15.0.0~debug~pic+shared build_system=generic arch=darwin-ventura-m2
[+]              ^diffutils@3.9%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]          ^expat@2.5.0%apple-clang@15.0.0~libbsd build_system=autotools arch=darwin-ventura-m2
[+]          ^gdbm@1.23%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]          ^gettext@0.21.1%apple-clang@15.0.0+bzip2+curses+git~libunistring+libxml2+tar+xz build_system=autotools arch=darwin-ventura-m2
[+]              ^tar@1.34%apple-clang@15.0.0 build_system=autotools zip=pigz arch=darwin-ventura-m2
[+]                  ^pigz@2.7%apple-clang@15.0.0 build_system=makefile arch=darwin-ventura-m2
[+]                  ^zstd@1.5.5%apple-clang@15.0.0+programs build_system=makefile compression=none libs=shared,static arch=darwin-ventura-m2
[+]          ^libffi@3.4.4%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]          ^libxcrypt@4.4.35%apple-clang@15.0.0~obsolete_api build_system=autotools patches=4885da3 arch=darwin-ventura-m2
[+]          ^openssl@3.1.2%apple-clang@15.0.0~docs+shared build_system=generic certs=mozilla arch=darwin-ventura-m2
[+]              ^ca-certificates-mozilla@2023-05-30%apple-clang@15.0.0 build_system=generic arch=darwin-ventura-m2
[+]          ^sqlite@3.42.0%apple-clang@15.0.0+column_metadata+dynamic_extensions+fts~functions+rtree build_system=autotools arch=darwin-ventura-m2
[+]      ^swig@4.0.2-fortran%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]          ^autoconf@2.69%apple-clang@15.0.0 build_system=autotools patches=35c4492,7793209,a49dd5b arch=darwin-ventura-m2
[+]              ^m4@1.4.19%apple-clang@15.0.0+sigsegv build_system=autotools patches=9dc5fbd,bfdffa7 arch=darwin-ventura-m2
[+]                  ^libsigsegv@2.14%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]              ^perl@5.38.0%apple-clang@15.0.0+cpanm+opcode+open+shared+threads build_system=generic patches=714e4d1 arch=darwin-ventura-m2
[+]          ^automake@1.16.5%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]          ^bison@3.8.2%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]              ^diffutils@3.9%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]          ^libtool@2.4.7%apple-clang@15.0.0 build_system=autotools arch=darwin-ventura-m2
[+]          ^pcre@8.45%apple-clang@15.0.0~jit+multibyte+utf build_system=autotools arch=darwin-ventura-m2
[+]      ^xz@5.4.1%apple-clang@15.0.0~pic build_system=autotools libs=shared,static arch=darwin-ventura-m2
[+]      ^zlib-ng@2.1.3%apple-clang@15.0.0+compat+opt build_system=autotools patches=299b958,86c3f5b,ae9077a,b692621 arch=darwin-ventura-m2
```


### Error message

<details><summary>Error message</summary>

<pre>
FAILED: compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_posix.cpp.o 
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-build-6pw5max/./bin/clang++ --target=arm64-apple-darwin22.6.0 -DHAVE_RPC_XDR_H=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/.. -std=c++11 -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion -Wmisleading-indentation -fdiagnostics-color -Wall -std=c++14 -Wno-unused-parameter -O3 -DNDEBUG -arch arm64 -arch x86_64 -arch x86_64h -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk  -stdlib=libc++ -mmacosx-version-min=10.10 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk -fPIC -fno-builtin -fno-exceptions -funwind-tables -fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -g -Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -Wno-format -fno-rtti -Wframe-larger-than=570 -Wglobal-constructors -MD -MT compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_posix.cpp.o -MF compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_posix.cpp.o.d -o compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_posix.cpp.o -c /private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1254:17: error: use of undeclared identifier 'XDR'
CHECK_TYPE_SIZE(XDR);
                ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1254:1: error: use of undeclared identifier '__sanitizer_XDR'
CHECK_TYPE_SIZE(XDR);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1439:25: note: expanded from macro 'CHECK_TYPE_SIZE'
  COMPILER_CHECK(sizeof(__sanitizer_##TYPE) == sizeof(TYPE))
                        ^
<scratch space>:162:1: note: expanded from here
__sanitizer_XDR
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1255:1: error: use of undeclared identifier '__sanitizer_XDR'; did you mean '__sanitizer_cov'?
CHECK_SIZE_AND_OFFSET(XDR, x_op);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1442:27: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
                          ^
<scratch space>:163:1: note: expanded from here
__sanitizer_XDR
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h:57:38: note: '__sanitizer_cov' declared here
  SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov(__sanitizer::u32 *guard);
                                     ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1255:1: error: expected expression
CHECK_SIZE_AND_OFFSET(XDR, x_op);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1442:48: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
                                               ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1255:23: error: use of undeclared identifier 'XDR'
CHECK_SIZE_AND_OFFSET(XDR, x_op);
                      ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1255:1: error: expected expression
CHECK_SIZE_AND_OFFSET(XDR, x_op);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1443:34: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
                 sizeof(((CLASS *)NULL)->MEMBER));                \
                                 ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1255:1: error: unknown type name '__sanitizer_XDR'; did you mean '__sanitizer_tm'?
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1444:27: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
                          ^
<scratch space>:164:1: note: expanded from here
__sanitizer_XDR
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:402:8: note: '__sanitizer_tm' declared here
struct __sanitizer_tm {
       ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1255:1: error: no member named 'x_op' in '__sanitizer_tm'
CHECK_SIZE_AND_OFFSET(XDR, x_op);
^                          ~~~~
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1444:18: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
                 ^                             ~~~~~~
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-build-6pw5max/lib/clang/14.0.6/include/stddef.h:104:24: note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:349:44: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                                           ^~~~
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1255:23: error: unknown type name 'XDR'
CHECK_SIZE_AND_OFFSET(XDR, x_op);
                      ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1256:1: error: use of undeclared identifier '__sanitizer_XDR'; did you mean '__sanitizer_cov'?
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1442:27: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
                          ^
<scratch space>:165:1: note: expanded from here
__sanitizer_XDR
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h:57:38: note: '__sanitizer_cov' declared here
  SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov(__sanitizer::u32 *guard);
                                     ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1256:1: error: expected expression
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1442:48: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
                                               ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1256:23: error: use of undeclared identifier 'XDR'
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
                      ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1256:1: error: expected expression
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1443:34: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
                 sizeof(((CLASS *)NULL)->MEMBER));                \
                                 ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1256:1: error: unknown type name '__sanitizer_XDR'; did you mean '__sanitizer_tm'?
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1444:27: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
                          ^
<scratch space>:166:1: note: expanded from here
__sanitizer_XDR
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:402:8: note: '__sanitizer_tm' declared here
struct __sanitizer_tm {
       ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1256:1: error: no member named 'x_ops' in '__sanitizer_tm'
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
^                          ~~~~~
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1444:18: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(offsetof(__sanitizer_##CLASS, MEMBER) ==         \
                 ^                             ~~~~~~
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-build-6pw5max/lib/clang/14.0.6/include/stddef.h:104:24: note: expanded from macro 'offsetof'
#define offsetof(t, d) __builtin_offsetof(t, d)
                       ^                     ~
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:349:44: note: expanded from macro 'COMPILER_CHECK'
#define COMPILER_CHECK(pred) static_assert(pred, "")
                                           ^~~~
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1256:23: error: unknown type name 'XDR'
CHECK_SIZE_AND_OFFSET(XDR, x_ops);
                      ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1257:1: error: use of undeclared identifier '__sanitizer_XDR'; did you mean '__sanitizer_cov'?
CHECK_SIZE_AND_OFFSET(XDR, x_public);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1442:27: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
                          ^
<scratch space>:167:1: note: expanded from here
__sanitizer_XDR
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_interface_internal.h:57:38: note: '__sanitizer_cov' declared here
  SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_cov(__sanitizer::u32 *guard);
                                     ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1257:1: error: expected expression
CHECK_SIZE_AND_OFFSET(XDR, x_public);
^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h:1442:48: note: expanded from macro 'CHECK_SIZE_AND_OFFSET'
  COMPILER_CHECK(sizeof(((__sanitizer_##CLASS *)NULL)->MEMBER) == \
                                               ^
/private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-src/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:1257:23: error: use of undeclared identifier 'XDR'
CHECK_SIZE_AND_OFFSET(XDR, x_public);
                      ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
[38/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_bsd.cpp.o
[39/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_common.cpp.o
[40/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_common.cpp.o
[41/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_fuchsia.cpp.o
[42/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_linux.cpp.o
[43/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_posix.cpp.o
[44/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_printf.cpp.o
[45/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_libc.cpp.o
[46/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_deadlock_detector1.cpp.o
[47/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_allocator.cpp.o
[48/1889] Building CXX object compiler-rt/lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_mac.cpp.o
ninja: build stopped: subcommand failed.
FAILED: runtimes/runtimes-stamps/runtimes-build /private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-build-6pw5max/runtimes/runtimes-stamps/runtimes-build 
cd /private/var/folders/jv/cgkfvslj6nq1l7cw0c8c_8gm0000gn/T/Adam/spack-stage/spack-stage-llvm-14.0.6-6pw5maxjofvtpidkmiukzx3hepqjujh7/spack-build-6pw5max/runtimes/runtimes-bins && /Users/Adam/spack/opt/spack/darwin-ventura-m2/apple-clang-15.0.0/cmake-3.27.4-dxs6zir7hups5kbzenifarsw2ua5jxxq/bin/cmake --build .
</pre></details>


### Information on your system

* **Spack:** 0.21.0.dev0 (f42402129ace15b6495c663320f2eca518d5f9d4)
* **Python:** 3.11.4
* **Platform:** darwin-ventura-m2
* **Concretizer:** clingo


### Additional information

* [spack-build-out.txt](https://github.com/spack/spack/files/12700949/spack-build-out.txt)
* [spack-build-env-mods.txt](https://github.com/spack/spack/files/12700954/spack-build-env-mods.txt)

@haampie  @skosukhin  @trws

### 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 encountered the same issue (trying to compile numba). Inspired by https://github.com/llvm/llvm-project/commit/28800c2e18972935cd4f942aa428c5e6cc4c1670 I've tried the following custom patch (seems `SANITIZER_APPLE` was called `SANITIZER_MAC` in llvm14 so could not use the llvm commit directly) :  

```
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
index 32b8f47ed633..6cefef3f3327 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -1250,7 +1250,7 @@ CHECK_SIZE_AND_OFFSET(group, gr_passwd);
 CHECK_SIZE_AND_OFFSET(group, gr_gid);
 CHECK_SIZE_AND_OFFSET(group, gr_mem);

-#if HAVE_RPC_XDR_H
+#if HAVE_RPC_XDR_H && !SANITIZER_MAC
 CHECK_TYPE_SIZE(XDR);
 CHECK_SIZE_AND_OFFSET(XDR, x_op);
 CHECK_SIZE_AND_OFFSET(XDR, x_ops);
```

which seems to get me past the compilation of llvm@14 at least...
Want to submit a PR to add that patch? Then I can review it.

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
@@ -572,6 +572,8 @@ 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")
 
+    patch("sanitizer-platform-limits-posix-xdr-macos.patch", when="@10:14 platform=darwin")
+
     @when("@14:17")
     def patch(self):
         # https://github.com/llvm/llvm-project/pull/69458
@@ -940,6 +942,26 @@ def cmake_args(self):
 
         # Semicolon seperated list of runtimes to enable
         if runtimes:
+            # The older versions are not careful enough with the order of the runtimes.
+            # Instead of applying
+            # https://github.com/llvm/llvm-project/commit/06400a0142af8297b5d39b8f34a7c59db6f9910c,
+            # which might be incompatible with the version that we install,
+            # we sort the runtimes here according to the same order as
+            # in the aforementioned commit:
+            if self.spec.satisfies("@:14"):
+                runtimes_order = [
+                    "libc",
+                    "libunwind",
+                    "libcxxabi",
+                    "libcxx",
+                    "compiler-rt",
+                    "openmp",
+                ]
+                runtimes.sort(
+                    key=lambda x: runtimes_order.index(x)
+                    if x in runtimes_order
+                    else len(runtimes_order)
+                )
             cmake_args.extend(
                 [
                     define("LLVM_ENABLE_RUNTIMES", runtimes),


Test patch: