Skip to contentSkip to conversation

tools/x86: Support clang compilation for Android

PATCH New Kaushlendra Kumar 1 participant 1 message Nov 7, 2025 x86 cpuid database

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/x86: Support clang compilation for Android

Add missing stdint.h include and replace compiler-gcc.h with compiler.h to fix clang compilation errors on Android builds. Change u64 typedef to use standard uint64_t with header guards to maintain backward compatibility with existing Linux builds.

This resolves clang build failures where uint64_t is undefined and ensures the tool compiles on both Android NDK and Linux toolchains.

---
 tools/arch/x86/kcpuid/kcpuid.c       | 5 ++++-
 tools/include/linux/compiler_types.h | 2 +-
 2 files changed, 5 insertions(+), 2 deletions(-)
tools/arch/x86/kcpuid/kcpuid.c +4 -1
index 7dc6b9235d02..5243b49556be 100644
@@ -7,6 +7,7 @@
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <string.h>
 
 #define ARRAY_SIZE(x)	(sizeof(x) / sizeof((x)[0]))
@@ -14,7 +15,9 @@
 #define __noreturn	__attribute__((__noreturn__))
 
 typedef unsigned int u32;
-typedef unsigned long long u64;
+#ifndef u64
+#define u64 uint64_t
+#endif
 
 char *def_csv = "/usr/share/misc/cpuid.csv";
 char *user_csv;
tools/include/linux/compiler_types.h +1 -1
index d09f9dc172a4..0333c234fe3d 100644
@@ -33,7 +33,7 @@
 
 /* Compiler specific macros. */
 #ifdef __GNUC__
-#include <linux/compiler-gcc.h>
+#include <linux/compiler.h>
 #endif
 
 #ifndef asm_goto_output
Signature · 1 line
2.34.1