Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3560983ybb; Mon, 6 Apr 2020 11:03:45 -0700 (PDT) X-Google-Smtp-Source: APiQypL2XlVlYC9WjVJ1pIykNNwHzv0zTmAt2wiXvf6a9g4WryBhmJPkXvB/mmYkuUbrW2CC0A15 X-Received: by 2002:aca:abcd:: with SMTP id u196mr482975oie.86.1586196225446; Mon, 06 Apr 2020 11:03:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586196225; cv=none; d=google.com; s=arc-20160816; b=Caxc9KvhA9MWdTml9wbNXOqnTE8KqlFDGrkLJzsjZDPU0NSl9B4kF3P5c5IxC/h1uG KVeLXJ5bgSM4axR2K4mXUmI2VULWjoeuu7bkJHsQTA+ke38JYPUG/UetawAUVobLHnyp BcfsP6vLvykyBkDgwjcLqUfJS+GfUXALhV/ezCo5+6AI5F4+DYF4sH6NDUgD1gnaYrSe fcHf6iaFqNEqsg1z5wtnK/9nM76lmt6N1MfUssHYQt+d8wXEx5H0Q5qLLI/SUIcWw7zI +ckIUA/fGtiW8AfGtgxkX+3tEX70L6xQdjVTgRHbsCbaTWB4R3i+oZgx8y8cpEeCYA4p 7F4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=6e1Q4vKzJzmKGtNiNjd8gFNJAJWEC5ayrvQVjXOX/iA=; b=vAL1cwGyqSd+Z0VKG4GZL2mQR2/4/8esOBVCOxyuTv9rOvecEAf9W8+EXqbaOiTMPW GXn2yDiWLbPlig/AgsKbVb58KwzI+6FJncnUgEa2YBl8naTLbKy5JyVqZVJa2vZVCK15 bDhgwfSomm4HkZZVF6n7/++StckA7HKuZfsOr9CFWpDU1El4IUnQ98vpMeZjaYYl9rae GVNN5p218ZU5zPltoNMYp5Ev9b3ml1l3EO6Z6Xkbr/NFRqaAeN6w9wg2VkpiU3cJgo0J iukREzezRl3gsWQwcxO0YgpCnUFBN5JpdhcyxJiyypF/cJwjlUokqpYOxA099YHxuszc L9bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VKzVFvDb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id z24si136634otp.207.2020.04.06.11.03.30; Mon, 06 Apr 2020 11:03:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VKzVFvDb; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1726720AbgDFSCl (ORCPT + 99 others); Mon, 6 Apr 2020 14:02:41 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42516 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgDFSCl (ORCPT ); Mon, 6 Apr 2020 14:02:41 -0400 Received: by mail-pg1-f195.google.com with SMTP id g6so332446pgs.9 for ; Mon, 06 Apr 2020 11:02:38 -0700 (PDT) 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=6e1Q4vKzJzmKGtNiNjd8gFNJAJWEC5ayrvQVjXOX/iA=; b=VKzVFvDbHxCrHuz1BGNeFLrQzjOqXm308/UzV4dy7t/94/5o8Eqc32uFmFoYw1GhVv YL/PJrZ5wYaWlf09YP/5Cw9aVe6InMX/KFrOUrgH1YJZJlWiq0Opcgr8ReG8QawTI274 WKtN/MWOtTpvlpHUdwxVT22pAxgnoaRhgG6I2tYHtL7RiZpTtHHQ4uZytoqFsV3Ar8ar ITcWYla8llaWu6JMF/9m/uIk+0Gwo3dkQMaEfnRI4dV96O34aZcV0bQr0GRy9DktfRs3 TkQw9r5uzIm1fP0iGYUwFSotBFCkb0R1wjfvHieZvIKI/5/QkP4n26nnVJRvQ5geQ51+ 8Uvg== 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=6e1Q4vKzJzmKGtNiNjd8gFNJAJWEC5ayrvQVjXOX/iA=; b=TkxLG7Xue/e1ZaAaPT1+viohAJMxJbHCyLE0RGEcs30DawRUMwwSV8QYeom528sult LYTQAOjsYb3BhU2fFgJ1xE8Dg3X1Er63vhybI1t65tBhBJ8IMFxWfxaEeMsmhgnM8nBN 4eUo1lqj6aiRgwp66xFyWEfzAR4TJnWuMK0VQUvpSk9Fey3T3A6nMpInFvpRHXYMLY5B 3xDWmsWamq9Tad5BTksqQRFyAPz5IsiyHFAZEFQ8QPiYpYNlO5OpH/9Gqni7P293GX27 Z0QWnbmASiMS0PkY6o8JJBgT0vumRpY9hrd17JIFzvmKSXNk2n8YUiHCZ+ZciWl6OHCq 3edg== X-Gm-Message-State: AGi0PuZS32SrqCgLkZ2h0BbGJ93tlH2bCV6lcLaiworhg/SD/fAcPaJ2 ll7QG73vGqNk68bk796mFnxfI1WjTTTJQHzRjDx/zw== X-Received: by 2002:a63:b954:: with SMTP id v20mr264508pgo.381.1586196157861; Mon, 06 Apr 2020 11:02:37 -0700 (PDT) MIME-Version: 1.0 References: <20200405163052.18942-1-masahiroy@kernel.org> In-Reply-To: From: Nick Desaulniers Date: Mon, 6 Apr 2020 11:02:27 -0700 Message-ID: Subject: Re: [PATCH] MIPS: fw: arc: add __weak to prom_meminit and prom_free_prom_memory To: "Maciej W. Rozycki" Cc: Masahiro Yamada , Linux Kbuild mailing list , Linux-MIPS , clang-built-linux , Linux Kernel Mailing List , Jiaxun Yang , Paul Burton , Thomas Bogendoerfer , linux-mips@vger.kernel.org, =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= 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 On Mon, Apr 6, 2020 at 4:54 AM Maciej W. Rozycki wrote: > > On Mon, 6 Apr 2020, Masahiro Yamada wrote: > > > > > As far as I understood, prom_meminit() in arch/mips/fw/arc/memory.c > > > > is overridden by the one in arch/mips/sgi-ip32/ip32-memory.c if > > > > CONFIG_SGI_IP32 is enabled. > > > > > > > > The use of EXPORT_SYMBOL in static libraries potentially causes a > > > > problem for the llvm linker [1]. So, I want to forcibly link lib-y > > > > objects to vmlinux when CONFIG_MODULES=y. > > > > > > It looks to me like a bug in the linker in the handling of the EXTERN > > > command. Why not fix the linker instead? > [...] > > I am not sure if this is a bug. > > Anyway, they decided to not change ld.lld > > Well, maybe that was a conscious decision, however it's a linker feature > that has been there since forever and projects like Linux can legitimately > rely on it. In this case perhaps sticking to other linkers, which have > the right features, is the right solution rather than trying to turn a > complex and mature project like Linux upside down (and quite possibly > introducing bugs and pessimisations on the way) just to match an inferior > tool. Adapt your tool to the task, not the task to your tool. The feature you refer to and the feature Masahiro is referring to are two separate issues. If you care to understand the issue Masahiro is trying to fix, please take the time to read the full discussion: https://github.com/ClangBuiltLinux/linux/issues/515 and particularly https://reviews.llvm.org/D63564 > > > MIPS code is so confusing. > > There are multiple definitions, > > and lib.a is (ab)used to hide them. > > It's a standard feature of libraries that a symbol reference is satisfied > by the first symbol definition encountered. Any extra ones provided later > in the link order are ignored. And we have control over the link order. Relying on link order is terribly brittle. Renaming a file can cause your implementation to change, and ties your hands from ever using things like LTO or newer build systems like ninja. Static initialization order is a plague to C and C++. It's explicitly undefined behavior you've just admitted you prefer to rely on. (A Google search for "static initialization order" wants to autocomplete to "static initialization order fiasco" which is also an interesting read; https://www.cryptopp.com/wiki/Static_Initialization_Order_Fiasco). Masahiro is right that this case has some questionable choices in terms of redefining symbols with different implementations. I think __HAVE_ARCH_STRCPY and friends in lib/string.c is actually the best pattern for not providing multiple definitions of a symbol, followed by marking symbols meant to be overridden at link time based on config as __weak. He's just trying to help clean this up. > > > I fixed another one for MIPS before, and > > 0-day bot reported this recently. > > > > > > There are lots of prom_meminit() definitions > > in arch/mips/. > > Naturally, many platforms will have its own, in addition to some generic > (possibly dummy) one. > > > Making the intention clearer is a good thing, IMHO. > > Hmm, what intention? Can you please be more specific? That prom_meminit and prom_free_prom_memory are meant to be overridden by other configs. -- Thanks, ~Nick Desaulniers