[PATCH] sparse: predefine __ILP32__ and _ILP32 in 32-bit mode
Oleg Nesterov <[email protected]> Fri, 12 Jun 2026 12:27:25 +0200
| Newsgroups | org.kernel.vger.linux-sparse |
|---|---|
| Message-ID | <[email protected]> |
Unlike gcc, sparse doesn't define __ILP32__ in 32-bit mode: $ gcc -dM -E -m32 - </dev/null | grep LP32 #define __ILP32__ 1 #define _ILP32 1 $ ./sparse -dM -E -m32 - </dev/null | grep LP32 $ Because of this, arch/x86/include/uapi/asm/bitsperlong.h #if defined(__x86_64__) && !defined(__ILP32__) # define __BITS_PER_LONG 64 #else # define __BITS_PER_LONG 32 #endif wrongly defines __BITS_PER_LONG == 64 when sparse inspects the files in arch/x86/boot/. sparse treats -m16 like -m32 and this is fine for sparse/semind purposes, but without __ILP32__ the bitsperlong checks fail. For example, the following command $ make C=2 CHECK="semind add --" complains: ./include/asm-generic/bitsperlong.h:23:2: error: Inconsistent word size. Check asm/bitsperlong.h ./include/asm-generic/bitsperlong.h:27:33: error: static assertion failed: "Inconsistent word size. Check asm/bitsperlong.h" Change predefined_macros() to define __ILP32__ and _ILP32 for both ARCH_X32 and ARCH_LP32. Signed-off-by: Oleg Nesterov <[email protected]> --- predefine.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/predefine.c b/predefine.c index 5b0f0caf..28601aba 100644 --- a/predefine.c +++ b/predefine.c @@ -209,9 +209,8 @@ void predefined_macros(void) predefine("__pragma__", 0, NULL); switch (arch_m64) { - case ARCH_LP32: - break; case ARCH_X32: + case ARCH_LP32: predefine("__ILP32__", 1, "1"); predefine("_ILP32", 1, "1"); break; -- 2.52.0