6

I haven't compiled Linux kernels in a couple of years, and now that I started doing so again I discovered that modules are installed with debug symbols by default unless INSTALL_MOD_STRIP=1 is passed to make modules_install, which makes them so enormous that my initrd images grew to be hundreds of megabytes.

I only found the INSTALL_MOD_STRIP option after googling around quite a bit, and even then only in forum threads where people ask why their modules are so large.

So I'm wondering, what is the reason this changed in the while I used precompiled kernels? Is there a reason modules are now installed with debug symbols by default (even though binary distributions still strip them off)? It seems rather esoteric to use debug symbols in the kernel, and it obviously has very large drawbacks in terms of installed size.

Basically, should I just consider INSTALL_MOD_STRIP as a part of the standard kernel compilation formula? Are there any other changes to the build process from around ~2.6.25 that I should be aware of?

4
  • That's quite a broad question, in short I'd say if you find yourself hand-crafting a kernel build you're either a module/kernel developer or you know what you're doing. Documentation/kbuild/*.txt should bring you up to date re the actual build process
    – hroptatyr
    Jan 22, 2014 at 7:24
  • Jesus Christ, you weren't kidding! I thought my system had hung at boot but it was just grub choking to death trying to load a half a gigabyte initramfs!
    – psusi
    Mar 23, 2021 at 20:20
  • Not stripping could also lead to the grub error: error: can't allocate initrd
    – Rufus
    Apr 13, 2021 at 5:25
  • If you pass the INSTALL_MOD_STRIP=1 setting and you are using automatic module signing, does the stripping happen before or after automatic module signing? kernel.org/doc/html/latest/admin-guide/module-signing.html
    – Shawn Eary
    Mar 9, 2022 at 20:21

1 Answer 1

3

I'm just posting the log message from the relevant patch to answer your question who/why it got changed:

commit 2ea038917bbdd51a7ae4a898c6a04641324dd033
Author: Sam Ravnborg <[email protected]>
Date:   Wed Jan 14 21:38:20 2009 +0100

Revert "kbuild: strip generated symbols from *.ko"

This reverts commit ad7a953c522ceb496611d127e51e278bfe0ff483.

And commit: ("allow stripping of generated symbols under CONFIG_KALLSYMS_ALL")
            9bb482476c6c9d1ae033306440c51ceac93ea80c

These stripping patches has caused a set of issues:

1) People have reported compatibility issues with binutils due to
   lack of support for `--strip-unneeded-symbols' with objcopy 2.15.92.0.2
   Reported by: Wenji
2) ccache and distcc no longer works as expeced
   Reported by: Ted, Roland, + others
3) The installed modules increased a lot in size
   Reported by: Ted, Davej + others

Reported-by: Wenji Huang <[email protected]>
Reported-by: "Theodore Ts'o" <[email protected]>
Reported-by: Dave Jones <[email protected]>
Reported-by: Roland McGrath <[email protected]>
Signed-off-by: Sam Ravnborg <[email protected]>
7
  • Thanks for the idea to trace the history of the changes. I'll be doing that, but so far it doesn't seem to answer my basic question; namely what the rational for including debug symbols by default is, and why stripping installed modules is not the default behavior.
    – Dolda2000
    Jan 25, 2014 at 4:39
  • Well in general it does no harm (apart from making the binary larger, which admittedly in the case of the kernel is a valid point), it's not the default behaviour because of the 3 reasons mentioned: incompatibility with binutils, ccache and distcc problems and despite being stripped the modules increase in size
    – hroptatyr
    Jan 27, 2014 at 6:28
  • That does not seem quite true. The commit you quoted only reverts changes to the stripping behavior, but INSTALL_MOD_STRIP existed long before that. As far as I can tell, it was introduced in commit ac031f26e8, which only mentions it as the solution to the problem of huge modules.
    – Dolda2000
    Jan 27, 2014 at 6:36
  • Also, I should mention that, at least as far as I remember (though it's been a while by now), the reason I had to go and find INSTALL_MOD_STRIP to begin with was that my initrd images grew so large without it that Grub wouldn't even accept them, in which case it's not entirely true that not stripping "does no harm".
    – Dolda2000
    Jan 27, 2014 at 6:37
  • 1
    Really? My initramfs was over half a GB until I added this flag and it went back down to ~40 MB. At that size, grub either can't load it, or it will take longer than the 2-3 minutes I'm willing to wait before giving up and hard booting.
    – psusi
    Mar 23, 2021 at 20:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .