kbuild: Try up to eight kallsyms link passes
PATCH 1/1 kbuild: Try up to eight kallsyms link passes
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.
--- scripts/link-vmlinux.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)
scripts/link-vmlinux.sh +19 -12
@@ -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}
Signature · 1 line
2.17.1
Quoted 11 lines · Guenter Roeck
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 workaroundSetting 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.
Quoted 7 lines
Make the number of link passes dynamic to solve the problem. Try up to eight passes before giving up. If
KALLSYMS_EXTRA_PASSis set, add one additional pass after succeeding.Suggested-by Geert Uytterhoeven <[email protected]>Cc Geert Uytterhoeven <[email protected]>Signed-off-by Guenter Roeck <[email protected]>
I still see a build failure for powerpc:allmodconfig due to this problem.
Feedback/comments/thoughts ? Does anyone have a better idea ?
Thanks,
Guenter
Quoted 56 lines
--- scripts/link-vmlinux.sh | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-)scripts/link-vmlinux.sh +19
-12@@ -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}Signature · 1 line
2.17.1