History

kbuild: lto: force rebuilds when switching CONFIG_LTO

When doing non-clean builds and switching between CONFIG_LTO=n and CONFIG_LTO=y, the build system (correctly) didn't notice that assembly and LTO-excluded C object files were rewritten in place by objtool (to add the .orc_unwind* sections), since their build command lines were the same between CONFIG_LTO=y and CONFIG_LTO=n. The objtool step would fail: vmlinux.o: warning: objtool: file already has .orc_unwind section, skipping make: *** [Makefile:1194: vmlinux] Error 255 Avoid this by making sure the build will see a difference between an LTO and non-LTO build (by including "-fno-lto" in KBUILD_*FLAGS). This will get ignored when CC_FLAGS_LTO is present, and will not be included at all when CONFIG_LTO=n.

Sami Tolvanen committed 5 years ago

Commit 5e953251 parent b33fff01 file · +2 −1Browse files

Unified · Split

Makefile+2−1
@@ -910,7 +910,8 @@ KBUILD_LDFLAGS += -mllvm -import-instr-limit=5 · 909 unmodified lines
910910 endif
911911
912912 ifdef CONFIG_LTO
913−KBUILD_CFLAGS += $(CC_FLAGS_LTO)
913+KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO)
914+KBUILD_AFLAGS += -fno-lto
914915 export CC_FLAGS_LTO
915916 endif
916917

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t