Skip to content

Commit 2dfe3ac

Browse files
committed
ARM: 8905/1: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer
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: ClangBuiltLinux/linux#35 Link: https://bugs.llvm.org/show_bug.cgi?id=33845 Link: llvm/llvm-project@16fa8b0 Reviewed-by: Matthias Kaehlcke <[email protected]> Reviewed-by: Nick Desaulniers <[email protected]> Reviewed-by: Stefan Agner <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Russell King <[email protected]> Link: https://git.kernel.org/linus/b0fe66cf095016e0b238374c10ae366e1f087d11 Signed-off-by: Nathan Chancellor <[email protected]>
1 parent 1c875dc commit 2dfe3ac

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

arch/arm/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ config ARM
6969
select HAVE_EXIT_THREAD
7070
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
7171
select HAVE_FUNCTION_GRAPH_TRACER if !THUMB2_KERNEL && !CC_IS_CLANG
72-
select HAVE_FUNCTION_TRACER if !XIP_KERNEL
72+
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && (CC_IS_GCC || CLANG_VERSION >= 100000)
7373
select HAVE_GCC_PLUGINS
7474
select HAVE_GENERIC_DMA_COHERENT
7575
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)

arch/arm/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ ifeq ($(CONFIG_ARM_UNWIND),y)
115115
CFLAGS_ABI +=-funwind-tables
116116
endif
117117

118+
ifeq ($(CONFIG_CC_IS_CLANG),y)
119+
CFLAGS_ABI += -meabi gnu
120+
endif
121+
118122
# Accept old syntax despite ".syntax unified"
119123
AFLAGS_NOWARN :=$(call as-option,-Wa$(comma)-mno-warn-deprecated,-Wa$(comma)-W)
120124

0 commit comments

Comments
 (0)