Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2851913ybl; Thu, 29 Aug 2019 13:58:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxP+TcWqRkS14B/Z0Fh8xgkGEM6/Uj22WpF96rIsPGGV5AnVAz4H6b87Jy3nwHQ+7b6byj0 X-Received: by 2002:aa7:8498:: with SMTP id u24mr14129203pfn.61.1567112339779; Thu, 29 Aug 2019 13:58:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567112339; cv=none; d=google.com; s=arc-20160816; b=tuGYDGTnOwcMe3o3+YITTWfrK3f/NUvBRKicJo/xFgnP7riI2PKx58D/2kNZEtANRz nHHSXzi+ON9RaGlR6pksnF7JytNKHakZ8OQ1LzGBQG+KJkP2u/aZLGF0TDnFygZMFR8s TkD2DbYBhslGpQcBv7KMVYKMSmBZzpvtKuqReRSfVN+FMIrml0kznsInMiM1HTOzz1DK ob/CVB66waOnotmVHCOKbYmIPL0DlQRlXku3ytYfad6o1vmBiW2QS/RzoAywQmmXJfbO nXv3YdJe9qUKVMAZnvNHF8Jbx87+fOAMLDzlH0/cieXcQj9QKhsLch67F9P6dqqg7IAi L9wQ== 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=oeDSTDmCykdOboI0NlO40BAz1xd+JSb526zs42hsg2U=; b=XQeTDmasWTxWdKUzkHzAnvJnev2u0oYdndVdkET/v0roXw79s+9enpm5OZYRuMX/OA 1AXpvYeuA5VQluxGIqazyXrS2HCYrP1dG0nOZVctZ9ist6ADwJHzYBxBivyU/eQOfzWK z5Qxb2Ph/g9cJvMNqFqaZtFB/7fo+BzguS3obWoW/gOy7+4gA2IEfBKDum9T3utlRk0D q/NEb73fcnK/RX4D3ondncbD6E3kpubltDcQK/Zpqhcxmki45hedivCPPIPyYSYfcXJg igYUuCFK91DumJlH8kJg3hkZs2enU90Q1BD/kqbNtSx7RHDJWEMnLcJqIT29FzCKIp19 oL9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=wWMz75Bi; 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 q11si2945384pgq.282.2019.08.29.13.58.43; Thu, 29 Aug 2019 13:58:59 -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=wWMz75Bi; 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 S1728148AbfH2U5s (ORCPT + 99 others); Thu, 29 Aug 2019 16:57:48 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:45862 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726944AbfH2U5s (ORCPT ); Thu, 29 Aug 2019 16:57:48 -0400 Received: by mail-pg1-f195.google.com with SMTP id o13so2215497pgp.12 for ; Thu, 29 Aug 2019 13:57:47 -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=oeDSTDmCykdOboI0NlO40BAz1xd+JSb526zs42hsg2U=; b=wWMz75BiWBHHLdLBIU+n9B/CTKoZ8dnq7ADjr5OGkRKToC9bRZONCKrh+s/7WxD7P7 Z3PvHQvDI/bCbDi3VZY+VBuWDE/OQMsYWdFaW948gYKyR6kSLUafPqt6V4FhN6A7wCIP uVYhYBK9kBRw1O318HxJm2hltIhZlolHYQfOjz6V8gOleVd8jMrQyPQByQeWmVk9Sn2u Auy3+9mHeWDUhVQ5kfe8o3iYFRgS5ETL2v5fuVn6ilMiDSsXtY7dMF16ndW4htSfXPV1 /+rImTVhTYSOsPQ55Q+dbV55VJlWRxSavFs1RoGuZNaMNfRveYw764+z2zbZ0XrxGaRt Resw== 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=oeDSTDmCykdOboI0NlO40BAz1xd+JSb526zs42hsg2U=; b=kilGqWMd9I1kE8R3lxlNdodVOd1JyY7e1UjT0lpw9XtqzgKrqlft9wh9HEz9vcjVi4 xBj44soMghVo+fKpcz2d0EpRZBcCLGbxY/wpKu8Dpq7DdqiaH4A8PXLKZnhwcICuLuPO dKmPgqEbPybEOP/mB43HoBIS5dnJP82y7ypnia+BfKBTzQSwccIZU9mu2w5Z2YNM2QSW hufb99rXMLsEYP2GKbCyYa8D8JAxuPuzqbYTjTjb7L+KSp9MTKmtfX5pLvil9fkhbY8S PKZB9RxUJMC5gPxNytFR7XvPN5GVUofIuXmDEU1lez7B920gAIvC6/LZXLa7HaTBWXp0 UFBA== X-Gm-Message-State: APjAAAVTaitJ9gJHg6N1yN0uKTu2crAcIcH5/SKpewb2NYyUel2btrHb jI8x39U21spoLbcPm8DVJgnzJnkkgjGTcLCG0XhOUQ== X-Received: by 2002:a17:90a:c20f:: with SMTP id e15mr11791171pjt.123.1567112267046; Thu, 29 Aug 2019 13:57:47 -0700 (PDT) MIME-Version: 1.0 References: <20190829062635.45609-1-natechancellor@gmail.com> <20190829193432.GA10138@archlinux-threadripper> <885bb20c11f0cb004e5eeda7b0ca6d16@agner.ch> In-Reply-To: <885bb20c11f0cb004e5eeda7b0ca6d16@agner.ch> From: Nick Desaulniers Date: Thu, 29 Aug 2019 13:57:35 -0700 Message-ID: Subject: Re: [PATCH] ARM: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer To: Stefan Agner Cc: Nathan Chancellor , Russell King , Arnd Bergmann , Matthias Kaehlcke , Linux ARM , LKML , clang-built-linux 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 Thu, Aug 29, 2019 at 1:21 PM Stefan Agner wrote: > > On 2019-08-29 21:34, Nathan Chancellor wrote: > > On Thu, Aug 29, 2019 at 10:55:28AM -0700, Nick Desaulniers wrote: > >> On Wed, Aug 28, 2019 at 11:27 PM Nathan Chancellor > >> wrote: > >> > > >> > Currently, multi_v7_defconfig + CONFIG_FUNCTION_TRACER fails to build > >> > with clang: > >> > > >> > arm-linux-gnueabi-ld: kernel/softirq.o: in function `_local_bh_enable': > >> > softirq.c:(.text+0x504): undefined reference to `mcount' > >> > arm-linux-gnueabi-ld: kernel/softirq.o: in function `__local_bh_enable_ip': > >> > softirq.c:(.text+0x58c): undefined reference to `mcount' > >> > arm-linux-gnueabi-ld: kernel/softirq.o: in function `do_softirq': > >> > softirq.c:(.text+0x6c8): undefined reference to `mcount' > >> > arm-linux-gnueabi-ld: kernel/softirq.o: in function `irq_enter': > >> > softirq.c:(.text+0x75c): undefined reference to `mcount' > >> > arm-linux-gnueabi-ld: kernel/softirq.o: in function `irq_exit': > >> > softirq.c:(.text+0x840): undefined reference to `mcount' > >> > arm-linux-gnueabi-ld: kernel/softirq.o:softirq.c:(.text+0xa50): more undefined references to `mcount' follow > >> > > >> > clang can emit a working mcount symbol, __gnu_mcount_nc, when > >> > '-meabi gnu' is passed to it. Until r369147 in LLVM, this was > >> > broken and caused the kernel not to boot because the calling > >> > convention was not correct. Now that it is fixed, add this to > >> > the command line when clang is 10.0.0 or newer so everything > >> > works properly. > >> > > >> > Link: https://github.com/ClangBuiltLinux/linux/issues/35 > >> > Link: https://bugs.llvm.org/show_bug.cgi?id=33845 > >> > Link: https://github.com/llvm/llvm-project/commit/16fa8b09702378bacfa3d07081afe6b353b99e60 > >> > Signed-off-by: Nathan Chancellor > >> > --- > >> > arch/arm/Makefile | 6 ++++++ > >> > 1 file changed, 6 insertions(+) > >> > > >> > diff --git a/arch/arm/Makefile b/arch/arm/Makefile > >> > index c3624ca6c0bc..7b5a26a866fc 100644 > >> > --- a/arch/arm/Makefile > >> > +++ b/arch/arm/Makefile > >> > @@ -112,6 +112,12 @@ ifeq ($(CONFIG_ARM_UNWIND),y) > >> > CFLAGS_ABI +=-funwind-tables > >> > endif > >> > > >> > +ifeq ($(CONFIG_CC_IS_CLANG),y) > >> > +ifeq ($(shell test $(CONFIG_CLANG_VERSION) -ge 100000; echo $$?),0) > >> > +CFLAGS_ABI +=-meabi gnu > >> > +endif > >> > +endif > >> > + > >> > >> Thanks for the patch! I think this is one of the final issues w/ 32b > >> ARM configs when building w/ Clang. > >> > >> I'm not super enthused about the version check. The flag is indeed > >> not recognized by GCC, but I think it would actually be more concise > >> with $(cc-option) and no compiler or version check. > >> > >> Further, I think that the working __gnu_mcount_nc in Clang would > >> better be represented as marking the arch/arm/KConfig option for > >> CONFIG_FUNCTION_TRACER for dependent on a version of Clang greater > >> than or equal to Clang 10, not conditionally adding this flag. (We > >> should always add the flag when supported, IMO. __gnu_mcount_nc's > >> calling convention being broken is orthogonal to the choice of > >> __gnu_mcount_nc vs mcount, and it's the former's that should be > >> checked, not the latter as in this patch. > > > > I will test with or without CONFIG_AEABI like Matthias asked and I will > > implement your Kconfig suggestion if it passes all of my tests. The > > reason that I did it this way is because I didn't want a user to end up > > with a non-booting kernel since -meabi gnu works with older versions of > > clang at build time, the issue happens at boot time but the Kconfig > > suggestion + cc-option should fix that. > > I agree with Nathan here, I'd rather prefer the build system to fail > building rather than runtime error. > > If we decide we want to have it building despite it not building a > functional kernel, we should at least add a #warning... Just to be clear...I was suggesting a build failure, but for __gnu_mcount_nc not having the correct calling convention in older clang releases, which is orthogonal to passing `-meabi gnu`. This patch uses the __gnu_mcount_nc calling convention problem to justify a version check for a flag that while closely related, is not actually the problem, IMO. -- Thanks, ~Nick Desaulniers