summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Le Cuirot <chewi@gentoo.org>2023-11-04 16:17:15 +0000
committerJames Le Cuirot <chewi@gentoo.org>2023-11-13 22:13:07 +0000
commit6fab286b0d2af2756716e4ba8d8c9aa569f9c6b4 (patch)
tree7fb39802810dd1c58a92092c5aed8db53de2aed5 /dev-lang
parenttoolchain-funcs.eclass: Add functions to get pointer size in bytes (diff)
downloadgentoo-6fab286b0d2af2756716e4ba8d8c9aa569f9c6b4.tar.gz
gentoo-6fab286b0d2af2756716e4ba8d8c9aa569f9c6b4.tar.bz2
gentoo-6fab286b0d2af2756716e4ba8d8c9aa569f9c6b4.zip
dev-lang/luajit: Fix cross-compiling from 64-bit to 32-bit
This will only work with a multilib build host toolchain, so probably just amd64 and ppc64, but it's better than nothing. Multilib profiles specify an explicit target rather than just -m32 in LDFLAGS, but this should still do the right thing, and there's probably no way to query the build profile. Closes: https://bugs.gentoo.org/627332 Signed-off-by: James Le Cuirot <chewi@gentoo.org>
Diffstat (limited to 'dev-lang')
-rw-r--r--dev-lang/luajit/luajit-2.1.0_beta3_p20220613.ebuild16
1 files changed, 15 insertions, 1 deletions
diff --git a/dev-lang/luajit/luajit-2.1.0_beta3_p20220613.ebuild b/dev-lang/luajit/luajit-2.1.0_beta3_p20220613.ebuild
index 24063aae5265..01c4aca8c65c 100644
--- a/dev-lang/luajit/luajit-2.1.0_beta3_p20220613.ebuild
+++ b/dev-lang/luajit/luajit-2.1.0_beta3_p20220613.ebuild
@@ -31,6 +31,21 @@ IUSE="lua52compat static-libs"
S="${WORKDIR}/LuaJIT-${GIT_COMMIT}"
+src_configure() {
+ tc-export_build_env
+
+ # You need to use a 32-bit toolchain to build for a 32-bit architecture.
+ # Some 64-bit toolchains (like amd64 and ppc64) usually have multilib
+ # enabled, allowing you to build in 32-bit with -m32. This won't work in all
+ # cases, but it will otherwise just break, so it's worth trying anyway. If
+ # you're trying to build for 64-bit from 32-bit, then you're screwed, sorry.
+ # See https://github.com/LuaJIT/LuaJIT/issues/664 for the upstream issue.
+ if tc-is-cross-compiler && [[ $(tc-get-build-ptr-size) != 4 && $(tc-get-ptr-size) == 4 ]]; then
+ BUILD_CFLAGS+=" -m32"
+ BUILD_LDFLAGS+=" -m32"
+ fi
+}
+
_emake() {
emake \
Q= \
@@ -55,7 +70,6 @@ _emake() {
}
src_compile() {
- tc-export_build_env
_emake XCFLAGS="$(usex lua52compat "-DLUAJIT_ENABLE_LUA52COMPAT" "")"
}