Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 09E6FC433FE for ; Tue, 18 Oct 2022 18:03:47 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9FDB784E7F; Tue, 18 Oct 2022 20:03:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="ecEbNFys"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C8B4184E6F; Tue, 18 Oct 2022 20:03:42 +0200 (CEST) Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B448384E6F for ; Tue, 18 Oct 2022 20:03:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 9D85ECE1D28; Tue, 18 Oct 2022 18:03:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8591C433D6; Tue, 18 Oct 2022 18:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666116214; bh=QWkEnzXe4AirOPt8IvX9l/+PaI42GfK1oUrDNgq2EfU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ecEbNFys5yR+kDL9EE1fOqNbyFoNPYRTJ4va/HRmL3e91wZ/mxsu9c5NpojTnSDTl 3vFkM1a15nYeuXOwAZmwI22KSbMfbpozuEcTALJh7e8hPpra/3Iy2ujcKO5HYtEXTu JuwR0QMX7/MEUqnJiPifpsm98ZYqHiI4/jFJv4m1n6mEkqR+UkXKoXkytugPinsTJa MXX/Hx40OS302Jvtu/MM88o6pdnqxMa5icZKkDNdFAJD/g2pX+puih5f6sUeyZUJUd DuT+qUE1IxtMlFu/dYIb1Nr4rVuYxEbW397mFxqlj0zjdrOSPa/jZpvdPddFnoimeH SjUIk7DzMHGnw== Received: by pali.im (Postfix) id D04BA76B; Tue, 18 Oct 2022 20:03:31 +0200 (CEST) Date: Tue, 18 Oct 2022 20:03:31 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Max Krummenacher Cc: u-boot@lists.denx.de, U-Boot STM32 , Adam Ford , Tom Rini , Patrice CHOTARD , Patrick DELAUNAY , Max Krummenacher , Heinrich Schuchardt , Marek =?utf-8?B?QmVow7pu?= , Quentin Schulz , Simon Glass Subject: Re: [PATCH] Makefile: fix u-boot-initial-env target if lto is enabled Message-ID: <20221018180331.sgsufsip2p2544ip@pali> References: <20221018174827.1393211-1-max.oss.09@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221018174827.1393211-1-max.oss.09@gmail.com> User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean On Tuesday 18 October 2022 19:48:27 Max Krummenacher wrote: > From: Max Krummenacher > > With LTO enabled the U-Boot initial environment is no longer stored > in an easy accessible section in env/common.o. I.e. the section name > changes from build to build, its content maybe compressed and it is > annotated with additional data. > > For GCC adding the option '-ffat-lto-objects' when compiling common.o > adds additionally the traditional sections in the object file and > 'make u-boot-initial-env' would work also for the LTO enabled case. > However clang doesn't have that option. > > Fix this by recompiling common.o into a object file only used for > the creation of u-boot-initial-env if LTO is enabled. > > See also: > https://lore.kernel.org/all/927b122e-1f62-e790-f5ca-30bae4332c77@foss.st.com/ > > Signed-off-by: Max Krummenacher > > --- > > Makefile | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/Makefile b/Makefile > index 3866cc62f9a..cd45c720d23 100644 > --- a/Makefile > +++ b/Makefile > @@ -2451,9 +2451,17 @@ endif > $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost > > quiet_cmd_genenv = GENENV $@ > +ifeq ($(LTO_ENABLE),y) > +cmd_genenv = $(CC) $(filter-out $(LTO_CFLAGS),$(c_flags)) -c -o env/initial_env.o env/common.c; \ > + $(OBJCOPY) --dump-section .rodata.default_environment=$@ env/initial_env.o; \ > + sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; \ > + sort --field-separator== -k1,1 --stable $@ -o $@; \ > + rm -f env/initial_env.o env/initial_env.su > +else > cmd_genenv = $(OBJCOPY) --dump-section .rodata.default_environment=$@ env/common.o; \ This code is still broken because in some cases section name is not RO. So instead of using section name, I would rather suggest to compile simple host application which prints it. > sed --in-place -e 's/\x00/\x0A/g' $@; sed --in-place -e '/^\s*$$/d' $@; \ > sort --field-separator== -k1,1 --stable $@ -o $@ > +endif > > u-boot-initial-env: u-boot.bin > $(call if_changed,genenv) > -- > 2.35.3 >