[libunwind] Only include cet.h if __CET__ defined
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 12 Feb 2022 09:29:33 +0000 (10:29 +0100)
committerNikita Popov <npopov@redhat.com>
Wed, 16 Feb 2022 08:45:54 +0000 (09:45 +0100)
We should not assume that the cet.h header exists just because
we're on x86 linux. Only include it if __CET__ is defined. This
makes the code more similar to what compiler-rt does in
https://github.com/llvm/llvm-project/blob/ee423d93ead39e94c2970b3cc7ef6e6faa75d10b/compiler-rt/lib/builtins/assembly.h#L17
(though that one also has a __has_include() check -- I've not found
that to be necessary).

Differential Revision: https://reviews.llvm.org/D119697

libunwind/src/assembly.h

index 978f6bd..89293a5 100644 (file)
@@ -15,7 +15,7 @@
 #ifndef UNWIND_ASSEMBLY_H
 #define UNWIND_ASSEMBLY_H
 
-#if (defined(__i386__) || defined(__x86_64__)) && defined(__linux__)
+#if defined(__linux__) && defined(__CET__)
 #include <cet.h>
 #define _LIBUNWIND_CET_ENDBR _CET_ENDBR
 #else