Skip to contentSkip to conversation

linux: strip installed modules

PATCH Superseded Mike Frysinger 3 participants 8 messages Nov 16, 2010 – Nov 24, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 linux: strip installed modules

The installed kernel modules should have useless build cruft stripped out of them. On my system, a default build went from a very unreasonable 30MB to a normal 3MB (on disk) and from 14MB to 3MB when compressed due to the info stored in the kernel modules alone.

---
 linux/linux.mk |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
linux/linux.mk +2 -0
index 4a6025c..69cab9f 100644
@@ -135,6 +135,8 @@ $(LINUX26_DIR)/.stamp_installed: $(LINUX26_DIR)/.stamp_compiled
 	@if [ $(shell grep -c "CONFIG_MODULES=y" $(LINUX26_DIR)/.config) != 0 ] ; then 	\
 		$(TARGET_MAKE_ENV) $(MAKE1) $(LINUX26_MAKE_FLAGS) -C $(@D) 		\
 			INSTALL_MOD_PATH=$(TARGET_DIR) modules_install ;		\
+		find $(TARGET_DIR)/lib/modules/$(LINUX26_VERSION_PROBED) -type f -name "*o" | \
+			xargs -r $(TARGET_CROSS)strip -R .comment -R .note -g --strip-unneeded ; \
 		rm -f $(TARGET_DIR)/lib/modules/$(LINUX26_VERSION_PROBED)/build ;	\
 		rm -f $(TARGET_DIR)/lib/modules/$(LINUX26_VERSION_PROBED)/source ;	\
 	fi
Signature · 1 line
1.7.3.2
#1 lore raw

PATCH 1/1 linux: strip installed modules

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Mike" == Mike Frysinger <[email protected]> writes:

Mike> The installed kernel modules should have useless build cruft stripped out Mike> of them. On my system, a default build went from a very unreasonable 30MB Mike> to a normal 3MB (on disk) and from 14MB to 3MB when compressed due to the Mike> info stored in the kernel modules alone.

Thanks. We're moving away from per-package stripping though, so I would prefer to add it to the toplevel target-finalize step instead though - E.G. something like

find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | xargs $(STRIPCMD) ..

Care to adjust the patch to do that instead?

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH v2 1/1 linux: strip installed modules

The installed kernel modules should have useless build cruft stripped out of them. On my system, a default build went from a very unreasonable 30MB to a normal 3MB (on disk) and from 14MB to 3MB when compressed due to the info stored in the kernel modules alone.

---
v2
- move to toplevel finalize target

 Makefile |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Makefile +3 -0
index e569a94..0396e37 100644
@@ -403,6 +403,9 @@ ifneq ($(BR2_HAVE_DOCUMENTATION),y)
 	rm -rf $(TARGET_DIR)/usr/share/gtk-doc
 endif
 	find $(TARGET_DIR) -type f -perm +111 | xargs $(STRIPCMD) 2>/dev/null || true
+	find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | \
+		xargs -r $(STRIPCMD) -R .comment -R .note -g --strip-unneeded
+
 	mkdir -p $(TARGET_DIR)/etc
 	# Mandatory configuration file and auxilliary cache directory
 	# for recent versions of ldconfig
Signature · 1 line
1.7.3.2
#3 lore raw

PATCH v2 1/1 linux: strip installed modules

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Mike" == Mike Frysinger <[email protected]> writes:

Mike> The installed kernel modules should have useless build cruft Mike> stripped out of them. On my system, a default build went from a Mike> very unreasonable 30MB to a normal 3MB (on disk) and from 14MB to Mike> 3MB when compressed due to the info stored in the kernel modules Mike> alone.

Committed with a small change to not use binutils strip specific options (we support sstrip as well).

Signature · 1 line
Bye, Peter Korsgaard
#4 lore raw

PATCH v2 1/1 linux: strip installed modules

Quoted 9 lines · On Wednesday, November 24, 2010 16:04:40 Peter Korsgaard wrote:
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Mike" == Mike Frysinger <[email protected]> writes:

Mike> The installed kernel modules should have useless build cruft Mike> stripped out of them. On my system, a default build went from a Mike> very unreasonable 30MB to a normal 3MB (on disk) and from 14MB to Mike> 3MB when compressed due to the info stored in the kernel modules Mike> alone.

Committed with a small change to not use binutils strip specific options (we support sstrip as well).

so STRIP_STRIP_UNNEEDED should have those flags added to it for the binutils case ... i'll send a patch to fix that. otherwise we're leaving a crap in the target fs that only takes up space.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20101124/ba504b95/attachment.pgp>

#5 lore raw

PATCH v2 1/1 linux: strip installed modules

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Mike" == Mike Frysinger <[email protected]> writes:

Hi,

Quoted 2 lines
Quoted 2 lines

Committed with a small change to not use binutils strip specific options (we support sstrip as well).

Mike> so STRIP_STRIP_UNNEEDED should have those flags added to it for Mike> the binutils case ... i'll send a patch to fix that. otherwise Mike> we're leaving a crap in the target fs that only takes up space. Mike> -mike

STRIPCMD already has --remove-section=.comment --remove-section=.note, what else are you missing?

Signature · 1 line
Bye, Peter Korsgaard
#6 lore raw

PATCH v2 1/1 linux: strip installed modules

Quoted 10 lines · On Wednesday, November 24, 2010 16:36:25 Peter Korsgaard wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Mike" == Mike Frysinger <[email protected]> writes:

Committed with a small change to not use binutils strip specific options (we support sstrip as well).

Mike> so STRIP_STRIP_UNNEEDED should have those flags added to it for Mike> the binutils case ... i'll send a patch to fix that. otherwise Mike> we're leaving a crap in the target fs that only takes up space.

STRIPCMD already has --remove-section=.comment --remove-section=.note, what else are you missing?

i hadnt noticed that. guess you can ignore my new patch too.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20101124/5a233ead/attachment.pgp>

#7 lore raw

PATCH 1/1 linux: strip installed modules

In reply to Peter Korsgaard
Quoted 7 lines · On Wed, 17 Nov 2010 21:51:44 +0100 Peter Korsgaard <[email protected]> wrote:

Mike> The installed kernel modules should have useless build cruft stripped out Mike> of them. On my system, a default build went from a very unreasonable 30MB Mike> to a normal 3MB (on disk) and from 14MB to 3MB when compressed due to the Mike> info stored in the kernel modules alone.

Thanks. We're moving away from per-package stripping though, so I would prefer to add it to the toplevel target-finalize step instead though -

Actually, yes and now. The stripping will go back into per-package, but inside the package infrastructure instead. This is because we want to do all the cleanup (documentation, headers, useless .a and .la files) right after the package installation in order to make the "package management" stuff work (this is something that Lionel already did in his experiments of package management). So it will not be inside each package .mk file as it used to be, but it's still going to be done on a per-package basis.

Quoted 1 line

find $(TARGET_DIR)/lib/modules -type f -name '*.ko' | xargs $(STRIPCMD) ..

In this particular case, the stripping is very much kernel-specific, so I don't see a strong reason of adding this to linux/linux.mk. Except maybe packages that do compile additional kernel modules, such as linux-fusion (and more could be added).

Thomas

Signature · 4 lines
Thomas Petazzoni, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com