Karmylr
December 31, 2023, 4:15am
1
How to set -O3 optimization for OpenWrt's Linux kernel when building firmware?
I was going to ask under Kernel optimization but it's already locked.
My settings now:
I execute ps -aux | grep cc1
and got /usr/lib/gcc/x86_64-linux-gnu/12/cc1 -quiet -I /home/conter/main/staging_dir/host/include -I /home/conter/main/staging_dir/host/include -I ./tools/include -imultiarch x86_64-linux-gnu -MMD scripts/.sorttable.d scripts/sorttable.c -quiet -dumpdir scripts/ -dumpbase sorttable.c -dumpbase-ext .c -mtune=generic -march=x86-64 -O2 -O2 -Wdeclaration-after-statement -Wall -Wmissing-prototypes -Wstrict-prototypes -std=gnu11 -fomit-frame-pointer -fasynchronous-unwind-tables -o /home/conter/main/tmp/ccTBjqZ6.s
which shows -O2
darksky
December 31, 2023, 2:59pm
2
Have you seen: https://openwrt.org/docs/guide-developer/packages.flags#overriding_build_options
I defined the following in my .config
CONFIG_BUSYBOX_CONFIG_EXTRA_CFLAGS="-march=znver3 -O3 -pipe"
CONFIG_KERNEL_CFLAGS="-march=znver3 -O3 -pipe"
And:
ps -aux | grep FLAG bash -c (cd /scratch/union/build_dir/target-x86_64_musl/linux-x86_64/grub-none/grub-2.06/./; if [ -x ./configure ]; then find /scratch/union/build_dir/target-x86_64_musl/linux-x86_64/grub-none/grub-2.06/ -name config.guess | xargs -r chmod u+w; find /scratch/union/build_dir/target-x86_64_musl/linux-x86_64/grub-none/grub-2.06/ -name config.guess | xargs -r -n1 cp --remove-destination /scratch/union/scripts/config.guess; find /scratch/union/build_dir/target-x86_64_musl/linux-x86_64/grub-none/grub-2.06/ -name config.sub | xargs -r chmod u+w; find /scratch/union/build_dir/target-x86_64_musl/linux-x86_64/grub-none/grub-2.06/ -name config.sub | xargs -r -n1 cp --remove-destination /scratch/union/scripts/config.sub; AR="x86_64-openwrt-linux-musl-gcc-ar" AS="x86_64-openwrt-linux-musl-gcc -c -march=znver3 -O3 -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/scratch/union/build_dir/target-x86_64_musl/linux-x86_64/grub-none/grub-2.06=grub-2.06 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro" LD="x86_64-openwrt-linux-musl-ld.bfd" NM="x86_64-openwrt-linux-musl-gcc-nm" CC="x86_64-openwrt-linux-musl-gcc" GCC="x86_64-openwrt-linux-musl-gcc" CXX="x86_64-openwrt-linux-musl-g++" RANLIB="x86_64-openwrt-linux-musl-gcc-ranlib" STRIP=x86_64-openwrt-linux-musl-strip OBJCOPY=x86_64-openwrt-linux-musl-objcopy OBJDUMP=x86_64-openwrt-linux-musl-objdump SIZE=x86_64-openwrt-linux-musl-size CFLAGS="-march=znver3 -O3 -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/scratch/union/build_dir/target-x86_64_musl/linux-x86_64/grub-none/grub-2.06=grub-2.06 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CXXFLAGS="-march=znver3 -O3 -pipe -fno-caller-saves -fno-plt -fhonour-copts -fmacro-prefix-map=/scratch/union/build_dir/target-x86_64_musl/linux-x86_64/grub-none/grub-2.06=grub-2.06 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro " CPPFLAGS="-I/scratch/union/staging_dir/toolchain-x86_64_gcc-12.3.0_musl/usr/include -I/scratch/union/staging_dir/toolchain-x86_64_gcc-12.3.0_musl/include -I/scratch/union/staging_dir/toolchain-x86_64_gcc-12.3.0_musl/include/fortify " LDFLAGS="-L/scratch/union/staging_dir/toolchain-x86_64_gcc-12.3.0_musl/usr/lib -L/scratch/union/staging_dir/toolchain-x86_64_gcc-12.3.0_musl/lib -fuse-ld=bfd -znow -zrelro " grub_build_mkfont_excuse="don't want fonts" ./configure --target=x86_64-openwrt-linux --host=x86_64-openwrt-linux --build=x86_64-pc-linux-gnu --disable-dependency-tracking --program-prefix="" --program-suffix="" --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --libexecdir=/usr/lib --sysconfdir=/etc --datadir=/usr/share --localstatedir=/var --mandir=/usr/man --infodir=/usr/info --disable-nls --target=x86_64-openwrt-linux-musl --disable-werror --disable-nls --disable-device-mapper --disable-libzfs --disable-liblzma --disable-grub-mkfont --with-platform=none ; fi; )