Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1643897ybl; Fri, 30 Aug 2019 23:09:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwvak8lN7R1VrgeGEAiDflzYjS/+p+muWKADdzEJhaBlbPKOqiT2H/iGoNEdcG77NmS93XV X-Received: by 2002:a17:902:6a8c:: with SMTP id n12mr19244936plk.159.1567231771794; Fri, 30 Aug 2019 23:09:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567231771; cv=none; d=google.com; s=arc-20160816; b=eskSNFLIYtODcXNmCcvMmjt7SIIdidn+oQuFMoyM+z930rrTddQJyKV8+jn1nfhsjH xD169id83EHiJIui4VMdpYV/XgFSgYqTB9ca1DpRFF3STWNgOKVIxW8JD8oudqUzY+uh UhUmZQFwDTO9w+oLXYEU8ByVEMNIYdRj2/BVwptv75vap74NJMVLAfIF0iLTH3jE1kyw 0sRyq5RZ5BeGfguFh5do8JWmrN0NFs3E/PkQP/khsHO2RALuxmgxvpVa/K3cR6fWMG2z WPz2WCzUvlj4aV4oqa2Fd9xtr7El0jcm9oeo1KTpt/11MNdGEPsHl0bIVpZGyV28oRhB 5P5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3NQT/+H/R/Gs9klh5utfpPtpga01Z/bPDqOTKDdobn4=; b=U6hLSmouPm12weEWywJkUAI+OviKadvwsnMfrvuwzJiwTDaTf/NXKgSJB+Ll6/3gLn /Hxbzb0qO/5dw5V7x8r/EfWi8gcrFjAqFFiSiQWrAgOwbzDGMMODsmvhNB3muOa2QB2a 8nud4VqPS2jUkCn7x7qS1SAzc5ePLfa+3Rn2qRtmktUjwV7x1acZmPsxR2n251QX/Kqz /IbW0cVynneFTMNOYduIJSC1rrup/m5Ue+a7j8sCJi9v5hyKxeV0cSbFlw0/htod9oCX uDeXjqgpWOyLgCQmbyI/vI805IPV9ZhaVxZ8vn1laDAyce4DaWzDu7CT3HBtWmJicMks s31g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pKEWbtp8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q23si6655439pll.430.2019.08.30.23.09.16; Fri, 30 Aug 2019 23:09:31 -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=@gmail.com header.s=20161025 header.b=pKEWbtp8; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726135AbfHaGI3 (ORCPT + 99 others); Sat, 31 Aug 2019 02:08:29 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:34429 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725298AbfHaGI2 (ORCPT ); Sat, 31 Aug 2019 02:08:28 -0400 Received: by mail-wm1-f67.google.com with SMTP id y135so5769949wmc.1 for ; Fri, 30 Aug 2019 23:08:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3NQT/+H/R/Gs9klh5utfpPtpga01Z/bPDqOTKDdobn4=; b=pKEWbtp87WRZkEQMPoUvMKiZmvK2H8bkjGIN+0ebQE+E197iGUHa9IAGOWKmbsMfEq tnOBAuY6AFPzlCfvboxOuNVBv0Ex1TGDpHIvyOdnATwBPrc7tJz7n0pv1isYTulaDwOm qL0dcdbhLC1bCIMwgGTg80g+FerKedCkM++fyDd6epwt4AoHlNVwyuabMeLQsWySEPzM tFxCP0d5W6dAAzjQaZUugV4qwX0/5N2ObXN/d/faL4BbZOAyEoErgPr/ZJonrOemhQNo +WnvEbXtP3BnGCBrUI7jRzAWq/sWhqoEpDu4UKykoVggVB/INMt3GTobFset8lE/TgK5 tFEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=3NQT/+H/R/Gs9klh5utfpPtpga01Z/bPDqOTKDdobn4=; b=Yp716rdlbGB5CjcCgF8cP+ELzpWbksIiqIhePtTeFCkofSRNROqfptzgBhx1pK5kge IfRHGnMwkD74IryfFo++x24Mpe7/fOwG8qJ99SAY8gR/CjWEfzCbOf4ITQAvLztdqLRQ 3TO05NVNLGBir2w+IxEI+XhUV29Q4P3qWidjRSo1lZnAXqgPRDHS4Xhecm9QO1Tsqxmt u0iq5FLbxH9Yd3V+AFMVwrvezH2ZBkVwUWTgrfdKLW/2RekkzL/qgbd+Y5cozmJEzNOI +9EDZ+Z2V186Tz1BeHAtTXaCcMVQ+s/G2e35wicZa1k4oLgBLHpWWa0a6hAcu7VevBNH 77YQ== X-Gm-Message-State: APjAAAV8xOzioc85ZsBjs7SWJr5IyDrwB/sPtdFJqN67DoezWRSy0j0N 5ViB96RJ0wBN8SXy2oPbVAs= X-Received: by 2002:a1c:2b85:: with SMTP id r127mr7079242wmr.30.1567231706449; Fri, 30 Aug 2019 23:08:26 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f8:222:2f1b::2]) by smtp.gmail.com with ESMTPSA id l62sm14708814wml.13.2019.08.30.23.08.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Aug 2019 23:08:25 -0700 (PDT) From: Nathan Chancellor To: Russell King Cc: Arnd Bergmann , Matthias Kaehlcke , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor , Nick Desaulniers , Stefan Agner Subject: [PATCH v2] ARM: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer Date: Fri, 30 Aug 2019 23:05:31 -0700 Message-Id: <20190831060530.43082-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190829062635.45609-1-natechancellor@gmail.com> References: <20190829062635.45609-1-natechancellor@gmail.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 with '-pg' because the calling convention was not correct. Always build with '-meabi gnu' when using clang but ensure that '-pg' (which is added with CONFIG_FUNCTION_TRACER and its prereq CONFIG_HAVE_FUNCTION_TRACER) cannot be added with it unless this is fixed (which means using clang 10.0.0 and newer). 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 Reviewed-by: Nick Desaulniers Reviewed-by: Stefan Agner Signed-off-by: Nathan Chancellor --- v1 -> v2: * Add Nick and Stefan's reviewed by tags * Move version check from Makefile to Kconfig. This prevents '-pg` from ever being added if '-meabi gnu' would produce a non-booting kernel and it allows clang 9.0.0 and earlier to build and link all*config kernels because the function tracer can't be selected. arch/arm/Kconfig | 2 +- arch/arm/Makefile | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index a98c7af50bf0..440ad41e77e4 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -83,7 +83,7 @@ config ARM select HAVE_FAST_GUP if ARM_LPAE select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG - select HAVE_FUNCTION_TRACER if !XIP_KERNEL + select HAVE_FUNCTION_TRACER if !XIP_KERNEL && (CC_IS_GCC || CLANG_VERSION >= 100000) select HAVE_GCC_PLUGINS select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7) select HAVE_IDE if PCI || ISA || PCMCIA diff --git a/arch/arm/Makefile b/arch/arm/Makefile index a43fc753aa53..aa7023db66c7 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -115,6 +115,10 @@ ifeq ($(CONFIG_ARM_UNWIND),y) CFLAGS_ABI +=-funwind-tables endif +ifeq ($(CONFIG_CC_IS_CLANG),y) +CFLAGS_ABI += -meabi gnu +endif + # Accept old syntax despite ".syntax unified" AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W) -- 2.23.0