LDFLAGS=\"$(get_abi_LDFLAGS)\" linux-mod_src_compile is wrong for x32 ABI. It forces the final link to be an x32 link while the objects are pure 64-bit. We should always create 64-bit kernel modules for x32 ABI because only the 64-bit kernel will run x32 ABI. So, LDFLAGS should be passed in this case. I don't know how to properly fix it though. I did not dig deep. But I have a feeling that just removing the LDFLAGS altogether should do the right thing for all ARCHs. But as I said, I don't know....:) Reproducible: Always
Just wanted to mention that the final link fails because 64-bit objects are not compatible with elf32_x86_64.
Doesn't the kernel Makefile handle using the right flags based on config options? What is the reason linux-mod passes any LDFLAGS?
linux-mod is doing the wrong thing with crosscompile as well, when there is no need to pass any of those args to the make. There is very good support for crosscompile built into the kernel. Last time I tried, you couldn't have a 64-bit kernel and pure 32-bit userspace on gentoo because of this CROSS_COMPILE=${CHOST}- thingy. All of the packages which needed to build kernel modules failed to build. I needed this patch to move fwd: # diff -u linux-mod.eclass.org linux-mod.eclass --- linux-mod.eclass.org 2012-08-08 08:23:52.666304793 -0700 +++ linux-mod.eclass 2012-08-08 08:23:47.699366891 -0700 @@ -667,9 +667,7 @@ # spaces that must be preserved. If don't do this, then the stuff # inside the variables gets used as targets for Make, which then # fails. - eval "emake HOSTCC=\"$(tc-getBUILD_CC)\" \ - CROSS_COMPILE=${CHOST}- \ - LDFLAGS=\"$(get_abi_LDFLAGS)\" \ + eval "emake \ ${BUILD_FIXES} \ ${BUILD_PARAMS} \ ${BUILD_TARGETS} " \
Pretty sure the only thing needed to fix this is to add KERNEL_ABI=amd64 into the x32 profiles. No changes to the eclass are required. Adding this locally fixes out of tree module ebuilds on my x32 systems.
(In reply to Ambroz Bizjak from comment #2) > Doesn't the kernel Makefile handle using the right flags based on config > options? What is the reason linux-mod passes any LDFLAGS? That originates from bug 133382.
(In reply to Nick Bowler from comment #4) > Pretty sure the only thing needed to fix this is to add KERNEL_ABI=amd64 > into the x32 profiles. No changes to the eclass are required. Yeah, this is probably the safest approach. Patch sent to gentoo-dev for review. https://archives.gentoo.org/gentoo-dev/message/cb1a75cf9274ffda23cbac51cfba1486
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b01f5d7f4de20063d5949b3bd8a4ed12ebf99621 commit b01f5d7f4de20063d5949b3bd8a4ed12ebf99621 Author: Mike Gilbert <floppym@gentoo.org> AuthorDate: 2021-09-06 23:17:24 +0000 Commit: Mike Gilbert <floppym@gentoo.org> CommitDate: 2021-09-08 14:48:49 +0000 profiles/arch/amd64/x32: set KERNEL_ABI="amd64" Closes: https://bugs.gentoo.org/427052 Signed-off-by: Mike Gilbert <floppym@gentoo.org> profiles/arch/amd64/x32/make.defaults | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
*** Bug 508502 has been marked as a duplicate of this bug. ***