diff mbox series

kbuild: Try up to eight kallsyms link passes

Message ID 20200910153204.156871-1-linux@roeck-us.net (mailing list archive)
State New, archived
Headers show
Series kbuild: Try up to eight kallsyms link passes | expand

Commit Message

Guenter Roeck Sept. 10, 2020, 3:32 p.m. UTC
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(-)

Comments

Guenter Roeck Sept. 22, 2020, 3:29 a.m. UTC | #1
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
>
diff mbox series

Patch

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}