Question: LTO and failing objcopy in "u-boot-initial-env" target

Adam Ford aford173 at gmail.com
Fri Oct 22 21:49:17 CEST 2021


On Fri, Oct 22, 2021 at 2:26 PM Marek Behún <marek.behun at nic.cz> wrote:
>
> On Fri, 22 Oct 2021 14:19:16 -0500
> Adam Ford <aford173 at gmail.com> wrote:
>
> > I am not sure it's the right solution, but it appears to work for me
> > on a board that uses LTO.  I didn't try it with a board that doesn't
> > use LTO.
>
> Need to be tested with GCC as well as Clang.

Agreed.

I turned off LTO, and got an error, so I updated the diff to:


diff --git a/Makefile b/Makefile
index 5194e4dc78..386180e935 100644
--- a/Makefile
+++ b/Makefile
@@ -2303,7 +2303,7 @@ endif
        $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost

 quiet_cmd_genenv = GENENV  $@
-cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@
env/common.o; \
+cmd_genenv = $(OBJCOPY) --dump-section `${OBJDUMP} env/common.o -t
|grep -m1 default_environment |awk '{print $$4}'`=$@ env/common.o; \
        sed --in-place -e 's/\x00/\x0A/g' $@

 u-boot-initial-env: u-boot.bin


It now appears to build without error with LTO enabled and disabled.

>
> Marek


More information about the U-Boot mailing list