From patchwork Thu Jan 21 18:45:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12037537 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 460EAC433E0 for ; Thu, 21 Jan 2021 19:41:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E951C23A5E for ; Thu, 21 Jan 2021 19:41:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726286AbhAUTkn (ORCPT ); Thu, 21 Jan 2021 14:40:43 -0500 Received: from mail-03.mail-europe.com ([91.134.188.129]:37310 "EHLO mail-03.mail-europe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726410AbhAUSs2 (ORCPT ); Thu, 21 Jan 2021 13:48:28 -0500 Date: Thu, 21 Jan 2021 18:45:55 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1611254762; bh=1Awk2X9LSHOQQZek4o1ELWbmO0BY+pTltTaN3f2WBw4=; h=Date:To:From:Cc:Reply-To:Subject:From; b=CrQodZ1xZM2FLIl9dUu8OGQbAxk8pFD5PDH+MeGcVSm7yNrjJgMYceYpJ4DtZ6Sz9 G/sT2qYGM4zcgSHo9UI6KRunrCt2lTG0vIvGYhsz9kz4rNQgA4Ezy7jbPUVTNIcVJL f6IRqw8gtdbvMnVWdzcFu1tb0zBq5sC+tjaJTl8RpxB5H9BAOGuxyp8vDr83yRf18S HymS15rUgb8k/enkIRmNlOLFHj/PGIhv7Xf2pJrkpU55bodYBCL52/62XlNDcz9v/P fg25BXyyT2dj95PJUi7CWskvbskXafSVA27y9dZV8ER7go6NBgPOxEdr4deCWYFAdG Tb+Pk1nLNANug== To: Kees Cook From: Alexander Lobakin Cc: Sami Tolvanen , Masahiro Yamada , Michal Marek , Alexander Lobakin , kernel-hardening@lists.openwall.com, linux-hardening@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH kspp-next] kbuild: prevent CC_FLAGS_LTO self-bloating on recursive rebuilds Message-ID: <20210121184544.659998-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org CC_FLAGS_LTO gets initialized only via +=, never with := or =. When building with CONFIG_TRIM_UNUSED_KSYMS, Kbuild may perform several kernel rebuilds to satisfy symbol dependencies. In this case, value of CC_FLAGS_LTO is concatenated each time, which triggers a full rebuild. Initialize it with := to fix this. Fixes: dc5723b02e52 ("kbuild: add support for Clang LTO") Signed-off-by: Alexander Lobakin --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 668909e7a460..2233951666f7 100644 --- a/Makefile +++ b/Makefile @@ -895,10 +895,10 @@ endif ifdef CONFIG_LTO_CLANG ifdef CONFIG_LTO_CLANG_THIN -CC_FLAGS_LTO += -flto=thin -fsplit-lto-unit +CC_FLAGS_LTO := -flto=thin -fsplit-lto-unit KBUILD_LDFLAGS += --thinlto-cache-dir=$(extmod-prefix).thinlto-cache else -CC_FLAGS_LTO += -flto +CC_FLAGS_LTO := -flto endif CC_FLAGS_LTO += -fvisibility=hidden