aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorquic-k <kushpal@qti.qualcomm.com>2025-11-04 10:05:31 +0530
committerGitHub <noreply@github.com>2025-11-04 04:35:31 +0000
commita3a99c3996ffa2abf7e2b1e4abeaa933830f2ac3 (patch)
treede4633b810b97455a7089c3b5e0cf75977dc6ac0
parent00ee53cc7b555ce408e6cd86378e3112bbdb0db8 (diff)
downloadllvm-a3a99c3996ffa2abf7e2b1e4abeaa933830f2ac3.zip
llvm-a3a99c3996ffa2abf7e2b1e4abeaa933830f2ac3.tar.gz
llvm-a3a99c3996ffa2abf7e2b1e4abeaa933830f2ac3.tar.bz2
[compiler-rt][x86] Don't use assert.h when building without a libc (#165384)
fixes https://github.com/llvm/llvm-project/issues/164932 Signed-off-by: Kushal Pal <kushpal@qti.qualcomm.com> Co-authored-by: Saleem Abdulrasool <compnerd@compnerd.org>
-rw-r--r--compiler-rt/lib/builtins/cpu_model/x86.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler-rt/lib/builtins/cpu_model/x86.c b/compiler-rt/lib/builtins/cpu_model/x86.c
index c21b2ba..45b7055 100644
--- a/compiler-rt/lib/builtins/cpu_model/x86.c
+++ b/compiler-rt/lib/builtins/cpu_model/x86.c
@@ -21,7 +21,9 @@
#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER)
+#if __STDC_HOSTED__
#include <assert.h>
+#endif // __STDC_HOSTED__
#if (defined(__GNUC__) || defined(__clang__)) && !defined(_MSC_VER)
#include <cpuid.h>
@@ -245,8 +247,8 @@ struct __processor_model {
unsigned int __cpu_features[1];
} __cpu_model = {0, 0, 0, {0}};
-static_assert(sizeof(__cpu_model) == 16,
- "Wrong size of __cpu_model will result in ABI break");
+_Static_assert(sizeof(__cpu_model) == 16,
+ "Wrong size of __cpu_model will result in ABI break");
// This code is copied from lib/Support/Host.cpp.
// Changes to either file should be mirrored in the other.
@@ -1200,8 +1202,8 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
unsigned Vendor;
unsigned Model, Family;
unsigned Features[(CPU_FEATURE_MAX + 31) / 32] = {0};
- static_assert(sizeof(Features) / sizeof(Features[0]) == 4, "");
- static_assert(sizeof(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, "");
+ _Static_assert(sizeof(Features) / sizeof(Features[0]) == 4, "");
+ _Static_assert(sizeof(__cpu_features2) / sizeof(__cpu_features2[0]) == 3, "");
// This function needs to run just once.
if (__cpu_model.__cpu_vendor)
@@ -1234,9 +1236,11 @@ int CONSTRUCTOR_ATTRIBUTE __cpu_indicator_init(void) {
} else
__cpu_model.__cpu_vendor = VENDOR_OTHER;
+#if __STDC_HOSTED__
assert(__cpu_model.__cpu_vendor < VENDOR_MAX);
assert(__cpu_model.__cpu_type < CPU_TYPE_MAX);
assert(__cpu_model.__cpu_subtype < CPU_SUBTYPE_MAX);
+#endif // __STDC_HOSTED__
return 0;
}