Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp877310ybt; Wed, 24 Jun 2020 13:34:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwnl0IsppbjO+nVNNQ8/KGjmrLWdwnxS+yA/TUGzRsiRaJWprSeVbMZIx58CFHZhHn2SwrN X-Received: by 2002:a17:906:af48:: with SMTP id ly8mr26356019ejb.28.1593030849485; Wed, 24 Jun 2020 13:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593030849; cv=none; d=google.com; s=arc-20160816; b=qILN5ou+KQlzMiiQi5IUNUsJrKh4BYgbWS01pnDTajFfkvxmd2A8Yy4w4CiTlBhhIy QjGF2RLrbyFeEI0+TZl+KLT2q48nvtpyZtGZHCUdpGU0miGZ+yBNMlLmhqVSSC12nll7 M1X8K3wpU2NB4KKOy9pty+Uv3nOA8iZZyDUXnYKFEGMbxB71J1yIYYfMm3NC9n3ysnS7 H794+NQqZMG59OBXqmcAJra8pwM8umh4EBg4/9Yxw7aE0QcH5OjbAmjXGwagwg9I6wTA ZGUzg+wTPIrnoaQwOGEbtTPMJxRAPVL6Zowsrs8jAXA3dq3OWww21zEMDddjBxk+I+58 8Kpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=7CIu5VjUyqeUAWF5g9yThD8i7PrniBSkPgVIeHI/Dgw=; b=MQjVS0ktQ29VQVxAMB1Mu6X9RAYzWf+CWyQ4SQ/rIx91zcBLSQ1D+wx155lVXDCTx4 0tYxbJ+RJJwA+TLKh1hkRW+0TEMvSEidDNCNWovN/O+6k7lVNp4XvR6UWAMSLn3RfOs1 z3dL9UGYxUU+dgu0K+R7CcfQXJOj5zIkfod9sm70U8RWF8KuzujZcHC+kGROffVH8/rK bSd/XrPGF/RvSRXori5QEu57S2m5XIOl5qPi0KWr2NNBRE3/6KhB42x/q3oWVkyrjaCZ uRobp32lYPPgjwZPIsa16GXHbAFLFoXbOVx6e98J9aWpVEusp5gbnY5PBExhhk2dwuKO OdVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ri578dhL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id wp10si13092685ejb.56.2020.06.24.13.33.45; Wed, 24 Jun 2020 13:34:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ri578dhL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388709AbgFXUdQ (ORCPT + 99 others); Wed, 24 Jun 2020 16:33:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50520 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406459AbgFXUdK (ORCPT ); Wed, 24 Jun 2020 16:33:10 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CECE7C061573 for ; Wed, 24 Jun 2020 13:33:09 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id t32so2448253qth.2 for ; Wed, 24 Jun 2020 13:33:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=7CIu5VjUyqeUAWF5g9yThD8i7PrniBSkPgVIeHI/Dgw=; b=ri578dhLvQe03PuVkYI/KosO3BmuE994j1VVuunF6mqXcSxoUchnm+hnogX96YG7Yx yI/MHeu9q9kVZVlnIIydNSi+r5iCLXjTZcnO6Uxh+hmUL4ed/4KhiHZWp/xtvwTh9cIK SomuMXc3FlUpv/wxq+AMmks9S70kXGIVSq6hdIig9pY/BRVFkIkq59gCCp2yYhdgtpZ+ TZxSgxiOsR9AcdF9rr0muiREjAZMfpam4EUBzlvonJ5mc1omg9Z9rzCkOz4lybvX42iW cfZVoIgjekwd1lX3DuJT3IjQ4IeC9YVCNgBTDnUF1CG7cfbw3hlLKLyVFbznVgBNgaOl aGRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=7CIu5VjUyqeUAWF5g9yThD8i7PrniBSkPgVIeHI/Dgw=; b=LWoT1VB4I9jnvM7bnJxXjgyQuLPCowwOm3xENmb5+LWrja2mtRl8BtV1k1QP7s5Mzp nd+BUr4jecvXh/GO2l2Vo+WFcv90dnhoU0M/2x/MqMU57etH3TjnsBqSKYEYVaqQoWLS 4CeVFI8eG+rzrQDbyv4UqrbFb+oESERfKMUCVx3sFlOsXaUo8uq87F1lOmHgKvzsHHHT rcu0kp0yHajUsJz1y4c34xkDYTsvoLokrCLL0dZ6npyz1ZZsdmxTTsUsMjC2v1MfMjeX ayDl6vLYJvCqLQ+6eShTyZuiBITlhdzJX/BC1TnizVVS2mrofrLXTLpzkqpa7aTCksDo kZnQ== X-Gm-Message-State: AOAM533506mfXWKliplJK44l4m40HX+/H8ITVJYNZQX4xdf0u5qtXLzY qm1qkwZJ4kectc2Cnn3DjwrEyWeKrxgIOSg84dY= X-Received: by 2002:ad4:47b2:: with SMTP id a18mr33619619qvz.121.1593030789019; Wed, 24 Jun 2020 13:33:09 -0700 (PDT) Date: Wed, 24 Jun 2020 13:31:44 -0700 In-Reply-To: <20200624203200.78870-1-samitolvanen@google.com> Message-Id: <20200624203200.78870-7-samitolvanen@google.com> Mime-Version: 1.0 References: <20200624203200.78870-1-samitolvanen@google.com> X-Mailer: git-send-email 2.27.0.212.ge8ba1cc988-goog Subject: [PATCH 06/22] kbuild: lto: limit inlining From: Sami Tolvanen To: Masahiro Yamada , Will Deacon Cc: Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux@googlegroups.com, kernel-hardening@lists.openwall.com, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org, Sami Tolvanen , George Burgess IV Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change limits function inlining across translation unit boundaries in order to reduce the binary size with LTO. The -import-instr-limit flag defines a size limit, as the number of LLVM IR instructions, for importing functions from other TUs. The default value is 100, and decreasing it to 5 reduces the size of a stripped arm64 defconfig vmlinux by 11%. Suggested-by: George Burgess IV Signed-off-by: Sami Tolvanen --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 3a7e5e5c17b9..ee66513a5b66 100644 --- a/Makefile +++ b/Makefile @@ -894,6 +894,10 @@ else CC_FLAGS_LTO_CLANG := -flto endif CC_FLAGS_LTO_CLANG += -fvisibility=default + +# Limit inlining across translation units to reduce binary size +LD_FLAGS_LTO_CLANG := -mllvm -import-instr-limit=5 +KBUILD_LDFLAGS += $(LD_FLAGS_LTO_CLANG) endif ifdef CONFIG_LTO -- 2.27.0.212.ge8ba1cc988-goog