Skip to contentSkip to conversation

package/linux-tools: selftests: Use KHDR_INCLUDES to locate the headers

PATCH Superseded Maxime Chevallier via buildroot 1 participant 6 messages Sep 5 – Oct 3

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/linux-tools: selftests: Use KHDR_INCLUDES to locate the headers

Since v6.7 [1], the KHDR_DIR variable isn't used anymore by the kernel selftest Makefiles to locate the kernel headers. Instead, KHDR_INCLUDES is used to specify their location.

Let's pass it with the "-isystem" flag, as is done in the default values used in the selftest makefiles.

[1]: 43e8832fed08 ("Revert "selftests: error out if kernel header files are not yet built"")

---
 package/linux-tools/linux-tool-selftests.mk.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
package/linux-tools/linux-tool-selftests.mk.in +1 -1
index db7e4fa1a3..f2f329c05f 100644
@@ -24,7 +24,7 @@ SELFTESTS_DEPENDENCIES = \
 SELFTESTS_MAKE_FLAGS = \
 	$(LINUX_MAKE_FLAGS) \
 	ARCH=$(SELFTESTS_ARCH) \
-	KHDR_DIR=$(LINUX_DIR)/usr/include
+	KHDR_INCLUDES="-isystem $(LINUX_DIR)/usr/include"
 
 LINUX_TOOLS_BIN_ARCH_EXCLUDE += \
 	/usr/lib/kselftests/tc-testing/
Signature · 6 lines
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hello Maxime,

Quoted 3 lines · Maxime Chevallier via buildroot

Since v6.7 [1], the KHDR_DIR variable isn't used anymore by the kernel selftest Makefiles to locate the kernel headers. Instead, KHDR_INCLUDES is used to specify their location.

But then doesn't that mean that the build would be broken for people who build Linux < 6.7 ? Keep in mind that the Linux kernel version in Buildroot is configurable, so not everyone is building the latest and greatest.

If that's the case, then maybe we need to keep both?

Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hi Thomas,

Quoted 11 lines · Thomas Petazzoni

Hello Maxime,

Quoted 3 lines · Maxime Chevallier via buildroot

Since v6.7 [1], the KHDR_DIR variable isn't used anymore by the kernel selftest Makefiles to locate the kernel headers. Instead, KHDR_INCLUDES is used to specify their location.

But then doesn't that mean that the build would be broken for people who build Linux < 6.7 ? Keep in mind that the Linux kernel version in Buildroot is configurable, so not everyone is building the latest and greatest.

Looking at the kernel history, the KHDR_DIR only existed between v6.4 and v6.7 :

Added in v6.4 :

9fc96c7c19df ("selftests: error out if kernel header files are not yet built")

Reverted in v6.7 :

43e8832fed08 ("Revert "selftests: error out if kernel header files are not yet built"")

And it looks like even between that v6.4 and v6.7 window, KHDR_DIR is just used to populate KHDR_INCLUDES :

tools/testing/selftests/lib.mk

[...]

  KHDR_INCLUDES := -isystem $(KHDR_DIR)

So I think this should work even on kernels older than v6.7, I haven't tried though ;(

I can add these details in the commit log in a resend if you want,

Maxime

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Hello,

Quoted 14 lines · Maxime Chevallier

Looking at the kernel history, the KHDR_DIR only existed between v6.4 and v6.7 :

Added in v6.4 :

9fc96c7c19df ("selftests: error out if kernel header files are not yet built")

Reverted in v6.7 :

43e8832fed08 ("Revert "selftests: error out if kernel header files are not yet built"")

And it looks like even between that v6.4 and v6.7 window, KHDR_DIR is just used to populate KHDR_INCLUDES :

Quoted 5 lines

tools/testing/selftests/lib.mk

[...]

  KHDR_INCLUDES := -isystem $(KHDR_DIR)

Ah good, so your change would potentially work across all kernel versions?

Quoted 2 lines

So I think this should work even on kernels older than v6.7, I haven't tried though ;(

Can we give it a quick try, just to make sure?

Quoted 1 line

I can add these details in the commit log in a resend if you want,

That would be awesome, thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
Quoted 4 lines · Thomas Petazzoni via buildroot
Quoted 2 lines

So I think this should work even on kernels older than v6.7, I haven't tried though ;(

Can we give it a quick try, just to make sure?

Gentle ping :-)

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw

Hi,

Quoted 8 lines · Thomas Petazzoni
Quoted 4 lines · Thomas Petazzoni via buildroot
Quoted 2 lines

So I think this should work even on kernels older than v6.7, I haven't tried though ;(

Can we give it a quick try, just to make sure?

Gentle ping :-)

Sorry for the delay :/

So I tried and unfortunately I was wrong, the KHDR_DIR variable has another use site, and without it the kselftests build fails on 6.6 :(

So we do need to keep both KHDR_IR and KHDR_INCLUDES, I've tested that and it works for at least 6.1, 6.6, 6.12 and upstream.

I'll spin another round somewhere on my way to OSS/LPC.

Thanks,

Maxime

Quoted 2 lines

Thomas

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot