Skip to content

Commit

Permalink
WiP: have modules built to be optimized for space (-Os)
Browse files Browse the repository at this point in the history
Adresses @easrentai suggestion to pass modules build optimization for space here: linuxboot#590 (comment)

Uniformized module's $(CROSS_TOOLS) being passed as environment variable, prior of ./configure call

Limitations:
- busybox don't seem to take Os into consideration when applied, no change to module yet.
- kexec applies both O2 and Os, no change to module yet.
- Kernel is already optimized for size (CONFIG_CC_OPTIMIZE_FOR_SIZE as Kconfig option), and kernel modules stripped prior of inserted in initrd, compressed with xz. Nothing else can be done here unless lto

Next steps:
- Go LTO for kernel and modules? But, I was not successful going that way in the past, maybe musl-cross-make has changed.
- Not sure if I read correctly, but -Oz may have happened under GCC 12.1, but not sure if apple relative or FSS GCC. Opened an issue over musl-cross-make, but the project is conservative on used GCC version.

Attempt to contribute to linuxboot#590 by reducing payload's footprint
  • Loading branch information
tlaurion committed Feb 22, 2023
1 parent 88b590a commit d45e20f
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions modules/busybox
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ busybox_configure := $(MAKE) CC="$(heads_cc)" oldconfig
busybox_config := config/busybox.config
busybox_output := busybox
busybox_target := \
HOSTCXXFLAGS="-Os" \
$(CROSS_TOOLS) \
$(MAKE_JOBS) \

Expand Down
2 changes: 1 addition & 1 deletion modules/flashrom
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ flashrom_target := \
INSTALL="$(INSTALL)" \
DESTDIR="$(INSTALL)" \
LIBS_BASE="$(INSTALL)" \
CFLAGS="-I$(INSTALL)/include/libusb-1.0 -I$(INSTALL)/include/pci" \
CFLAGS="-Os -I$(INSTALL)/include/libusb-1.0 -I$(INSTALL)/include/pci" \
LDFLAGS="-L$(INSTALL)/lib" \
$(flashrom_cfg) \
$(CROSS_TOOLS) \
Expand Down
2 changes: 1 addition & 1 deletion modules/flashtools
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ flashtools_hash := 81b3c1f12318bd2942b426a99638e23d24e85819227653cd3b9302fbfc43b

flashtools_target := \
$(CROSS_TOOLS) \
CFLAGS="-I$(INSTALL)/include" \
CFLAGS="-Os -I$(INSTALL)/include" \
LDFLAGS="-L$(INSTALL)/lib" \

flashtools_output := \
Expand Down
4 changes: 3 additions & 1 deletion modules/kexec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ kexec_tar := kexec-tools-$(kexec_version).tar.gz
kexec_url := https://kernel.org/pub/linux/utils/kernel/kexec/$(kexec_tar)
kexec_hash := 40623d4321be2865ef9ea2cd6ec998d31dcf93d0f74353cbd3aa06d8821e3e41

kexec_configure := ./configure \
kexec_configure := \
CFLAGS="-g -Os -fno-strict-aliasing -Wall -Wstrict-prototypes" \
./configure \
$(CROSS_TOOLS) \
--host $(MUSL_ARCH)-elf-linux \
--target $(MUSL_ARCH) \
Expand Down
4 changes: 3 additions & 1 deletion modules/libusb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ libusb_url := https://downloads.sourceforge.net/project/libusb/libusb-1.0/libusb
libusb_url := https://github.com/libusb/libusb/releases/download/v$(libusb_version)/$(libusb_tar)
libusb_hash := 7dce9cce9a81194b7065ee912bcd55eeffebab694ea403ffb91b67db66b1824b

libusb_configure := ./configure\
libusb_configure := \
CFLAGS="-Os" \
./configure \
$(CROSS_TOOLS)\
--host $(MUSL_ARCH)-elf-linux\
--prefix "/"\
Expand Down
4 changes: 3 additions & 1 deletion modules/libusb-compat
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ libusb-compat_tar := libusb-compat-$(libusb-compat_version).tar.bz2
libusb-compat_url := https://downloads.sourceforge.net/project/libusb/libusb-compat-0.1/libusb-compat-$(libusb-compat_version)/$(libusb-compat_tar)
libusb-compat_hash := 404ef4b6b324be79ac1bfb3d839eac860fbc929e6acb1ef88793a6ea328bc55a

libusb-compat_configure := ./configure \
libusb-compat_configure := \
CFLAGS="-Os" \
./configure \
$(CROSS_TOOLS) \
--host $(MUSL_ARCH)-elf-linux \
--prefix "/" \
Expand Down
3 changes: 2 additions & 1 deletion modules/newt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ newt_output := \
newt_libraries := \
libnewt.so.0.52 \

newt_configure := ./autogen.sh; ./configure \
newt_configure := \
./autogen.sh && CFLAGS="-Os" ./configure \
$(CROSS_TOOLS) \
--prefix "/" \
--host $(MUSL_ARCH)-elf-linux \
Expand Down
4 changes: 3 additions & 1 deletion modules/npth
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ npth_tar := npth-$(npth_version).tar.bz2
npth_url := https://gnupg.org/ftp/gcrypt/npth/$(npth_tar)
npth_hash := 1393abd9adcf0762d34798dc34fdcf4d0d22a8410721e76f1e3afcd1daa4e2d1

npth_configure := ./configure \
npth_configure := \
CFLAGS="-Os" \
./configure \
$(CROSS_TOOLS) \
--host $(MUSL_ARCH)-linux-musl \
--prefix "/" \
Expand Down
4 changes: 3 additions & 1 deletion modules/qrencode
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ qrencode_hash := e794e26a96019013c0e3665cb06b18992668f352c5553d0a553f5d144f7f2a7

qrencode_libraries := .libs/libqrencode.so.3

qrencode_configure := ./configure \
qrencode_configure := \
CFLAGS="-Os" \
./configure \
$(CROSS_TOOLS) \
--prefix "/" \
--without-tools \
Expand Down

0 comments on commit d45e20f

Please sign in to comment.