linux-kbuild.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: Try up to eight kallsyms link passes
@ 2020-09-10 15:32 Guenter Roeck
  2020-09-22  3:29 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Guenter Roeck @ 2020-09-10 15:32 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, linux-kbuild, linux-kernel, Guenter Roeck,
	Geert Uytterhoeven

Since v5.8, powerpc:allmodconfig often fails to build with the following
error message.

	Inconsistent kallsyms data
	Try make KALLSYMS_EXTRA_PASS=1 as a workaround

Setting KALLSYMS_EXTRA_PASS=1 does not help. As it turns out, the build
currently needs up to four link passes to succeed.

Similar problems have been observed over time for other architectures.

Make the number of link passes dynamic to solve the problem. Try up to
eight passes before giving up. If KALLSYMS_EXTRA_PASS is set, add one
additional pass after succeeding.

Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 scripts/link-vmlinux.sh | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index e6e2d9e5ff48..72abdee0e649 100755
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -316,11 +316,10 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
 	#     From here, we generate a correct .tmp_kallsyms2.o
 	# 3)  That link may have expanded the kernel image enough that
 	#     more linker branch stubs / trampolines had to be added, which
-	#     introduces new names, which further expands kallsyms. Do another
-	#     pass if that is the case. In theory it's possible this results
-	#     in even more stubs, but unlikely.
-	#     KALLSYMS_EXTRA_PASS=1 may also used to debug or work around
-	#     other bugs.
+	#     introduces new names, which further expands kallsyms. Try up
+	#     to eight passes to handle that situation before giving up.
+	#     KALLSYMS_EXTRA_PASS=1 may be used to add an extra step
+	#     for debugging or to work around other bugs.
 	# 4)  The correct ${kallsymso} is linked into the final vmlinux.
 	#
 	# a)  Verify that the System.map from vmlinux matches the map from
@@ -329,13 +328,21 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
 	kallsyms_step 1
 	kallsyms_step 2
 
-	# step 3
-	size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
-	size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
-
-	if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
-		kallsyms_step 3
-	fi
+	# step n
+	step=3
+	while [ $step -le 8 ]; do
+		size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
+		size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
+
+		if [ $size1 -eq $size2 ]; then
+			if [ -z "${KALLSYMS_EXTRA_PASS}" ]; then
+				break
+			fi
+			KALLSYMS_EXTRA_PASS=""
+		fi
+		kallsyms_step $step
+		step="$(expr $step + 1)"
+	done
 fi
 
 vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
-- 
2.17.1


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

* Re: [PATCH] kbuild: Try up to eight kallsyms link passes
  2020-09-10 15:32 [PATCH] kbuild: Try up to eight kallsyms link passes Guenter Roeck
@ 2020-09-22  3:29 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2020-09-22  3:29 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Michal Marek, linux-kbuild, linux-kernel, Geert Uytterhoeven

On Thu, Sep 10, 2020 at 08:32:04AM -0700, Guenter Roeck wrote:
> Since v5.8, powerpc:allmodconfig often fails to build with the following
> error message.
> 
> 	Inconsistent kallsyms data
> 	Try make KALLSYMS_EXTRA_PASS=1 as a workaround
> 
> Setting KALLSYMS_EXTRA_PASS=1 does not help. As it turns out, the build
> currently needs up to four link passes to succeed.
> 
> Similar problems have been observed over time for other architectures.
> 
> Make the number of link passes dynamic to solve the problem. Try up to
> eight passes before giving up. If KALLSYMS_EXTRA_PASS is set, add one
> additional pass after succeeding.
> 
> Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org>
> Cc: Geert Uytterhoeven <geert@linux-m68k.org>
> Signed-off-by: Guenter Roeck <linux@roeck-us.net>

I still see a build failure for powerpc:allmodconfig due to this problem.

Feedback/comments/thoughts ? Does anyone have a better idea ?

Thanks,
Guenter

> ---
>  scripts/link-vmlinux.sh | 31 +++++++++++++++++++------------
>  1 file changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
> index e6e2d9e5ff48..72abdee0e649 100755
> --- a/scripts/link-vmlinux.sh
> +++ b/scripts/link-vmlinux.sh
> @@ -316,11 +316,10 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
>  	#     From here, we generate a correct .tmp_kallsyms2.o
>  	# 3)  That link may have expanded the kernel image enough that
>  	#     more linker branch stubs / trampolines had to be added, which
> -	#     introduces new names, which further expands kallsyms. Do another
> -	#     pass if that is the case. In theory it's possible this results
> -	#     in even more stubs, but unlikely.
> -	#     KALLSYMS_EXTRA_PASS=1 may also used to debug or work around
> -	#     other bugs.
> +	#     introduces new names, which further expands kallsyms. Try up
> +	#     to eight passes to handle that situation before giving up.
> +	#     KALLSYMS_EXTRA_PASS=1 may be used to add an extra step
> +	#     for debugging or to work around other bugs.
>  	# 4)  The correct ${kallsymso} is linked into the final vmlinux.
>  	#
>  	# a)  Verify that the System.map from vmlinux matches the map from
> @@ -329,13 +328,21 @@ if [ -n "${CONFIG_KALLSYMS}" ]; then
>  	kallsyms_step 1
>  	kallsyms_step 2
>  
> -	# step 3
> -	size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
> -	size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
> -
> -	if [ $size1 -ne $size2 ] || [ -n "${KALLSYMS_EXTRA_PASS}" ]; then
> -		kallsyms_step 3
> -	fi
> +	# step n
> +	step=3
> +	while [ $step -le 8 ]; do
> +		size1=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso_prev})
> +		size2=$(${CONFIG_SHELL} "${srctree}/scripts/file-size.sh" ${kallsymso})
> +
> +		if [ $size1 -eq $size2 ]; then
> +			if [ -z "${KALLSYMS_EXTRA_PASS}" ]; then
> +				break
> +			fi
> +			KALLSYMS_EXTRA_PASS=""
> +		fi
> +		kallsyms_step $step
> +		step="$(expr $step + 1)"
> +	done
>  fi
>  
>  vmlinux_link vmlinux "${kallsymso}" ${btf_vmlinux_bin_o}
> -- 
> 2.17.1
> 

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

end of thread, other threads:[~2020-09-22  3:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 15:32 [PATCH] kbuild: Try up to eight kallsyms link passes Guenter Roeck
2020-09-22  3:29 ` Guenter Roeck

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).