[libunwind] assembly.h includes cet.h that may not exist

The following line in libunwind/src/assembly.h causes build failure (file cet.h not found).

#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__)
#include <cet.h>
#define _LIBUNWIND_CET_ENDBR _CET_ENDBR
#else

Should this be changed to:

#if defined(__linux__) && __has_include(<cet.h>)

Comments?

Similar code in compiler-rt:

lib/builtins/assembly.h
18:#if __has_include(<cet.h>)
19:#include <cet.h>

lib/sanitizer_common/sanitizer_asm.h
70:#if (defined(__x86_64__) || defined(__i386__)) && defined(__has_include) && __has_include(<cet.h>)
71:#include <cet.h>

Moved this topic from “Project Infrastructure” (which is more about CI, build systems, website, …) to “Runtimes” which hopefully will help making it more visible to the right set of folks :slight_smile:

I reviewed ⚙ D105968 [libunwind][CET] Support exception handling stack unwind in CET environment which added the libunwind CET support.

libunwind needs to be built as runtimes. This builds a fresh clang first which bundles cet.h in its resource directory, so you can assume that cet.h is always available.

foreach(proj "libcxx" "libcxxabi" "libunwind")
  if (${proj} IN_LIST LLVM_ENABLE_PROJECTS)
    message(WARNING "Using LLVM_ENABLE_PROJECTS=${proj} is deprecated now, please use -DLLVM_ENABLE_RUNTIMES=${proj} or "
                    "see the instructions at https://libcxx.llvm.org/BuildingLibcxx.html for building the runtimes.")
  endif()
endforeach()

The LLVM_ENABLE_PROJECTS=libunwind way will sooner or later be officially removed, so adding __has_include to work with some older GCC looks like wasted efforts.

I do not know what people think about LLVM_ENABLE_PROJECTS=compiler-rt. I know compiler-rt is ported to GCC but they only need it for the latest GCC which has cet.h, so supporting older versions is not necessary.

Thanks. I found the warning for the deprecation of LLVM_ENABLE_PROJECTS for building libunwind and also found that using the freshly built clang to build libunwind is the recommended way now (this may be required for even libc++ because an older clang or gcc may not support certain C++20 features).

I agree that adding __has_include may be pointless. I will change my build scripts to start using LLVM_ENABLE_RUNTIMES. Btw, this is a good change and will simplify things a lot.

Looks like this is now “fixed”.