Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp98509pxu; Wed, 2 Dec 2020 16:13:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7S6ELM99sdvwEwBnTycd5DcFHygG+hgiUsowKF/g4Saw4XxPzbD5hzZdR7+g9NNOS6wAt X-Received: by 2002:a50:f308:: with SMTP id p8mr495229edm.331.1606954410157; Wed, 02 Dec 2020 16:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606954410; cv=none; d=google.com; s=arc-20160816; b=aEDuswqrbrns6WfZm147O7LQkSTzOpXyRsmoI/WZiu2jOz+O6V11NlyPiRQFiagOl8 iofPrXbhHSS6F8eUlfrD4MYRTV7rFoK6KpQzliK5hxyqAq3e7yIG60ky9MFKNNJyzdId v5QL20+b8752eP0DfTgmNk6CpDIWRYqbuXMRX+k6CRsBqf7uIE8PogITStyu+Q6qK+dI JVWVdOf3qnZRVN8t+rFvR6DIa3ZFbBD1bdLQXYl2+HVKi4ooVL0C08w3fvf6VItWE4uP i62flvhowWjJ66AjLisO2nml6ka1KBaOnp/dzJIoeu2g+P5XbEsWrQLIcjVf2O1qCQgv RAeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=kEzbS1TJpZr1zlUaIzJZNjxvOX/ycdroxO9B6D39hfs=; b=MuGB+YbaI6AewvV/vw9lJvN/71EG7Fv03cTS0GH1SQP/4/pJo1PaylQszb/VnV+nQR xr61HCoAQIPqtcU8vClLTIdmODiqT4RB2k53EhvfFzsrvJdjtoHkKDPcGaG7/p1GSyX7 kPD/f6vkpGDD+XgUvSoa7W6Zv4+5wpHoZGqv77n+RKBps7kcCZAePYTwlGnOI+n3VzrJ IgGm6PjfYDuJ5rBLyBWza5kbu820GYnrj/yC5UCGNYeafshZ/skENiQfJXw7JEo/QFuX 9vjSqrh9d/wWgrkTQ/CXaPlIyFEi/G52ZJixqtF00/vdkcQdc3YhfqwUvSLkwAfGUucs 45qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=XgE4hFlR; 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 p21si118681ejx.516.2020.12.02.16.13.07; Wed, 02 Dec 2020 16:13:30 -0800 (PST) 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=XgE4hFlR; 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 S1726339AbgLCAIw (ORCPT + 99 others); Wed, 2 Dec 2020 19:08:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725885AbgLCAIw (ORCPT ); Wed, 2 Dec 2020 19:08:52 -0500 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C8D2C061A04 for ; Wed, 2 Dec 2020 16:08:06 -0800 (PST) Received: by mail-pl1-x642.google.com with SMTP id p6so134535plo.6 for ; Wed, 02 Dec 2020 16:08:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kEzbS1TJpZr1zlUaIzJZNjxvOX/ycdroxO9B6D39hfs=; b=XgE4hFlRnyVhoAVXKZpoORytuCszXHlvqvjFiWoMfDwKLHMBAJiLtfdxPUF1Ds0rUD hMy53TCCB3trdymTPnhD/EpvivzoOAAQAXZxETeYSC6+cHzGVMjT4trKGbcy7mVBPbhc EU9XgJtJIhJthGXtFVvljVzi3G5x0AhpPonp2pZCSVp8N7AtEqRR1TIcbgMo+e0jsZ0Z Hc665Mzj1QqTEsrYINBIu3TQZCrLkjHzzC62HS4Y70oidn18XQ6vsN8XwIZCJ0FsFltb h9glLD+E7xt4OobgWoc6JZBfXamL35QVqKIzdutURzOaZO1KrXt6o7P69HgMN+nPfgD4 oNFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kEzbS1TJpZr1zlUaIzJZNjxvOX/ycdroxO9B6D39hfs=; b=PhfozmpQ5HzQhPAxfgv6dBUjn7TxYsBja1RrOYixyPMC6Nwjo+84mQWAOwowSFUmJf 5pmVPmpDqpNq7Ztfkl+4943tJ3hS4CROtwpQDqNw0GbETWf9kTBYsvU2Uio+PpKvYBHZ BWcbGlkCeJ5fInQsG95FQy8pxZ0HVTkjnu28Vefxuvne95ns4p9mYdF/JjmOaCUdbrQ8 mTE0hgnfPVN8hu9vrF1rcx/AqDpLejtGPq5UZesi8ajVbhkZFaKJxCgXMu8FjPr1/twm mYO247g8Dr9x0dggOkE9EEI91WlkXbhcqHrHzGkJGeLr4zvoFg/3w3YR9fc3XUjfR2HQ fqtg== X-Gm-Message-State: AOAM531aoly47mZnBqH7Mq7VugzPjDlK/uWPDesWdPG25ISNROm3COwl kp79AifZybtvd/jvu8aq7+31SG3Oc8CV7HPgRNNggQ== X-Received: by 2002:a17:90a:2e8c:: with SMTP id r12mr413591pjd.101.1606954085432; Wed, 02 Dec 2020 16:08:05 -0800 (PST) MIME-Version: 1.0 References: <20201201213707.541432-1-samitolvanen@google.com> <20201201213707.541432-3-samitolvanen@google.com> In-Reply-To: <20201201213707.541432-3-samitolvanen@google.com> From: Nick Desaulniers Date: Wed, 2 Dec 2020 16:07:54 -0800 Message-ID: Subject: Re: [PATCH v8 02/16] kbuild: add support for Clang LTO To: Sami Tolvanen Cc: Masahiro Yamada , Steven Rostedt , Will Deacon , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , clang-built-linux , Kernel Hardening , linux-arch , Linux ARM , Linux Kbuild mailing list , LKML , PCI Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 1, 2020 at 1:37 PM Sami Tolvanen wrote: > > This change adds build system support for Clang's Link Time > Optimization (LTO). With -flto, instead of ELF object files, Clang > produces LLVM bitcode, which is compiled into native code at link > time, allowing the final binary to be optimized globally. For more > details, see: > > https://llvm.org/docs/LinkTimeOptimization.html > > The Kconfig option CONFIG_LTO_CLANG is implemented as a choice, > which defaults to LTO being disabled. To use LTO, the architecture > must select ARCH_SUPPORTS_LTO_CLANG and support: > > - compiling with Clang, > - compiling inline assembly with Clang's integrated assembler, > - and linking with LLD. > > While using full LTO results in the best runtime performance, the > compilation is not scalable in time or memory. CONFIG_THINLTO > enables ThinLTO, which allows parallel optimization and faster > incremental builds. ThinLTO is used by default if the architecture > also selects ARCH_SUPPORTS_THINLTO: > > https://clang.llvm.org/docs/ThinLTO.html > > To enable LTO, LLVM tools must be used to handle bitcode files. The > easiest way is to pass the LLVM=1 option to make: > > $ make LLVM=1 defconfig > $ scripts/config -e LTO_CLANG > $ make LLVM=1 > > Alternatively, at least the following LLVM tools must be used: > > CC=clang LD=ld.lld AR=llvm-ar NM=llvm-nm > > To prepare for LTO support with other compilers, common parts are > gated behind the CONFIG_LTO option, and LTO can be disabled for > specific files by filtering out CC_FLAGS_LTO. > > Signed-off-by: Sami Tolvanen > Reviewed-by: Kees Cook Reviewed-by: Nick Desaulniers -- Thanks, ~Nick Desaulniers