[BOLT] Robustify compile-time config check
authorNathan Sidwell <nathan@acm.org>
Wed, 19 Apr 2023 20:07:25 +0000 (16:07 -0400)
committerNathan Sidwell <nathan@acm.org>
Fri, 21 Apr 2023 16:37:54 +0000 (12:37 -0400)
The BOLT runtime is specifically hard coded for x86_64 linux or x86_64
darwin. (Using x86_64 syscalls, hardcoding syscall numbers.)

Make it very clear this is for those specific pair of systems.

Reviewed By: rafauler

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

bolt/runtime/common.h

index 58b8114..de11e44 100644 (file)
@@ -6,7 +6,11 @@
 //
 //===----------------------------------------------------------------------===//
 
-#if !defined(__APPLE__)
+#if !defined(__x86_64__)
+#error "For x86_64 only"
+#endif
+
+#if defined(__linux__)
 
 #include <cstddef>
 #include <cstdint>
@@ -17,7 +21,7 @@
 #include <elf.h>
 #endif
 
-#else
+#elif defined(__APPLE__)
 
 typedef __SIZE_TYPE__ size_t;
 #define __SSIZE_TYPE__                                                         \
@@ -36,6 +40,8 @@ typedef unsigned char uint8_t;
 typedef long long int64_t;
 typedef int int32_t;
 
+#else
+#error "For Linux or MacOS only"
 #endif
 
 // Save all registers while keeping 16B stack alignment