Skip to content

Commit b3d6bdf

Browse files
nathanchancepalmer-dabbelt
authored andcommitted
riscv: Adjust dependencies of HAVE_DYNAMIC_FTRACE selection
When building allmodconfig with clang and its integrated assembler and linking with a version of GNU ld prior to 2.36, the following link error occurs: riscv64-linux-gnu-ld: .init.data has both ordered [`__patchable_function_entries' in init/main.o] and unordered [`.init_array.0' in kernel/trace/trace_benchmark.o] sections riscv64-linux-gnu-ld: final link failed: bad value This is the same error addressed by commit 45bd895 ("arm64: Improve HAVE_DYNAMIC_FTRACE_WITH_REGS selection for clang") for arm64. See that changelog for a full description of why this error occurs with this combination of tools. In a similar manner as that change, restrict the CONFIG_HAVE_DYNAMIC_FTRACE selection to combinations of tools known to work so that there are no errors. Link: ClangBuiltLinux#1817 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Link: https://lore.kernel.org/r/20230404-riscv-dynamic-ftrace-checks-clang-v1-1-0ce296b7d423@kernel.org Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 89d77f7 commit b3d6bdf

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

arch/riscv/Kconfig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,12 +142,23 @@ config RISCV
142142
select TRACE_IRQFLAGS_SUPPORT
143143
select UACCESS_MEMCPY if !MMU
144144
select ZONE_DMA32 if 64BIT
145-
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8)
145+
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
146146
select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE
147147
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
148148
select HAVE_FUNCTION_GRAPH_TRACER
149149
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !PREEMPTION
150150

151+
config CLANG_SUPPORTS_DYNAMIC_FTRACE
152+
def_bool CC_IS_CLANG
153+
# https://github.com/llvm/llvm-project/commit/6ab8927931851bb42b2c93a00801dc499d7d9b1e
154+
depends on CLANG_VERSION >= 130000
155+
# https://github.com/ClangBuiltLinux/linux/issues/1817
156+
depends on AS_IS_GNU || (AS_IS_LLVM && (LD_IS_LLD || LD_VERSION >= 23600))
157+
158+
config GCC_SUPPORTS_DYNAMIC_FTRACE
159+
def_bool CC_IS_GCC
160+
depends on $(cc-option,-fpatchable-function-entry=8)
161+
151162
config ARCH_MMAP_RND_BITS_MIN
152163
default 18 if 64BIT
153164
default 8

0 commit comments

Comments
 (0)