diff mbox series

[2/3] MIPS: boot/compressed: Build without LTO

Message ID 20211213224914.1501303-3-paul@crapouillou.net (mailing list archive)
State New
Headers show
Series MIPS: Add support for LTO | expand

Commit Message

Paul Cercueil Dec. 13, 2021, 10:49 p.m. UTC
We need a valid ELF object for dummy.o, so that objcopy can insert the
vmlinuz payload.

Therefore, we must build the decompresser program without LTO, otherwise
dummy.o will be LLVM bytecode instead of a ELF object file.

Building the decompresser with LTO wouldn't make much sense anyway,
unlike building the vmlinuz itself with LTO.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
 arch/mips/boot/compressed/Makefile | 3 +++
 1 file changed, 3 insertions(+)

Comments

Nathan Chancellor Dec. 14, 2021, 6:07 p.m. UTC | #1
On Mon, Dec 13, 2021 at 10:49:13PM +0000, Paul Cercueil wrote:
> We need a valid ELF object for dummy.o, so that objcopy can insert the
> vmlinuz payload.
> 
> Therefore, we must build the decompresser program without LTO, otherwise
> dummy.o will be LLVM bytecode instead of a ELF object file.
> 
> Building the decompresser with LTO wouldn't make much sense anyway,
> unlike building the vmlinuz itself with LTO.
> 
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>

Seems reasonable.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  arch/mips/boot/compressed/Makefile | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
> index 4c9ecfbb0ef4..2d01c50fb0b1 100644
> --- a/arch/mips/boot/compressed/Makefile
> +++ b/arch/mips/boot/compressed/Makefile
> @@ -27,6 +27,9 @@ ifdef CONFIG_CPU_LOONGSON64
>  KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2
>  endif
>  
> +# Disable LTO
> +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
> +
>  KBUILD_CFLAGS := $(KBUILD_CFLAGS) -mno-abicalls -D__KERNEL__ -D__DISABLE_EXPORTS \
>  	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
>  
> -- 
> 2.33.0
> 
>
Nick Desaulniers Dec. 14, 2021, 7:43 p.m. UTC | #2
On Mon, Dec 13, 2021 at 2:49 PM Paul Cercueil <paul@crapouillou.net> wrote:
>
> We need a valid ELF object for dummy.o, so that objcopy can insert the
> vmlinuz payload.
>
> Therefore, we must build the decompresser program without LTO, otherwise
> dummy.o will be LLVM bytecode instead of a ELF object file.

While the below may work and follows the pattern observed in
drivers/firmware/efi/libstub/Makefile
43:KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))

I can't help but wonder whether we should instead be doing something like:
arch/x86/power/Makefile
9:CFLAGS_REMOVE_cpu.o := $(CC_FLAGS_LTO)
scripts/mod/Makefile
3:CFLAGS_REMOVE_empty.o += $(CC_FLAGS_LTO)
drivers/misc/lkdtm/Makefile
19:CFLAGS_REMOVE_rodata.o               += $(CC_FLAGS_LTO)

but for dummy.o?  ie.
CFLAGS_REMOVE_dummy.o += $(CC_FLAGS_LTO)

Can you please try that rather than disabling LTO for a large subset of files?

>
> Building the decompresser with LTO wouldn't make much sense anyway,
> unlike building the vmlinuz itself with LTO.

Why not? We do it for x86 and arm64 AFAICT.

>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
> ---
>  arch/mips/boot/compressed/Makefile | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
> index 4c9ecfbb0ef4..2d01c50fb0b1 100644
> --- a/arch/mips/boot/compressed/Makefile
> +++ b/arch/mips/boot/compressed/Makefile
> @@ -27,6 +27,9 @@ ifdef CONFIG_CPU_LOONGSON64
>  KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2
>  endif
>
> +# Disable LTO
> +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
> +
>  KBUILD_CFLAGS := $(KBUILD_CFLAGS) -mno-abicalls -D__KERNEL__ -D__DISABLE_EXPORTS \
>         -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"
>
> --
> 2.33.0
>
diff mbox series

Patch

diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile
index 4c9ecfbb0ef4..2d01c50fb0b1 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -27,6 +27,9 @@  ifdef CONFIG_CPU_LOONGSON64
 KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64r2
 endif
 
+# Disable LTO
+KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO), $(KBUILD_CFLAGS))
+
 KBUILD_CFLAGS := $(KBUILD_CFLAGS) -mno-abicalls -D__KERNEL__ -D__DISABLE_EXPORTS \
 	-DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull"