Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] gentoo-sources 6.10.8 32bit fails: relocation issue
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
ipic
Guru
Guru


Joined: 29 Dec 2003
Posts: 407
Location: UK

PostPosted: Wed Sep 04, 2024 5:58 pm    Post subject: [SOLVED] gentoo-sources 6.10.8 32bit fails: relocation issue Reply with quote

I just pulled gentoo-sources 6.10.8 for a routine kernel build for my 32-bit VMs (with 64bit config option disabled/off). The kernel is built on a 64 bit VM. Usually 'just works'. This time I get:
Code:

ld: relocatable linking with relocations from format elf32-i386 (init/main.o) to format elf64-x86-64 (vmlinux.o) is not supported
make[2]: *** [scripts/Makefile.vmlinux_o:79: vmlinux.o] Error 1
make[1]: *** [/usr/src/linux-6.10.8-gentoo/Makefile:1153: vmlinux_o] Error 2
make: *** [Makefile:240: __sub-make] Error 2


Does any one know what I have to do to make it work again?
Thanks


Last edited by ipic on Thu Sep 05, 2024 6:25 pm; edited 1 time in total
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1962

PostPosted: Thu Sep 05, 2024 1:26 am    Post subject: Reply with quote

Please share the full output, via a pastebin, of make V=1. .config may be useful too.
Back to top
View user's profile Send private message
ipic
Guru
Guru


Joined: 29 Dec 2003
Posts: 407
Location: UK

PostPosted: Thu Sep 05, 2024 7:49 am    Post subject: Reply with quote

output from make V=1 and .config file are here:
https://gist.github.com/pickworthi/90f491c37ec39582939ecd1509769825

The build process I follow is:
Code:

make mrproper
cp /var/tmp/vmkernel/kernel-config-32bit .config
make olddefconfig
make menuconfig
make V=1


The fail message is as follows:
Code:
catalyst /usr/src/linux # make V=1 >>pastebinmake
ld: relocatable linking with relocations from format elf32-i386 (init/main.o) to format elf64-x86-64 (vmlinux.o) is not supported
make[2]: *** [scripts/Makefile.vmlinux_o:79: vmlinux.o] Error 1
make[1]: *** [/usr/src/linux-6.10.8-gentoo/Makefile:1153: vmlinux_o] Error 2
make: *** [Makefile:240: __sub-make] Error 2


The failing line in the output (last line) is:
Code:

# LD      vmlinux.o
  ld -m elf_i386 -z noexecstack --no-warn-rwx-segments -r -o vmlinux.o   -T .tmp_remove-ctf.lds --whole-archive vmlinux.a --no-whole-archive --start-group lib/lib.a arch/x86/lib/lib.a --end-group
Back to top
View user's profile Send private message
VoVaN
l33t
l33t


Joined: 02 Jul 2003
Posts: 701
Location: The Netherlands

PostPosted: Thu Sep 05, 2024 8:48 am    Post subject: Reply with quote

I have problem building 6.10.8 kernel as well and I'm aware of the implementation of the experimental USE flag https://bugs.gentoo.org/706294.
Code:

make[2]: *** [/mnt/portage/tmp/portage/sys-kernel/gentoo-kernel-6.10.8/work/linux-6.10/Makefile:1942: .] Error 2
make[1]: *** [/mnt/portage/tmp/portage/sys-kernel/gentoo-kernel-6.10.8/work/linux-6.10/Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/mnt/portage/tmp/portage/sys-kernel/gentoo-kernel-6.10.8/work/build'


Rebuilding 6.10.7 kernel still works without issues.
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1962

PostPosted: Thu Sep 05, 2024 11:32 am    Post subject: Reply with quote

VoVaN wrote:
I have problem building 6.10.8 kernel as well and I'm aware of the implementation of the experimental USE flag https://bugs.gentoo.org/706294.
Code:

make[2]: *** [/mnt/portage/tmp/portage/sys-kernel/gentoo-kernel-6.10.8/work/linux-6.10/Makefile:1942: .] Error 2
make[1]: *** [/mnt/portage/tmp/portage/sys-kernel/gentoo-kernel-6.10.8/work/linux-6.10/Makefile:240: __sub-make] Error 2
make[1]: Leaving directory '/mnt/portage/tmp/portage/sys-kernel/gentoo-kernel-6.10.8/work/build'


Rebuilding 6.10.7 kernel still works without issues.


Your issue may well be different. Please start a new thread and share the full build.log and emerge --info.
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1962

PostPosted: Thu Sep 05, 2024 11:33 am    Post subject: Reply with quote

ipic wrote:
output from make V=1 and .config file are here:
https://gist.github.com/pickworthi/90f491c37ec39582939ecd1509769825

The build process I follow is:
Code:

make mrproper
cp /var/tmp/vmkernel/kernel-config-32bit .config
make olddefconfig
make menuconfig
make V=1


The fail message is as follows:
Code:
catalyst /usr/src/linux # make V=1 >>pastebinmake
ld: relocatable linking with relocations from format elf32-i386 (init/main.o) to format elf64-x86-64 (vmlinux.o) is not supported
make[2]: *** [scripts/Makefile.vmlinux_o:79: vmlinux.o] Error 1
make[1]: *** [/usr/src/linux-6.10.8-gentoo/Makefile:1153: vmlinux_o] Error 2
make: *** [Makefile:240: __sub-make] Error 2


The failing line in the output (last line) is:
Code:

# LD      vmlinux.o
  ld -m elf_i386 -z noexecstack --no-warn-rwx-segments -r -o vmlinux.o   -T .tmp_remove-ctf.lds --whole-archive vmlinux.a --no-whole-archive --start-group lib/lib.a arch/x86/lib/lib.a --end-group


This log misses stderr. Try &> pastebinmake if using bash.
Back to top
View user's profile Send private message
ipic
Guru
Guru


Joined: 29 Dec 2003
Posts: 407
Location: UK

PostPosted: Thu Sep 05, 2024 11:46 am    Post subject: Reply with quote

Does the text I included in the post not provide the STDERR output?
It is everything that appeared.

I reran make V=1 and captured all output, and placed it in the gist (third file)
https://gist.github.com/pickworthi/90f491c37ec39582939ecd1509769825

Since it is a re-run - nothing was compiled (since nothing changed).

The STDERR is as I posted above nothing added as far as I can see.
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1962

PostPosted: Thu Sep 05, 2024 12:04 pm    Post subject: Reply with quote

It added the actual linker error and I wanted to be sure there wasn't more. Thanks, looking.
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1962

PostPosted: Thu Sep 05, 2024 2:14 pm    Post subject: Reply with quote

EDIT: Please ignore previous text, I'm a fool and didn't read your instructions properly. Indeed it happens with a 32-bit build on a 64-bit host. Looking.
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1962

PostPosted: Thu Sep 05, 2024 3:23 pm    Post subject: Reply with quote

Please try this patch:
Code:

--- a/scripts/Makefile.vmlinux_o      2024-09-05 16:22:47.594384762 +0100
+++ b/scripts/Makefile.vmlinux_o  2024-09-05 16:23:03.427561105 +0100
@@ -32,7 +32,7 @@

 quiet_cmd_gen_remove_ctf.lds = GEN     $@
       cmd_gen_remove_ctf.lds = \
-       $(LD) -r --verbose | awk -f $(real-prereqs) > $@
+       $(LD) $(KBUILD_LDFLAGS) -r --verbose | awk -f $(real-prereqs) > $@

 .tmp_remove-ctf.lds: $(srctree)/scripts/remove-ctf-lds.awk FORCE
        $(call if_changed,gen_remove_ctf.lds)
Back to top
View user's profile Send private message
ipic
Guru
Guru


Joined: 29 Dec 2003
Posts: 407
Location: UK

PostPosted: Thu Sep 05, 2024 5:02 pm    Post subject: Reply with quote

I could not get the patch to apply, it did this:
Code:

catalyst /usr/src/linux # patch --dry-run -p1 -i 32bit.patch
checking file scripts/Makefile.vmlinux_o
Hunk #1 FAILED at 32.
1 out of 1 hunk FAILED

...and...

catalyst /usr/src/linux # patch  -p1 -i 32bit.patch
patching file scripts/Makefile.vmlinux_o
Hunk #1 FAILED at 32.
1 out of 1 hunk FAILED -- saving rejects to file scripts/Makefile.vmlinux_o.rej


So, I edited in the change to scripts/Makefile.vmlinux_o by hand using vi. The change I applied is:
Code:

line 35
change:  $(LD) -r --verbose | ..etc..
to: $(LD) $(KBUILD_LDFLAGS) -r --verbose | ..etc..


I then ran make again (no other changes) and it worked.

I have no idea why the patch would not apply - it looks OK to me. However, what it does, works.

Does this mean that gentoo-sources has to be patched?

(EDIT: Just for completeness, I ran a 64-bit make on the same patched source, and that worked as well.)
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 1962

PostPosted: Thu Sep 05, 2024 5:37 pm    Post subject: Reply with quote

Thanks! Whitespace probably got mangled. The call to LD was wrong because it's used to generate a linker script. By not passing -m XXX, it hardcodes OUTPUT_FORMAT of whatever the native linker output format is. By passing KBUILD_LDFLAGS, which has the right -m XXX value, the issue is fixed.

I've sent the fix for inclusion in the next version of gentoo-sources (it's not an upstream bug, it's from a patch we added recently). Thank you again for the help.
Back to top
View user's profile Send private message
ipic
Guru
Guru


Joined: 29 Dec 2003
Posts: 407
Location: UK

PostPosted: Thu Sep 05, 2024 6:26 pm    Post subject: Reply with quote

Cool, and thank you for fixing it.

I've marked the thread as [SOLVED].
Back to top
View user's profile Send private message
ipic
Guru
Guru


Joined: 29 Dec 2003
Posts: 407
Location: UK

PostPosted: Sun Sep 08, 2024 3:38 pm    Post subject: Reply with quote

6.10.9 compiled and linked OK. So patch must have made it to the release.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum