diff mbox series

[v2] powerpc: Fail build if using recordmcount with binutils v2.37

Message ID 20230530061436.56925-1-naveen@kernel.org (mailing list archive)
State Accepted
Commit 25ea739ea1d4d3de41acc4f4eb2d1a97eee0eb75
Headers show
Series [v2] powerpc: Fail build if using recordmcount with binutils v2.37 | expand

Checks

Context Check Description
snowpatch_ozlabs/github-powerpc_ppctests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_selftests success Successfully ran 8 jobs.
snowpatch_ozlabs/github-powerpc_sparse success Successfully ran 4 jobs.
snowpatch_ozlabs/github-powerpc_kernel_qemu success Successfully ran 24 jobs.
snowpatch_ozlabs/github-powerpc_clang success Successfully ran 6 jobs.

Commit Message

Naveen N Rao May 30, 2023, 6:14 a.m. UTC
binutils v2.37 drops unused section symbols, which prevents recordmcount
from capturing mcount locations in sections that have no non-weak
symbols. This results in a build failure with a message such as:
	Cannot find symbol for section 12: .text.perf_callchain_kernel.
	kernel/events/callchain.o: failed

The change to binutils was reverted for v2.38, so this behavior is
specific to binutils v2.37:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c09c8b42021180eee9495bd50d8b35e683d3901b

Objtool is able to cope with such sections, so this issue is specific to
recordmcount.

Fail the build and print a warning if binutils v2.37 is detected and if
we are using recordmcount.

Cc: stable@vger.kernel.org
Suggested-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Naveen N Rao <naveen@kernel.org>
---
v2: Check directly against $CONFIG_LD_VERSION

 arch/powerpc/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)


base-commit: 7b2f56d76feff3b494d6e77950ab97987323d3c5

Comments

Michael Ellerman July 3, 2023, 5:26 a.m. UTC | #1
On Tue, 30 May 2023 11:44:36 +0530, Naveen N Rao wrote:
> binutils v2.37 drops unused section symbols, which prevents recordmcount
> from capturing mcount locations in sections that have no non-weak
> symbols. This results in a build failure with a message such as:
> 	Cannot find symbol for section 12: .text.perf_callchain_kernel.
> 	kernel/events/callchain.o: failed
> 
> The change to binutils was reverted for v2.38, so this behavior is
> specific to binutils v2.37:
> https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=c09c8b42021180eee9495bd50d8b35e683d3901b
> 
> [...]

Applied to powerpc/next.

[1/1] powerpc: Fail build if using recordmcount with binutils v2.37
      https://git.kernel.org/powerpc/c/25ea739ea1d4d3de41acc4f4eb2d1a97eee0eb75

cheers
diff mbox series

Patch

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index dca73f673d7046..fc76eb9830fdfa 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -409,3 +409,11 @@  checkbin:
 		echo -n '*** Please use a different binutils version.' ; \
 		false ; \
 	fi
+	@if test "x${CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT}" = "xy" -a \
+		"x${CONFIG_LD_IS_BFD}" = "xy" -a \
+		"${CONFIG_LD_VERSION}" = "23700" ; then \
+		echo -n '*** binutils 2.37 drops unused section symbols, which recordmcount ' ; \
+		echo 'is unable to handle.' ; \
+		echo '*** Please use a different binutils version.' ; \
+		false ; \
+	fi