A user reported that when compiling modules for a system with a 64-bit
kernel and a 32-bit userland, there were linker errors. This patch here
is an attempt to fix that by making sure that we always use the kernel
ABI when giving target build parameters.

Signed-off-by: Jason A. Donenfeld <zx...@gentoo.org>
Fixes: https://bugs.gentoo.org/704468
Cc: joakim.tjernl...@infinera.com
Cc: ker...@gentoo.org
---
This is untested on the bug reporter's system, and I'd appreciate some
review from an author of this eclass.

 eclass/linux-mod.eclass | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/eclass/linux-mod.eclass b/eclass/linux-mod.eclass
index b6dc2c84d09..ecfce72a142 100644
--- a/eclass/linux-mod.eclass
+++ b/eclass/linux-mod.eclass
@@ -671,13 +671,16 @@ linux-mod_src_compile() {
                        # 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)\" \
+                       local KERNEL_CHOST="$(ABI=${KERNEL_ABI} get_abi_CHOST)"
+                       local KERNEL_LDFLAGS="$(ABI=${KERNEL_ABI} 
get_abi_LDFLAGS)"
+                       local HOST_CC="$(tc-getHOST_CC)"
+                       eval "emake HOSTCC=\"${HOST_CC}\" \
+                                               CROSS_COMPILE=${KERNEL_CHOST}- \
+                                               LDFLAGS=\"${KERNEL_LDFLAGS}\" \
                                                ${BUILD_FIXES} \
                                                ${BUILD_PARAMS} \
                                                ${BUILD_TARGETS} " \
-                               || die "Unable to emake 
HOSTCC="$(tc-getBUILD_CC)" CROSS_COMPILE=${CHOST}- LDFLAGS="$(get_abi_LDFLAGS)" 
${BUILD_FIXES} ${BUILD_PARAMS} ${BUILD_TARGETS}"
+                               || die "Unable to emake HOSTCC="${HOST_CC}" 
CROSS_COMPILE=${KERNEL_CHOST}- LDFLAGS="${KERNEL_LDFLAGS}" ${BUILD_FIXES} 
${BUILD_PARAMS} ${BUILD_TARGETS}"
                        cd "${OLDPWD}"
                        touch "${srcdir}"/.built
                fi
-- 
2.24.1


Reply via email to