pc-bios/s390-ccw: Optimize the s390-ccw bios for size
PATCH 1/1 pc-bios/s390-ccw: Optimize the s390-ccw bios for size
Since we're storing the firmware blobs in the QEMU git repository, it would be nice if the blobs would be a little bit smaller. By using -Os and -fno-asynchronous-unwind-tables the size of the s390-ccw.img can be decreased by ca. 4kB, and the size of s390-netboot.img even by ca. 45kB. The change of speed of the firmware should not really matter compared to a binary that has been compiled with -O2 since the firmware still starts very fast.
--- pc-bios/s390-ccw/Makefile | 1 + 1 file changed, 1 insertion(+)
pc-bios/s390-ccw/Makefile +1 -0
@@ -13,6 +13,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ virtio.o virtio-scsi.o virtio-blkdev.o libc.o QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += -Os -fno-asynchronous-unwind-tables QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
Signature · 1 line
1.8.3.1
Quoted 20 lines · Thomas Huth
Since we're storing the firmware blobs in the QEMU git repository, it would be nice if the blobs would be a little bit smaller. By using -Os and -fno-asynchronous-unwind-tables the size of the s390-ccw.img can be decreased by ca. 4kB, and the size of s390-netboot.img even by ca. 45kB. The change of speed of the firmware should not really matter compared to a binary that has been compiled with -O2 since the firmware still starts very fast.
Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/Makefile | 1 + 1 file changed, 1 insertion(+)pc-bios/s390-ccw/Makefile +0
-0
pc-bios/s390-ccw/Makefile OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ · line 16
Quoted 4 lines
pc-bios/s390-ccw/Makefile +1
-0@@ -13,6 +13,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ virtio.o virtio-scsi.o virtio-blkdev.o libc.o QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += -Os -fno-asynchronous-unwind-tables
Hmm, it looks like that the O2 comes after Os for me (which would override Os).
cc -iquote /home/cborntra/REPOS/qemu/build/. -iquote . -iquote /home/cborntra/REPOS/qemu/tcg -iquote /home/cborntra/REPOS/qemu/tcg/s390 -I/home/cborntra/REPOS/qemu/linux-headers -I/home/cborntra/REPOS/qemu/build/linux-headers -iquote . -iquote /home/cborntra/REPOS/qemu -iquote /home/cborntra/REPOS/qemu/accel/tcg -iquote /home/cborntra/REPOS/qemu/include -Werror -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -Wexpansion-to-defined -Wendif-labels -Wno-shift-negative-value -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -Os -fno-asynchronous-unwind-tables -ffreestanding -fno-delete-null-pointer-checks -msoft-float -march=z900 -fPIE -fno-strict-aliasing -fno-stack-protector -MMD -MP -MT libc.o -MF ./libc.d -O2 -g -c -o libc.o /home/cborntra/REPOS/qemu/pc-bios/s390-ccw/libc.c
so the effect is only because of the -fno-asynchronous-unwind-tables.
Quoted 4 lines
pc-bios/s390-ccw/Makefile +0
-0QEMU_CFLAGS += -ffreestanding -fno-delete-null-pointer-checks -msoft-float QEMU_CFLAGS += -march=z900 -fPIE -fno-strict-aliasing QEMU_CFLAGS += $(call cc-option, $(QEMU_CFLAGS), -fno-stack-protector)
Quoted 24 lines · Christian Borntraeger
Quoted 22 lines · Thomas Huth
Since we're storing the firmware blobs in the QEMU git repository, it would be nice if the blobs would be a little bit smaller. By using -Os and -fno-asynchronous-unwind-tables the size of the s390-ccw.img can be decreased by ca. 4kB, and the size of s390-netboot.img even by ca. 45kB. The change of speed of the firmware should not really matter compared to a binary that has been compiled with -O2 since the firmware still starts very fast.
Signed-off-by Thomas Huth <[email protected]>--- pc-bios/s390-ccw/Makefile | 1 + 1 file changed, 1 insertion(+)pc-bios/s390-ccw/Makefile +0
-0@@ -13,6 +13,7 @@ OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ virtio.o virtio-scsi.o virtio-blkdev.o libc.o
Quoted 8 lines
pc-bios/s390-ccw/Makefile OBJECTS = start.o main.o bootmap.o jump2ipl.o sclp.o menu.o \ · line 16
Quoted 2 lines
pc-bios/s390-ccw/Makefile +1
-0QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) +QEMU_CFLAGS += -Os -fno-asynchronous-unwind-tablesHmm, it looks like that the O2 comes after Os for me (which would override Os).
cc -iquote
/home/cborntra/REPOS/qemu/build/. -iquote . -iquote/home/cborntra/REPOS/qemu/tcg-iquote/home/cborntra/REPOS/qemu/tcg/s390-I/home/cborntra/REPOS/qemu/linux-headers -I/home/cborntra/REPOS/qemu/build/linux-headers -iquote . -iquote/home/cborntra/REPOS/qemu-iquote/home/cborntra/REPOS/qemu/accel/tcg-iquote/home/cborntra/REPOS/qemu/include-Werror -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -Wexpansion-to-defined -Wendif-labels -Wno-shift-negative-value -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -Os -fno-asynchronous-unwind-tables -ffreestanding -fno-delete-null-pointer-checks -msoft-float -march=z900 -fPIE -fno-strict-aliasing -fno-stack-protector -MMD -MP -MT libc.o -MF ./libc.d -O2 -g -c -o libc.o/home/cborntra/REPOS/qemu/pc-bios/s390-ccw/libc.cso the effect is only because of the -fno-asynchronous-unwind-tables.
Ugh, you're right - at least for the objects for s390-ccw.img. Seems like the -O2 comes from "CFLAGS" and not from "QEMU_CFLAGS" here, so the flags should be added to the CFLAGS variable instead.
Actually, I was only looking at the object files from s390-netboot.img, and the libc files from SLOF get *only* compiled with QEMU_CFLAGS there (see LIBC_CFLAGS in netboot.mak). So the huge part of the s390-netboot.img binary got compiled without optimizations so far! That's why I was seeing such a big improvement there! Wow, I wonder why we did not notice this before... Anyway, I'll send a v2 to fix these issues.
Thomas