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.3 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,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 0DD86C433FE for ; Tue, 8 Dec 2020 16:54:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D039523A79 for ; Tue, 8 Dec 2020 16:54:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730138AbgLHQyi (ORCPT ); Tue, 8 Dec 2020 11:54:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728602AbgLHQyh (ORCPT ); Tue, 8 Dec 2020 11:54:37 -0500 Received: from mail-vk1-xa42.google.com (mail-vk1-xa42.google.com [IPv6:2607:f8b0:4864:20::a42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BF76C061793 for ; Tue, 8 Dec 2020 08:53:57 -0800 (PST) Received: by mail-vk1-xa42.google.com with SMTP id l187so1724629vki.6 for ; Tue, 08 Dec 2020 08:53:57 -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=l5zve3QgoBiHLvxkhbeIQQ8L+c1shM0AySo9iJPfdLI=; b=tcWjcUsoxU6SpDxMxfUujxhJGgNiN0OcrzVgHRXE+pbJuNC7SLmXfBUI75eINJCzON G0nY39F1EVNqZripZe6gbBqfZzjuLM84h1W0NmIJ9jvGryhhLgEOXTrybPsOQT8GLnc8 KUcGz9aiF8dfaNJXcsm4ma4k42S8fJ72oEzmlNAlfhp/cRlYwKUgc/vMzXaoCHGAiAQz Fv8ITYgJz1voaC3m4n36riFKsJeJiarjPn95yOG7ac8eVlG7dHlzrZ6kvmUTf+Y5xSqG 1a1WQigfWfhFFyxkOxdgAlObdqquWglgAenkMnogNlCbuvVFB7EBjDeKD1KOeC3meePi dfuA== 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=l5zve3QgoBiHLvxkhbeIQQ8L+c1shM0AySo9iJPfdLI=; b=JdNhFmRdujPKwoW6H0RSooGkM3t08lqu6ZIwEKsws58mGdkaIKm7zCHDZa2ndEbpfv XcnRQLEbV3WNps8sx6nxVBMBuuKbALMy5qRLC0OD7Ys3rQDUw5RS92n3pKTbDRA94cw2 yWsRlo+/f3XzurOQWXpjnEpeHjaixzO2uwmMPOgXRu39LETtZBCiAvuZ37q034yZ0efR Uishe2d1kksa93pQQTq5rzYEERGtvI/yYaihAxAQVcaZbZjwS3CXy8vok3C9wcbfzNDC 6OoqlATGlv4VyDPu9VzY1fo8hEfxx6qaFpknNXV4DN0H+KqLPn7wvgDPx9sdYvjAEo/F wKIw== X-Gm-Message-State: AOAM530VrJb0AnvLV5q7tE3TYXCejA7hOAfS1uDZeA0PMEZSdOp+ccyj MdMk21btb+FRFw5/iD28o49Bq+FINKAoa8bxk0n7aA== X-Google-Smtp-Source: ABdhPJxgg0AuBgAyNX33MRQChfKNjBy/l6I+d3qFW7cDxguUPeYCwHRH9XJaUc5ctnBi5qE5LUaYex6e2Q3DEwkWc2E= X-Received: by 2002:a1f:b245:: with SMTP id b66mr17138078vkf.3.1607446436156; Tue, 08 Dec 2020 08:53:56 -0800 (PST) MIME-Version: 1.0 References: <20201201213707.541432-1-samitolvanen@google.com> In-Reply-To: From: Sami Tolvanen Date: Tue, 8 Dec 2020 08:53:44 -0800 Message-ID: Subject: Re: [PATCH v8 00/16] Add support for Clang LTO To: Arnd Bergmann Cc: Masahiro Yamada , Steven Rostedt , Will Deacon , Josh Poimboeuf , Peter Zijlstra , Greg Kroah-Hartman , "Paul E. McKenney" , Kees Cook , Nick Desaulniers , clang-built-linux , Kernel Hardening , linux-arch , Linux ARM , Linux Kbuild mailing list , "linux-kernel@vger.kernel.org" , linux-pci Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 8, 2020 at 5:55 AM Arnd Bergmann wrote: > > On Tue, Dec 8, 2020 at 1:15 PM Arnd Bergmann wrote: > > On Tue, Dec 1, 2020 at 10:37 PM 'Sami Tolvanen' via Clang Built Linux wrote: > > > > - many builds complain about thousands of duplicate symbols in the kernel, e.g. > > ld.lld: error: duplicate symbol: qrtr_endpoint_post > > >>> defined in net/qrtr/qrtr.lto.o > > >>> defined in net/qrtr/qrtr.o > > ld.lld: error: duplicate symbol: init_module > > >>> defined in crypto/842.lto.o > > >>> defined in crypto/842.o > > ld.lld: error: duplicate symbol: init_module > > >>> defined in net/netfilter/nfnetlink_log.lto.o > > >>> defined in net/netfilter/nfnetlink_log.o > > ld.lld: error: duplicate symbol: vli_from_be64 > > >>> defined in crypto/ecc.lto.o > > >>> defined in crypto/ecc.o > > ld.lld: error: duplicate symbol: __mod_of__plldig_clk_id_device_table > > >>> defined in drivers/clk/clk-plldig.lto.o > > >>> defined in drivers/clk/clk-plldig.o > > A small update here: I see this behavior with every single module > build, including 'tinyconfig' with one module enabled, and 'defconfig'. The .o file here is a thin archive of the bitcode files for the module. We compile .lto.o from that before modpost, because we need an ELF binary to process, and then reuse the .lto.o file when linking the final module. At no point should we link the .o file again, especially not with .lto.o, because that would clearly cause every symbol to be duplicated, so I'm not sure what goes wrong here. Here's the relevant part of scripts/Makefile.modfinal: ifdef CONFIG_LTO_CLANG # With CONFIG_LTO_CLANG, reuse the object file we compiled for modpost to # avoid a second slow LTO link prelink-ext := .lto ... $(modules): %.ko: %$(prelink-ext).o %.mod.o scripts/module.lds FORCE +$(call if_changed,ld_ko_o) Sami