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 C45B7C433FE for ; Tue, 18 Oct 2022 17:48:51 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id CAE1084F1B; Tue, 18 Oct 2022 19:48:49 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com 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=gmail.com header.i=@gmail.com header.b="o1sQbEgw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8E83084F3F; Tue, 18 Oct 2022 19:48:48 +0200 (CEST) Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id E588284EA1 for ; Tue, 18 Oct 2022 19:48:45 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=max.oss.09@gmail.com Received: by mail-ej1-x630.google.com with SMTP id k2so34171543ejr.2 for ; Tue, 18 Oct 2022 10:48:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=pzyOb/XIMWGKDy/zWkVmITsxFstivl0hhkn74dWXe7Q=; b=o1sQbEgwnrd3qFTYhNf77jZfqoMPAFWWowpjvFTUtQ6wtWZ5pxbPUyWMrh1GNny2+m U25trp4dwzEHtjcl3hJ1WRZunTCNttHIoL0E/NTn+VTpPuzn27BXTV7FKbWwg0tIATgp Arwt+uoGmE3y3NWaRSTo+JWfpMwLrYpJvm4rxZhs47Uts9r6oXmHn7GGhDTi185X+Rcz TKNn7qRreH1xJMpV9sSiB8wGJumvidzlmiUhFpJ+caio9NrzNjeFtRzY+a5IwLn+fHjr F6npX1t7vbr1jBPUf9bVnkwPpWK1yaFTcBIJhXgyCA3YLyfvjHWArcMjydAirqaR4tSV CkHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pzyOb/XIMWGKDy/zWkVmITsxFstivl0hhkn74dWXe7Q=; b=D6KSul7UO35avBZ8zofEzzjgNKFdeP28lZdt8fwUOH+zJF+ipLIi9l9JhZaMBaRR06 brJKEcGS35gu8MOR+7Ky1bCxznlYnlCb+7c5bztSg5GSJjmylM3CzQnxRtRbaHCjHQIr 2txzDN2+jzc5TUWjzo6Xkabn5Yzcx2c0Wl49AcaA4exSN0IRmZZ3bqAzZoRRS6lP4dnp h2lkU/PnXAJh/qm6KECeLPcd1p3t1CVbhDgZ36tC0SofZg5PFZg5OMZw+7cCoZM6yARB Pue/a+P4s3QS+ZmHg24++a25BW7flZyNiOtRy2Sss4sEQxHhFrKzsZzk2PS/mI9DStcy Oy4A== X-Gm-Message-State: ACrzQf3y7oe4bsa94JdUxs10jzZmkuSZWy1rI5R3OjGK/dWBl9rfSbV+ fAlmWS7FfGTpmyZuHDYlYvKoxQDxFQE= X-Google-Smtp-Source: AMsMyM6YgywBpI2wM0YaJ/y46osiX8/taosREOGIa/Qdo6SR3W65IY+7UEQB9jtsIoQwp3EPlSeGtg== X-Received: by 2002:a17:907:1b1e:b0:783:8e33:2d1c with SMTP id mp30-20020a1709071b1e00b007838e332d1cmr3428787ejc.304.1666115325047; Tue, 18 Oct 2022 10:48:45 -0700 (PDT) Received: from linuxdev2.toradex.int (31-10-206-125.static.upc.ch. [31.10.206.125]) by smtp.gmail.com with ESMTPSA id u22-20020a056402111600b00458dc7e8ecasm9227098edv.72.2022.10.18.10.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Oct 2022 10:48:44 -0700 (PDT) From: Max Krummenacher To: u-boot@lists.denx.de Cc: U-Boot STM32 , Adam Ford , Tom Rini , Patrice CHOTARD , Patrick DELAUNAY , Max Krummenacher , Heinrich Schuchardt , =?UTF-8?q?Marek=20Beh=C3=BAn?= , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Quentin Schulz , Simon Glass Subject: [PATCH] Makefile: fix u-boot-initial-env target if lto is enabled Date: Tue, 18 Oct 2022 19:48:27 +0200 Message-Id: <20221018174827.1393211-1-max.oss.09@gmail.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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; \ 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