linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc: Fail build if using recordmcount with binutils v2.37
@ 2023-05-29 13:45 Naveen N Rao
  2023-05-30  0:00 ` Michael Ellerman
  0 siblings, 1 reply; 3+ messages in thread
From: Naveen N Rao @ 2023-05-29 13:45 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Joel Stanley, Nicholas Piggin

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>
---
 arch/powerpc/Makefile | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index dca73f673d7046..f0540c1f1377c8 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 \
+		"x$(call ld-ifversion, -eq, 23700, y)" = "xy" ; 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

base-commit: 7b2f56d76feff3b494d6e77950ab97987323d3c5
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc: Fail build if using recordmcount with binutils v2.37
  2023-05-29 13:45 [PATCH] powerpc: Fail build if using recordmcount with binutils v2.37 Naveen N Rao
@ 2023-05-30  0:00 ` Michael Ellerman
  2023-05-30  6:18   ` Naveen N Rao
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Ellerman @ 2023-05-30  0:00 UTC (permalink / raw)
  To: Naveen N Rao; +Cc: linuxppc-dev, Joel Stanley, Nicholas Piggin

Naveen N Rao <naveen@kernel.org> writes:
> 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>
> ---
>  arch/powerpc/Makefile | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
> index dca73f673d7046..f0540c1f1377c8 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 \
> +		"x$(call ld-ifversion, -eq, 23700, y)" = "xy" ; 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

Thanks for doing this.

Masahiro wanted to remove ld-ifversion, he suggested to just check
CONFIG_LD_VERSION directly instead. Mind doing a v2 with that change?

https://lore.kernel.org/all/CAK7LNAQWtDHOs=K+qznt5U1WiDv86tChkj4zOer4wtVRB974OA@mail.gmail.com/

cheers

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] powerpc: Fail build if using recordmcount with binutils v2.37
  2023-05-30  0:00 ` Michael Ellerman
@ 2023-05-30  6:18   ` Naveen N Rao
  0 siblings, 0 replies; 3+ messages in thread
From: Naveen N Rao @ 2023-05-30  6:18 UTC (permalink / raw)
  To: Michael Ellerman; +Cc: linuxppc-dev, Joel Stanley, Nicholas Piggin

Michael Ellerman wrote:
> Naveen N Rao <naveen@kernel.org> writes:
>> 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>
>> ---
>>  arch/powerpc/Makefile | 8 ++++++++
>>  1 file changed, 8 insertions(+)
>>
>> diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
>> index dca73f673d7046..f0540c1f1377c8 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 \
>> +		"x$(call ld-ifversion, -eq, 23700, y)" = "xy" ; 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
> 
> Thanks for doing this.
> 
> Masahiro wanted to remove ld-ifversion, he suggested to just check
> CONFIG_LD_VERSION directly instead. Mind doing a v2 with that change?
> 
> https://lore.kernel.org/all/CAK7LNAQWtDHOs=K+qznt5U1WiDv86tChkj4zOer4wtVRB974OA@mail.gmail.com/

I have posted a v2 with just that change. Let me know if you are 
planning to pick up Masahiro's patch above and if you want me to base my 
changes atop that (just have to add back archprepare/checkbin).


- Naveen


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-30  6:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-29 13:45 [PATCH] powerpc: Fail build if using recordmcount with binutils v2.37 Naveen N Rao
2023-05-30  0:00 ` Michael Ellerman
2023-05-30  6:18   ` Naveen N Rao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).