From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no 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 6C0E3C433FE for ; Thu, 3 Dec 2020 17:09:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 15661206CA for ; Thu, 3 Dec 2020 17:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731469AbgLCRIa (ORCPT ); Thu, 3 Dec 2020 12:08:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725918AbgLCRIa (ORCPT ); Thu, 3 Dec 2020 12:08:30 -0500 Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 586A8C061A4E for ; Thu, 3 Dec 2020 09:07:44 -0800 (PST) Received: by mail-lf1-x141.google.com with SMTP id v14so3793463lfo.3 for ; Thu, 03 Dec 2020 09:07:44 -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=+MQyiUOcMt6gFRBNfnN0H07pYjhZgF4qm1+bZjvfjTY=; b=Cx6oEw3asYjWnT8nYuCvr3UMa7sC7zqGfjZH+6NM/LRsctzlYBq4jWYT5t+CTuzy81 ufA/35gbWjoyI3GR4sHKJJ/dXIYNWsy/BxrQVF9OwKV8d6p4mG8Br2zZ9qAR1jhR1sR5 XFtBts/povF4EP6Ny/d1T5ZXYf5b7sm8jc1Iq+39jvlvaKhZ804pJUPhzTdzV+xw97qN T4REXRSQqTMIj7T7Nw8GXA7uRLUe6tmfZ+hAOZ2AadWxtejiV4KjYgBy29l+9CK6RmgP /m7bEmZBumCr+ghR9RTNKJtACi6yZ1mK18q6oD/IvZz6axncMy9glbpDQAxZ3Bj+bHAk 275w== 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=+MQyiUOcMt6gFRBNfnN0H07pYjhZgF4qm1+bZjvfjTY=; b=M0/FMXEaywvGKgfDsZ74f6gZWogbee72KQwc7ZvH4/0KiRqU09t5x2QOe9aaAcVKlp IWkAyDxnCdW2vbEA1e08QkozTcErfk14IAngwc0rFAQgcbgziVhl8tEk4o8HDdsoSpB8 94TenHes/ULVZ6iZMqOFbbwZPWH7Ig4WVdk5cRyiUfx3jpGCYHS4AqugoA+w7Kx1ajhe /cYcHObnahAgl6uZPEF054byhSEJjPZ+QL9Tq/FACsHRVAQDfSzXH0lhmfeVtLF98acg FPeRRy28Eil2A9f46IBTAFbrsx+ga4fU1QUGmUwq8GGfH5kapq6J9xdi+xzTILkUqqj/ f2SQ== X-Gm-Message-State: AOAM532vMczZ0lnIRP/eUM4UGaRKugPEcFAelFsQ3hos7whu4bPfSrs8 8IC2fdM5evr6XZkzaBWjIM45T1EwyA5smC78ZEL/6A== X-Google-Smtp-Source: ABdhPJyeNpRimBzFqDhGioLOrE5ouq1kJk4Pby6GpAHMXjB75Cnj+2lIjlrUJWt+qddSs9EdyIaV3e9wcFRpPEdvaH8= X-Received: by 2002:a19:c815:: with SMTP id y21mr1656793lff.589.1607015262357; Thu, 03 Dec 2020 09:07:42 -0800 (PST) MIME-Version: 1.0 References: <20201201213707.541432-1-samitolvanen@google.com> <20201203112622.GA31188@willie-the-truck> In-Reply-To: <20201203112622.GA31188@willie-the-truck> From: Sami Tolvanen Date: Thu, 3 Dec 2020 09:07:30 -0800 Message-ID: Subject: Re: [PATCH v8 00/16] Add support for Clang LTO To: Will Deacon , Nick Desaulniers , Nathan Chancellor Cc: Masahiro Yamada , Steven Rostedt , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , linux-kbuild , LKML , PCI Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 3, 2020 at 3:26 AM Will Deacon wrote: > > Hi Sami, > > On Tue, Dec 01, 2020 at 01:36:51PM -0800, Sami Tolvanen wrote: > > This patch series adds support for building the kernel with Clang's > > Link Time Optimization (LTO). In addition to performance, the primary > > motivation for LTO is to allow Clang's Control-Flow Integrity (CFI) > > to be used in the kernel. Google has shipped millions of Pixel > > devices running three major kernel versions with LTO+CFI since 2018. > > > > Most of the patches are build system changes for handling LLVM > > bitcode, which Clang produces with LTO instead of ELF object files, > > postponing ELF processing until a later stage, and ensuring initcall > > ordering. > > > > Note that arm64 support depends on Will's memory ordering patches > > [1]. I will post x86_64 patches separately after we have fixed the > > remaining objtool warnings [2][3]. > > I took this series for a spin, with my for-next/lto branch merged in but > I see a failure during the LTO stage with clang 11.0.5 because it doesn't > understand the '.arch_extension rcpc' directive we throw out in READ_ONCE(). I just tested this with Clang 11.0.0, which I believe is the latest 11.x version, and the current Clang 12 development branch, and both work for me. Godbolt confirms that '.arch_extension rcpc' is supported by the integrated assembler starting with Clang 11 (the example fails with 10.0.1): https://godbolt.org/z/1csGcT What does running clang --version and ld.lld --version tell you? > We actually check that this extension is available before using it in > the arm64 Kconfig: > > config AS_HAS_LDAPR > def_bool $(as-instr,.arch_extension rcpc) > > so this shouldn't happen. I then realised, I wasn't passing LLVM_IAS=1 > on my Make command line; with that, then the detection works correctly > and the LTO step succeeds. > > Why is it necessary to pass LLVM_IAS=1 if LTO is enabled? I think it > would be _much_ better if this was implicit (or if LTO depended on it). Without LLVM_IAS=1, Clang uses two different assemblers when LTO is enabled: the external GNU assembler for stand-alone assembly, and LLVM's integrated assembler for inline assembly. as-instr tests the external assembler and makes an admittedly reasonable assumption that the test is also valid for inline assembly. I agree that it would reduce confusion in future if we just always enabled IAS with LTO. Nick, Nathan, any thoughts about this? Sami From mboxrd@z Thu Jan 1 00:00:00 1970 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=-5.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 1230BC4361A for ; Thu, 3 Dec 2020 17:09:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DD4220674 for ; Thu, 3 Dec 2020 17:09:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9DD4220674 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=swepvatQI+b94pELRhf//S6rw46wuhFlbOpXH502Ubg=; b=Au+IbX7FL/mb7G2bfwGru4XXe aQWHHgp50KVfKJ4A9ZaBL6o5pHTWahDPRZ6tg9Ztaxu6z0tWa6x/tXbRrCv2g8SAzFf6H6wm+Mor3 EXLjmMMnhSnvdOrMLoiCs9u9paSeIXvPmqIZIyJVUAn3jIYOa700zIQ0OUjhwQL1VB7h+80sRJEg9 zIu0h9cMhlYFt4AYe8zOOjNx+6aouyLsnmO1YBw0EXUIYuYpZehtRrhv+aE8srkAU678BBgAnlktO Zhe0IPxJuBErtUIqlAbeHZnlPMKR19Xt/EbSoT23lMCD/uRIJ3JMZ5JMN9z+9Wgv7d9Abf+DY+cPO 3UMCgJMAQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kks56-00034v-SZ; Thu, 03 Dec 2020 17:07:48 +0000 Received: from mail-lf1-x144.google.com ([2a00:1450:4864:20::144]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kks54-00034L-EG for linux-arm-kernel@lists.infradead.org; Thu, 03 Dec 2020 17:07:47 +0000 Received: by mail-lf1-x144.google.com with SMTP id d8so3813079lfa.1 for ; Thu, 03 Dec 2020 09:07:43 -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=+MQyiUOcMt6gFRBNfnN0H07pYjhZgF4qm1+bZjvfjTY=; b=Cx6oEw3asYjWnT8nYuCvr3UMa7sC7zqGfjZH+6NM/LRsctzlYBq4jWYT5t+CTuzy81 ufA/35gbWjoyI3GR4sHKJJ/dXIYNWsy/BxrQVF9OwKV8d6p4mG8Br2zZ9qAR1jhR1sR5 XFtBts/povF4EP6Ny/d1T5ZXYf5b7sm8jc1Iq+39jvlvaKhZ804pJUPhzTdzV+xw97qN T4REXRSQqTMIj7T7Nw8GXA7uRLUe6tmfZ+hAOZ2AadWxtejiV4KjYgBy29l+9CK6RmgP /m7bEmZBumCr+ghR9RTNKJtACi6yZ1mK18q6oD/IvZz6axncMy9glbpDQAxZ3Bj+bHAk 275w== 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=+MQyiUOcMt6gFRBNfnN0H07pYjhZgF4qm1+bZjvfjTY=; b=NUa71sTwryVMJMjEkTBK0KRmXgyfo5welmRKCVc1gbjvEsydUNeZiLw1uRL6XYHkzD LJhCHg9qQ90UgZ6RjxGRsLaEMcib/HyhPPZmfQgNPbhqnhHNVk0nzqDSlEiH7V35AEqA Atsc7eS/nWqi8pQNN3cNwFtCZNNzM710PEEqYKu1gwUqC1H2qtzujd7fYmedWBiPFAi8 CdaQfnyPlEUrQiXFJlfLvBAqzU3LCVISv2IziF3yHLVa67lPjPuMXCjbqyC49QR1BmTV +zec910AslVh/kjHWXWJk6YCltSdAgBjvMENeytw2BgeRSi7bW94F7+3OwOaQCX/yaJC 01YQ== X-Gm-Message-State: AOAM532w8YT+8xkrc32HL6Z4P7z5Eyjc3Fz6cihzA6BEQXJns2eHAvrP TsCjCRe8PRqMZy9V0a3yFUDprpXS6vST2a6ZGquRuA== X-Google-Smtp-Source: ABdhPJyeNpRimBzFqDhGioLOrE5ouq1kJk4Pby6GpAHMXjB75Cnj+2lIjlrUJWt+qddSs9EdyIaV3e9wcFRpPEdvaH8= X-Received: by 2002:a19:c815:: with SMTP id y21mr1656793lff.589.1607015262357; Thu, 03 Dec 2020 09:07:42 -0800 (PST) MIME-Version: 1.0 References: <20201201213707.541432-1-samitolvanen@google.com> <20201203112622.GA31188@willie-the-truck> In-Reply-To: <20201203112622.GA31188@willie-the-truck> From: Sami Tolvanen Date: Thu, 3 Dec 2020 09:07:30 -0800 Message-ID: Subject: Re: [PATCH v8 00/16] Add support for Clang LTO To: Will Deacon , Nick Desaulniers , Nathan Chancellor X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201203_120746_527901_85BE5E45 X-CRM114-Status: GOOD ( 26.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch , Kees Cook , "Paul E. McKenney" , Kernel Hardening , Peter Zijlstra , Greg Kroah-Hartman , Masahiro Yamada , linux-kbuild , PCI , LKML , Steven Rostedt , clang-built-linux , Josh Poimboeuf , linux-arm-kernel Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Dec 3, 2020 at 3:26 AM Will Deacon wrote: > > Hi Sami, > > On Tue, Dec 01, 2020 at 01:36:51PM -0800, Sami Tolvanen wrote: > > This patch series adds support for building the kernel with Clang's > > Link Time Optimization (LTO). In addition to performance, the primary > > motivation for LTO is to allow Clang's Control-Flow Integrity (CFI) > > to be used in the kernel. Google has shipped millions of Pixel > > devices running three major kernel versions with LTO+CFI since 2018. > > > > Most of the patches are build system changes for handling LLVM > > bitcode, which Clang produces with LTO instead of ELF object files, > > postponing ELF processing until a later stage, and ensuring initcall > > ordering. > > > > Note that arm64 support depends on Will's memory ordering patches > > [1]. I will post x86_64 patches separately after we have fixed the > > remaining objtool warnings [2][3]. > > I took this series for a spin, with my for-next/lto branch merged in but > I see a failure during the LTO stage with clang 11.0.5 because it doesn't > understand the '.arch_extension rcpc' directive we throw out in READ_ONCE(). I just tested this with Clang 11.0.0, which I believe is the latest 11.x version, and the current Clang 12 development branch, and both work for me. Godbolt confirms that '.arch_extension rcpc' is supported by the integrated assembler starting with Clang 11 (the example fails with 10.0.1): https://godbolt.org/z/1csGcT What does running clang --version and ld.lld --version tell you? > We actually check that this extension is available before using it in > the arm64 Kconfig: > > config AS_HAS_LDAPR > def_bool $(as-instr,.arch_extension rcpc) > > so this shouldn't happen. I then realised, I wasn't passing LLVM_IAS=1 > on my Make command line; with that, then the detection works correctly > and the LTO step succeeds. > > Why is it necessary to pass LLVM_IAS=1 if LTO is enabled? I think it > would be _much_ better if this was implicit (or if LTO depended on it). Without LLVM_IAS=1, Clang uses two different assemblers when LTO is enabled: the external GNU assembler for stand-alone assembly, and LLVM's integrated assembler for inline assembly. as-instr tests the external assembler and makes an admittedly reasonable assumption that the test is also valid for inline assembly. I agree that it would reduce confusion in future if we just always enabled IAS with LTO. Nick, Nathan, any thoughts about this? Sami _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 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=-13.2 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no 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 5BFCEC433FE for ; Thu, 3 Dec 2020 17:08:04 +0000 (UTC) Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.kernel.org (Postfix) with SMTP id 5310A207AF for ; Thu, 3 Dec 2020 17:08:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5310A207AF Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernel-hardening-return-20516-kernel-hardening=archiver.kernel.org@lists.openwall.com Received: (qmail 10228 invoked by uid 550); 3 Dec 2020 17:07:54 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Received: (qmail 10205 invoked from network); 3 Dec 2020 17:07:54 -0000 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=+MQyiUOcMt6gFRBNfnN0H07pYjhZgF4qm1+bZjvfjTY=; b=Cx6oEw3asYjWnT8nYuCvr3UMa7sC7zqGfjZH+6NM/LRsctzlYBq4jWYT5t+CTuzy81 ufA/35gbWjoyI3GR4sHKJJ/dXIYNWsy/BxrQVF9OwKV8d6p4mG8Br2zZ9qAR1jhR1sR5 XFtBts/povF4EP6Ny/d1T5ZXYf5b7sm8jc1Iq+39jvlvaKhZ804pJUPhzTdzV+xw97qN T4REXRSQqTMIj7T7Nw8GXA7uRLUe6tmfZ+hAOZ2AadWxtejiV4KjYgBy29l+9CK6RmgP /m7bEmZBumCr+ghR9RTNKJtACi6yZ1mK18q6oD/IvZz6axncMy9glbpDQAxZ3Bj+bHAk 275w== 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=+MQyiUOcMt6gFRBNfnN0H07pYjhZgF4qm1+bZjvfjTY=; b=L/gRcv3yqR4PZL4eP3x//ZpPteNfjox/BXESRzoCB80KRjEkJNSmMSLzoE2vU0TnC3 hCOI6Cx+pOR0ebw88Ud1wGKI5aeLni2trYeidp/yq2F3P6gmrc244Nky4e3IhIGHQ8KD FiWq4fCCJ/Y92UAuY1dobr6vwYtXCH9dEu64TajUdwl/6sDXnrA7vRd3O39s6zAGLSJV ad5TynHtAO8hatSceiVc4NTu1Q+gP6h5qm9P2PW51AYKi+R/ROkTE3KvOPUMMBkzVej8 3xeykfhP/ED6R+tLO1RKC1OBJR2VlM4P5gJFwkA9TFI213jgM+IpP+CUQCy9kFy0ixcu EmVA== X-Gm-Message-State: AOAM531OP6OkDgrKXUvoAadvaqCA6jywVEH9o9y34DxTg2JOWRNp6iuK 9SqEqC/v5ftwKqUpWlfEl6ZXBTazhtkr3N5HN1TxPw== X-Google-Smtp-Source: ABdhPJyeNpRimBzFqDhGioLOrE5ouq1kJk4Pby6GpAHMXjB75Cnj+2lIjlrUJWt+qddSs9EdyIaV3e9wcFRpPEdvaH8= X-Received: by 2002:a19:c815:: with SMTP id y21mr1656793lff.589.1607015262357; Thu, 03 Dec 2020 09:07:42 -0800 (PST) MIME-Version: 1.0 References: <20201201213707.541432-1-samitolvanen@google.com> <20201203112622.GA31188@willie-the-truck> In-Reply-To: <20201203112622.GA31188@willie-the-truck> From: Sami Tolvanen Date: Thu, 3 Dec 2020 09:07:30 -0800 Message-ID: Subject: Re: [PATCH v8 00/16] Add support for Clang LTO To: Will Deacon , Nick Desaulniers , Nathan Chancellor Cc: Masahiro Yamada , Steven Rostedt , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , clang-built-linux , Kernel Hardening , linux-arch , linux-arm-kernel , linux-kbuild , LKML , PCI Content-Type: text/plain; charset="UTF-8" On Thu, Dec 3, 2020 at 3:26 AM Will Deacon wrote: > > Hi Sami, > > On Tue, Dec 01, 2020 at 01:36:51PM -0800, Sami Tolvanen wrote: > > This patch series adds support for building the kernel with Clang's > > Link Time Optimization (LTO). In addition to performance, the primary > > motivation for LTO is to allow Clang's Control-Flow Integrity (CFI) > > to be used in the kernel. Google has shipped millions of Pixel > > devices running three major kernel versions with LTO+CFI since 2018. > > > > Most of the patches are build system changes for handling LLVM > > bitcode, which Clang produces with LTO instead of ELF object files, > > postponing ELF processing until a later stage, and ensuring initcall > > ordering. > > > > Note that arm64 support depends on Will's memory ordering patches > > [1]. I will post x86_64 patches separately after we have fixed the > > remaining objtool warnings [2][3]. > > I took this series for a spin, with my for-next/lto branch merged in but > I see a failure during the LTO stage with clang 11.0.5 because it doesn't > understand the '.arch_extension rcpc' directive we throw out in READ_ONCE(). I just tested this with Clang 11.0.0, which I believe is the latest 11.x version, and the current Clang 12 development branch, and both work for me. Godbolt confirms that '.arch_extension rcpc' is supported by the integrated assembler starting with Clang 11 (the example fails with 10.0.1): https://godbolt.org/z/1csGcT What does running clang --version and ld.lld --version tell you? > We actually check that this extension is available before using it in > the arm64 Kconfig: > > config AS_HAS_LDAPR > def_bool $(as-instr,.arch_extension rcpc) > > so this shouldn't happen. I then realised, I wasn't passing LLVM_IAS=1 > on my Make command line; with that, then the detection works correctly > and the LTO step succeeds. > > Why is it necessary to pass LLVM_IAS=1 if LTO is enabled? I think it > would be _much_ better if this was implicit (or if LTO depended on it). Without LLVM_IAS=1, Clang uses two different assemblers when LTO is enabled: the external GNU assembler for stand-alone assembly, and LLVM's integrated assembler for inline assembly. as-instr tests the external assembler and makes an admittedly reasonable assumption that the test is also valid for inline assembly. I agree that it would reduce confusion in future if we just always enabled IAS with LTO. Nick, Nathan, any thoughts about this? Sami