From patchwork Fri Jun 5 08:36:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1303958 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=C0XGJXDZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49dbc632LYz9sT6 for ; Fri, 5 Jun 2020 18:37:09 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 38F0281DC7; Fri, 5 Jun 2020 10:37:07 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="C0XGJXDZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id AA9DE81DFC; Fri, 5 Jun 2020 10:37:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on0723.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe02::723]) (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 A367981DB5 for ; Fri, 5 Jun 2020 10:37:01 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=faZJmPmcKcLCLlQ6yjgeTzmn7ctEV2l6SRAcMVotLkinxRmV/xQO4IPJRlbfhcx2Ne++reO4FKi54YCH6fYG1S20tJHXzMLE4hhPbXGius/R557FRy25syLWM1dNEPtZXP4uCCXj4eu+hkqhOzHDcFWjvpjTBY3L+SjcamMpFW2/ZuJH2ikl5mPFX2Pyrh/rY3w6bygDOWl3yEZEN8ive/6CEdM7Bd5Gjz6dHspYtrbUsJYmn4t/MJ1qxV1GImO8ER7+VsoeTcMqUGhlWZX2tJqvOCsBPE9ftWWntEWBNbuaDg2955jHsvErFfIoSPvo+IsYl1DjDvDrSmbEiCoHAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=McpfKAscXxRmCwjoWYpHkBW0PiMQOu78cz0YPBXM3Ew=; b=N3o++WJd0QsybOeIQjoCS5fjNBcKGkF0JtNIbH3oN1lzfMupY1tIeF4f7QiIwHKdA7+22wRzoaBn3reOBAARAYi1p8CLY9ROULp//+6qeyrsKG3iNGIT5u7hkQoFtP95xZldVdLt1gdrSZxiyYivJeUJc5h5uulqll7pbwLhuge40NZir4y8OQZpg6k3epl/AqsY2WSt5j5wHNYtw49O8JShgqTHNaiNUk/+D8qlaaUOoIvw2nuD3yGaGSKe6fj+eznebyhpOXjwWoKbWF8h0H7r2wHX80DcJAw5QcZsp7JX9+ibwwsngaExZFRitWQyHP94hBiF7L86/vuUSbxpkQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=McpfKAscXxRmCwjoWYpHkBW0PiMQOu78cz0YPBXM3Ew=; b=C0XGJXDZB2RfhBowJGZjgeDWZAUc98Q+13y1s0ClEG+nrJF9Vop4TkrSYXojptuEJhgT1rcoOV9dbC+YvyKu+d3yDAnpApC98n8gc+jmz+yqdjtc/qNAjXbJxeQ53ZLE10S7ypiH9QlMvsYc9YSpVmNrS9v5u1EJD4PY+SJC8Gc= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) by VI1PR10MB2605.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:dd::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20; Fri, 5 Jun 2020 08:36:59 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::f0ac:4e97:2536:faa%7]) with mapi id 15.20.3066.018; Fri, 5 Jun 2020 08:36:59 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Rasmus Villemoes , Masahiro Yamada , Michal Simek , Tom Rini , Simon Glass Subject: [RFC PATCH] allow choosing -Os/-O2 separately for SPL and TPL Date: Fri, 5 Jun 2020 10:36:50 +0200 Message-Id: <20200605083650.30048-1-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 X-ClientProxiedBy: AM6P195CA0104.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::45) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by AM6P195CA0104.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.18 via Frontend Transport; Fri, 5 Jun 2020 08:36:58 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: bb0ecd1b-4703-4180-f163-08d8092b9ccd X-MS-TrafficTypeDiagnostic: VI1PR10MB2605: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-Forefront-PRVS: 0425A67DEF X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BmeUzf+7s3ejSP3JeN7btT4tu9jqmdh6TvrDEe4XcnmD7AQtGSRXhb5SRW6fC1gp1A6GxQ69Zy25rBLvgvmVKxdQ29xUhbh0/yeSzTi+jqiCJtgYNpIJakI0itKVsA43m65p5lkIH8hHnV3Ovl2jXk06bHI9DkxRdJeS0DkGvG4jrR+oI2gyniwSQWns9KbQVtQRfO6RZaM4Va5AKexnBgXb7crI47uJUT8XyLcE7l1TmvHrdjJvKVOitl7WAs41woWiN1TRBuMGgaHFnpF+xbRLYXZZoadteWRHm9CjhUOBvCRIRK0LNyhywupE5FHeCgAgyhLiAvV5GNL4RUzqxw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFTY:; SFS:(39850400004)(136003)(346002)(366004)(396003)(376002)(1076003)(8676002)(5660300002)(8936002)(8976002)(478600001)(956004)(4326008)(6486002)(6916009)(6512007)(66556008)(66476007)(66946007)(44832011)(316002)(86362001)(6506007)(26005)(2906002)(54906003)(83380400001)(52116002)(36756003)(6666004)(16526019)(186003)(2616005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: dASDYcQFeYEuUmhDT082ivqB4DrcHInFz/J1DYj+DPUUmEk8vvoiNl2wYNJwCNiTqXvQ6RYr1oIbbnE7W694uT3zEstglZk9BHcou5nKFQXhF5EAg8zmouKZ9zec2aoJjk36Wq3C2rXcDFroY7p6cxE8jptV5i6f5oTd0++PaFZ4SOSe8IA98lcVOZPGhZ5bHDLoxXwFEKvteQsv9440QKIYG/qYZ54EkaAnn5Si3XrWc+i3RLRZ22ZK4YxfJSWMFrFWuPZavKE19ppdiisPOAcK4CENdMbtckSbYbt+JBWR/EgiDDjkBIDtjHMuMoHQPtb6UFVyuRFk4js1hmccvuzIcE2JxjEarqHXwfOGnb8Npin+9V0aMIBHw3VXlOn8MZ2MV8WvYXc9+Hl7pGTDqVyN98uMWiotspMVo83P7If9YVzLZfxTT1LCW89aBQHcur/+Y+wdhAkziIqKNFSj6rmOCveZKrhXhRNR/cQ94YQ= X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: bb0ecd1b-4703-4180-f163-08d8092b9ccd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jun 2020 08:36:59.3850 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +bxOAn1oYln0rI4zIHDF6xzB19jOr+7yLk56L3sz98Pp83XLMo0PByIZbjNSYz8Pp7HSAyQeUDMhvHVvpsUbzmYzhXsTba/92drWcwcX2bI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2605 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 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.102.2 at phobos.denx.de X-Virus-Status: Clean It can be useful to build U-Boot proper with -O2, but still optimize the SPL for size. So add separate config options for SPL and TPL. I had to move the Makefile logic to config.mk, since otherwise SPL_TPL_ didn't seem to be known. Unfortunately, the SPL translation units end up getting both -O2 and -Os passed (assuming CC_OPTIMIZE_FOR_SIZE=n, SPL_CC_OPTIMIZE_FOR_SIZE=y) - it ends up with the intended effect, but it is still not very pretty. My Kbuild fu is pretty weak; I wonder how the two uses of $(SPL_) in the main Makefile works when apparently $(SPL_TPL_) didn't. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- Kconfig | 20 ++++++++++++++++++++ Makefile | 6 ------ config.mk | 6 ++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Kconfig b/Kconfig index f698e0a94f..0468bd0089 100644 --- a/Kconfig +++ b/Kconfig @@ -66,6 +66,26 @@ config CC_OPTIMIZE_FOR_SIZE This option is enabled by default for U-Boot. +config SPL_CC_OPTIMIZE_FOR_SIZE + bool "Optimize SPL for size" + default y + depends on SPL + help + Enabling this option will pass "-Os" instead of "-O2" to gcc + resulting in a smaller U-Boot SPL image. + + This option is enabled by default for U-Boot SPL. + +config TPL_CC_OPTIMIZE_FOR_SIZE + bool "Optimize TPL for size" + default y + depends on TPL + help + Enabling this option will pass "-Os" instead of "-O2" to gcc + resulting in a smaller U-Boot TPL image. + + This option is enabled by default for U-Boot TPL. + config CC_COVERAGE bool "Enable code coverage analysis" depends on SANDBOX diff --git a/Makefile b/Makefile index 7c2067f35e..586d5d687a 100644 --- a/Makefile +++ b/Makefile @@ -645,12 +645,6 @@ ifeq ($(CONFIG_XTENSA),) LDPPFLAGS += -ansi endif -ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE -KBUILD_CFLAGS += -Os -else -KBUILD_CFLAGS += -O2 -endif - KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks) diff --git a/config.mk b/config.mk index caf0dd9b81..a3eb3f941e 100644 --- a/config.mk +++ b/config.mk @@ -70,6 +70,12 @@ RELFLAGS := $(PLATFORM_RELFLAGS) PLATFORM_CPPFLAGS += $(RELFLAGS) PLATFORM_CPPFLAGS += -pipe +ifeq ($(CONFIG_$(SPL_TPL_)CC_OPTIMIZE_FOR_SIZE),y) +KBUILD_CFLAGS += -Os +else +KBUILD_CFLAGS += -O2 +endif + LDFLAGS += $(PLATFORM_LDFLAGS) LDFLAGS_FINAL += -Bstatic