diff mbox series

[01/12] kconfig: implement CONFIG_HEADERS_INSTALL for Usermode Linux

Message ID 20250217-kunit-kselftests-v1-1-42b4524c3b0a@linutronix.de
State Accepted
Commit 268d191abc57a89f4ed92efcb276aae54f86c88c
Headers show
Series [01/12] kconfig: implement CONFIG_HEADERS_INSTALL for Usermode Linux | expand

Commit Message

Thomas Weißschuh Feb. 17, 2025, 10:59 a.m. UTC
userprogs sometimes need access to UAPI headers.
This is currently not possible for Usermode Linux, as UM is only
a pseudo architecture built on top of a regular architecture and does
not have its own UAPI.
Instead use the UAPI headers from the underlying regular architecture.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 Makefile          | 5 ++++-
 lib/Kconfig.debug | 1 -
 2 files changed, 4 insertions(+), 2 deletions(-)

Comments

Masahiro Yamada March 4, 2025, 7:23 p.m. UTC | #1
On Mon, Feb 17, 2025 at 8:00 PM Thomas Weißschuh
<thomas.weissschuh@linutronix.de> wrote:
>
> userprogs sometimes need access to UAPI headers.
> This is currently not possible for Usermode Linux, as UM is only
> a pseudo architecture built on top of a regular architecture and does
> not have its own UAPI.
> Instead use the UAPI headers from the underlying regular architecture.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

Applied to linux-kbuild with the subject prefix fixed.


What concerned me was that this patch creates
multiple paths to visit the same directory.


[1]
ARCH=um archheaders
  -> ARCH=x86 archheaders
    -> arch/x86/entry/syscalls/

[2]
ARCH=um headers
  -> ARCH=x86 headers
    -> depends on ARCH=x86 archheaders
      -> arch/x86/entry/syscalls/


After carefully reviewing the code, I was convinced that
this is not a race condition.
(I am particularly cautious about race conditions in parallel builds
and try my best to avoid such code.)








--
Best Regards
Masahiro Yamada
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index b4c208ae4041c1f4e32c2a158322422ce7353d06..275185d2ff5d3dc99bd7982abd1de85af0b9621a 100644
--- a/Makefile
+++ b/Makefile
@@ -1357,9 +1357,12 @@  hdr-inst := -f $(srctree)/scripts/Makefile.headersinst obj
 
 PHONY += headers
 headers: $(version_h) scripts_unifdef uapi-asm-generic archheaders archscripts
-	$(if $(filter um, $(SRCARCH)), $(error Headers not exportable for UML))
+ifdef HEADER_ARCH
+	$(Q)$(MAKE) -f $(srctree)/Makefile HEADER_ARCH= SRCARCH=$(HEADER_ARCH) headers
+else
 	$(Q)$(MAKE) $(hdr-inst)=include/uapi
 	$(Q)$(MAKE) $(hdr-inst)=arch/$(SRCARCH)/include/uapi
+endif
 
 ifdef CONFIG_HEADERS_INSTALL
 prepare: headers
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
index 1af972a92d06f6e3f7beec4bd086c00b412c83ac..60026c8388db82c0055ccd8b8ac8789d6b939b62 100644
--- a/lib/Kconfig.debug
+++ b/lib/Kconfig.debug
@@ -473,7 +473,6 @@  config READABLE_ASM
 
 config HEADERS_INSTALL
 	bool "Install uapi headers to usr/include"
-	depends on !UML
 	help
 	  This option will install uapi headers (headers exported to user-space)
 	  into the usr/include directory for use during the kernel build.