@@ -893,11 +893,20 @@ KBUILD_CFLAGS += -fno-delete-null-pointer-checks
893893ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE
894894KBUILD_CFLAGS += -O2
895895KBUILD_RUSTFLAGS += -Copt-level=2
896+ else ifdef CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3
897+ KBUILD_CFLAGS += -O3
898+ KBUILD_RUSTFLAGS += -Copt-level=3
896899else ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
897900KBUILD_CFLAGS += -Os
898901KBUILD_RUSTFLAGS += -Copt-level=s
899902endif
900903
904+ # Perform swing modulo scheduling immediately before the first scheduling pass.
905+ # This pass looks at innermost loops and reorders their instructions by
906+ # overlapping different iterations.
907+ KBUILD_CFLAGS += $(call cc-option,-fmodulo-sched -fmodulo-sched-allow-regmoves -fivopts)
908+ KBUILD_CFLAGS += $(call cc-option,-mllvm -enable-pipeliner)
909+
901910# Always set `debug-assertions` and `overflow-checks` because their default
902911# depends on `opt-level` and `debug-assertions`, respectively.
903912KBUILD_RUSTFLAGS += -Cdebug-assertions=$(if $(CONFIG_RUST_DEBUG_ASSERTIONS ) ,y,n)
@@ -1033,10 +1042,10 @@ export CC_FLAGS_SCS
10331042endif
10341043
10351044ifdef CONFIG_LTO_CLANG
1036- ifdef CONFIG_LTO_CLANG_THIN
1037- CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
1038- else
1045+ ifdef CONFIG_LTO_CLANG_FULL
10391046CC_FLAGS_LTO := -flto
1047+ else
1048+ CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit
10401049endif
10411050CC_FLAGS_LTO += -fvisibility=hidden
10421051
@@ -1255,7 +1264,7 @@ export ARCH_DRIVERS := $(drivers-y) $(drivers-m)
12551264KBUILD_VMLINUX_OBJS := built-in.a $(patsubst % /, % /lib.a, $(filter % /, $(libs-y ) ) )
12561265KBUILD_VMLINUX_LIBS := $(filter-out % /, $(libs-y ) )
12571266
1258- export KBUILD_VMLINUX_LIBS
1267+ export KBUILD_VMLINUX_OBJS KBUILD_VMLINUX_LIBS
12591268export KBUILD_LDS := arch/$(SRCARCH ) /kernel/vmlinux.lds
12601269
12611270ifdef CONFIG_TRIM_UNUSED_KSYMS
@@ -1264,16 +1273,12 @@ ifdef CONFIG_TRIM_UNUSED_KSYMS
12641273KBUILD_MODULES := y
12651274endif
12661275
1267- # '$(AR) mPi' needs 'T' to workaround the bug of llvm-ar <= 14
1268- quiet_cmd_ar_vmlinux.a = AR $@
1269- cmd_ar_vmlinux.a = \
1270- rm -f $@ ; \
1271- $(AR ) cDPrST $@ $(KBUILD_VMLINUX_OBJS ) ; \
1272- $(AR ) mPiT $$($(AR ) t $@ | sed -n 1p) $@ $$($(AR ) t $@ | grep -F -f $(srctree ) /scripts/head-object-list.txt)
1276+ PHONY += vmlinux_a
1277+ vmlinux_a : $(KBUILD_VMLINUX_OBJS ) scripts/head-object-list.txt FORCE
1278+ $(Q )$(MAKE ) -f $(srctree ) /scripts/Makefile.vmlinux_a
12731279
1274- targets += vmlinux.a
1275- vmlinux.a : $(KBUILD_VMLINUX_OBJS ) scripts/head-object-list.txt FORCE
1276- $(call if_changed,ar_vmlinux.a)
1280+ vmlinux.a : vmlinux_a
1281+ @:
12771282
12781283PHONY += vmlinux_o
12791284vmlinux_o : vmlinux.a $(KBUILD_VMLINUX_LIBS )
@@ -1652,6 +1657,7 @@ endif # CONFIG_MODULES
16521657CLEAN_FILES += vmlinux.symvers modules-only.symvers \
16531658 modules.builtin modules.builtin.modinfo modules.nsdeps \
16541659 modules.builtin.ranges vmlinux.o.map vmlinux.unstripped \
1660+ vmlinux.thinlto-index builtin.order \
16551661 compile_commands.json rust/test \
16561662 rust-project.json .vmlinux.objs .vmlinux.export.c \
16571663 .builtin-dtbs-list .builtin-dtbs.S
@@ -2113,7 +2119,7 @@ clean: $(clean-dirs)
21132119 $(call cmd,rmfiles)
21142120 @find . $(RCS_FIND_IGNORE ) \
21152121 \( -name ' *.[aios]' -o -name ' *.rsi' -o -name ' *.ko' -o -name ' .*.cmd' \
2116- -o -name ' *.ko.*' \
2122+ -o -name ' *.ko.*' -o -name ' *.o.thinlto.bc ' \
21172123 -o -name ' *.dtb' -o -name ' *.dtbo' \
21182124 -o -name ' *.dtb.S' -o -name ' *.dtbo.S' \
21192125 -o -name ' *.dt.yaml' -o -name ' dtbs-list' \
0 commit comments