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 D6667C4332F for ; Tue, 18 Oct 2022 18:19:34 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E19B384E09; Tue, 18 Oct 2022 20:19:32 +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="WK3XUnrT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3307184F63; Tue, 18 Oct 2022 20:19:31 +0200 (CEST) Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) (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 627D684D2B for ; Tue, 18 Oct 2022 20:19:28 +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 ams.source.kernel.org (Postfix) with ESMTPS id 0268AB81D8C; Tue, 18 Oct 2022 18:19:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A7D9C433C1; Tue, 18 Oct 2022 18:19:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666117166; bh=FdXkkbyeQIBWuoDAralLijrZFMw7pjR3uE4hBuf+qps=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WK3XUnrTSSKKuSWsl4nGYA9KXpCTpDIVRHfJyD0KtuP50yZjYh79LDKlv2xrwbkUq CNnC6bzkBgnAuXRbbNkPfCORxPkZapgCUc3ZoIKp6KdwM8hdDQKL/doDyORJsqhFCK 0Nb1dcNOwykwBiFrj/SKt03xWX6/9Ea4D3PaOJmJ3RYq3earRHXnG8iKSlkvj/fnfV /qLe2xpHYwvfYmkZIY09SdbrGkc8Xw8QnB86qKPTQpgdEUvkX5CbSd57ohDOCPyefu nNSm/bVBKLWRO0NW61EfKcVJB05Nip1aySxkgMTYPbKEOei8OpaljJK8hkn+1RssOL c2C3RksOfO7ZA== Received: by pali.im (Postfix) id 8F62B76B; Tue, 18 Oct 2022 20:19:23 +0200 (CEST) Date: Tue, 18 Oct 2022 20:19:23 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Tom Rini Cc: Max Krummenacher , u-boot@lists.denx.de, U-Boot STM32 , Adam Ford , 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: <20221018181923.4vuaskvw3bkfil7b@pali> References: <20221018174827.1393211-1-max.oss.09@gmail.com> <20221018180331.sgsufsip2p2544ip@pali> <20221018180446.GP2020586@bill-the-cat> <20221018180627.eezooyqb2yyhyodu@pali> <20221018181723.GQ2020586@bill-the-cat> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20221018181723.GQ2020586@bill-the-cat> 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 14:17:23 Tom Rini wrote: > On Tue, Oct 18, 2022 at 08:06:27PM +0200, Pali Rohár wrote: > > On Tuesday 18 October 2022 14:04:46 Tom Rini wrote: > > > On Tue, Oct 18, 2022 at 08:03:31PM +0200, Pali Rohár wrote: > > > > 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. > > > > > > Wait, when does that happen? > > > > E.g. for mvebu_espressobin-88f3720_defconfig > > Erm, ugh. I see 44be835d25ba ("arm: mvebu: Espressobin: Set default > value for $ethNaddr env variable") and c4df0f6f315c ("arm: mvebu: > Espressobin: Set default value for $fdtfile env variable") I guess we > couldn't solve this any other way? The platforms aren't unique in > needing / wanting to set MAC or fdtfile variables. > > -- > Tom Yes, we can solve it. Marek was working on solution for setting default variables at runtime but seems it is not finished yet.