Skip to contentSkip to conversation

kbuild: Add vmlinux_install to facilitate debugging

PATCH In review Zach Wade 2 participants 3 messages Oct 7, 2024 – Oct 8, 2024 Kbuild

lore
Share & tools
lore

Zach Wade

author
#0 lore raw

PATCH 1/1 kbuild: Add vmlinux_install to facilitate debugging

When testing multiple versions of the kernel with the same source code,it is often necessary to recompile the kernel, which is time-consuming for small hosts. I need to cp vmlinux to the corresponding module directory. I think adding this will make debugging the kernel a little more convenient.

---
 Makefile | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Makefile +14 -0
index c5493c0c0ca1..1caab011599f 100644
@@ -1579,6 +1579,7 @@ help:
 	@echo  '* vmlinux	  - Build the bare kernel'
 	@echo  '* modules	  - Build all modules'
 	@echo  '  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
+	@echo  '  vmlinux_install - Install vmlinux to INSTALL_MOD_PATH (default: /)'
 	@echo  '  vdso_install    - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
 	@echo  '  dir/            - Build all files in dir and below'
 	@echo  '  dir/file.[ois]  - Build specified target only'
@@ -1887,6 +1888,19 @@ modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
 	 $(if $(KBUILD_MODULES), modules_check)
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
+# ---------------------------------------------------------------------------
+# vmlinux install
+
+PHONY += vmlinux_install
+
+vmlinux_install:
+	@if [ -f vmlinux ]; then \
+		echo "INSTALL ${MODLIB}/vmlinux"; \
+		cp -f vmlinux ${MODLIB}/ ; \
+	else \
+		echo "vmlinux file does not exist."; \
+	fi
+
 # Single targets
 # ---------------------------------------------------------------------------
 # To build individual files in subdirectories, you can do like this:
Signature · 1 line
2.46.0
author
#1 lore raw
Quoted 33 lines · Zach Wade

When testing multiple versions of the kernel with the same source code,it is often necessary to recompile the kernel, which is time-consuming for small hosts. I need to cp vmlinux to the corresponding module directory. I think adding this will make debugging the kernel a little more convenient.

---
  Makefile | 14 ++++++++++++++
  1 file changed, 14 insertions(+)
Makefile +7 -0
index c5493c0c0ca1..1caab011599f 100644
@@ -1579,6 +1579,7 @@ help:
  	@echo  '* vmlinux	  - Build the bare kernel'
  	@echo  '* modules	  - Build all modules'
  	@echo  '  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
+	@echo  '  vmlinux_install - Install vmlinux to INSTALL_MOD_PATH (default: /)'
  	@echo  '  vdso_install    - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
  	@echo  '  dir/            - Build all files in dir and below'
  	@echo  '  dir/file.[ois]  - Build specified target only'
@@ -1887,6 +1888,19 @@ modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
  	 $(if $(KBUILD_MODULES), modules_check)
  	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
+# ---------------------------------------------------------------------------
+# vmlinux install
+
+PHONY += vmlinux_install
+
+vmlinux_install:

Makefile modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \ · line 1906

Quoted 10 lines
Makefile +7 -0
+	@if [ -f vmlinux ]; then \
+		echo "INSTALL ${MODLIB}/vmlinux"; \
+		cp -f vmlinux ${MODLIB}/ ; \
+	else \
+		echo "vmlinux file does not exist."; \
+	fi
+
  # Single targets
  # ---------------------------------------------------------------------------
  # To build individual files in subdirectories, you can do like this:

Hi Masahiro Yamada,

I think this patch will make me feel comfortable, so I submitted this change.
However, this submission may not be perfect. I just put forward my ideas. If you think it can be added, you are welcome to point out the parts that need to be modified. I will fix them as required and resubmit the v2 version.

Thanks,
Zach

#2 lore raw
In reply to Zach Wade
Quoted 31 lines · Zach Wade

When testing multiple versions of the kernel with the same source code,it is often necessary to recompile the kernel, which is time-consuming for small hosts. I need to cp vmlinux to the corresponding module directory. I think adding this will make debugging the kernel a little more convenient.

---
 Makefile | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Makefile +4 -0
index c5493c0c0ca1..1caab011599f 100644
@@ -1579,6 +1579,7 @@ help:
        @echo  '* vmlinux         - Build the bare kernel'
        @echo  '* modules         - Build all modules'
        @echo  '  modules_install - Install all modules to INSTALL_MOD_PATH (default: /)'
+       @echo  '  vmlinux_install - Install vmlinux to INSTALL_MOD_PATH (default: /)'
        @echo  '  vdso_install    - Install unstripped vdso to INSTALL_MOD_PATH (default: /)'
        @echo  '  dir/            - Build all files in dir and below'
        @echo  '  dir/file.[ois]  - Build specified target only'
@@ -1887,6 +1888,19 @@ modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \
         $(if $(KBUILD_MODULES), modules_check)
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
+# ---------------------------------------------------------------------------
+# vmlinux install
+

Makefile modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \ · line 1903

Quoted 10 lines
Makefile +10 -0
+PHONY += vmlinux_install
+
+vmlinux_install:
+       @if [ -f vmlinux ]; then \
+               echo "INSTALL ${MODLIB}/vmlinux"; \
+               cp -f vmlinux ${MODLIB}/ ; \
+       else \
+               echo "vmlinux file does not exist."; \
+       fi
+

This is a very niche use-case.
What if someone else wants to copy vmlinux to /boot/ instead of ${MODLIB}/ ?

People tend to have local scripts to meet personal demands. The upstream is not a place for that.

Quoted 7 lines
Makefile +0 -1
 # Single targets
 # ---------------------------------------------------------------------------
 # To build individual files in subdirectories, you can do like this:
--

2.46.0

Signature · 2 lines
Best Regards
Masahiro Yamada