Skip to contentSkip to conversation

objtool: Also include tools/include/uapi

PATCH RESEND Applied HONG Yifan 2 participants 2 messages Oct 8, 2024 – Oct 9, 2024 objtool

lore
Share & tools
lore

HONG Yifan

author
#0 lore raw

PATCH RESEND 1/1 objtool: Also include tools/include/uapi

When building objtool against a sysroot that contains a stripped down version of the UAPI headers, the following error happens:

In file included from arch/x86/decode.c:10:
In file included from .../tools/arch/x86/include/asm/insn.h:10:
In file included from <sysroot>/include/asm/byteorder.h:9:
In file included from <sysroot>/include/linux/byteorder/little_endian.h:15:
In file included from <sysroot>/include/linux/stddef.h:9:
In file included from .../tools/include/linux/compiler_types.h:36:
.../tools/include/linux/compiler-gcc.h:3:2: error: "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
3 | #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
| ^
1 error generated.

As hinted by the error, this is because <sysroot>/include/linux/stddef.h (a stripped-down version of uapi/include/linux/stddef.h) includes linux/compiler_types.h directly. However, this gets resolved to tools/include/linux/compiler_types.h, which is not expected to be included directly.

To resolve this, I added tools/include/uapi to the include paths when building objtool. With this trick, linux/stddef.h is resolved to tools/include/uapi/linux/stddef.h, which doesn't include linux/compiler_types.h.

---
 tools/objtool/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/objtool/Makefile +1 -0
index bf7f7f84ac62..f56e27727534 100644
@@ -24,6 +24,7 @@ LIBELF_LIBS  := $(shell $(HOSTPKG_CONFIG) libelf --libs 2>/dev/null || echo -lel
 all: $(OBJTOOL)
 
 INCLUDES := -I$(srctree)/tools/include \
+	    -I$(srctree)/tools/include/uapi \
 	    -I$(srctree)/tools/arch/$(HOSTARCH)/include/uapi \
 	    -I$(srctree)/tools/arch/$(SRCARCH)/include	\
 	    -I$(srctree)/tools/objtool/include \
Signature · 1 line
2.46.0.662.g92d0881bb0-goog
maintainer Applied
#1 lore raw
Quoted 20 lines · HONG Yifan

When building objtool against a sysroot that contains a stripped down version of the UAPI headers, the following error happens:

In file included from arch/x86/decode.c:10:
In file included from .../tools/arch/x86/include/asm/insn.h:10:
In file included from <sysroot>/include/asm/byteorder.h:9:
In file included from <sysroot>/include/linux/byteorder/little_endian.h:15:
In file included from <sysroot>/include/linux/stddef.h:9:
In file included from .../tools/include/linux/compiler_types.h:36:
.../tools/include/linux/compiler-gcc.h:3:2: error: "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
3 | #error "Please don't include <linux/compiler-gcc.h> directly, include <linux/compiler.h> instead."
| ^
1 error generated.

As hinted by the error, this is because <sysroot>/include/linux/stddef.h (a stripped-down version of uapi/include/linux/stddef.h) includes linux/compiler_types.h directly. However, this gets resolved to tools/include/linux/compiler_types.h, which is not expected to be included directly.

Quoted 6 lines

To resolve this, I added tools/include/uapi to the include paths when building objtool. With this trick, linux/stddef.h is resolved to tools/include/uapi/linux/stddef.h, which doesn't include linux/compiler_types.h.

Queued, thanks!

Signature · 1 line
Josh