Skip to content

Commit a176843

Browse files
committed
fix(luajit): support building on aarch64 hosts
LuaJIT requires its host tools (minilua, buildvm) to match the target's bitness. On x86_64 hosts this is solved with gcc -m32, but aarch64 has no equivalent flag. Use Buildroot's own cross-compiler (TARGET_CC) to build the host tools as static arm32 binaries, which run natively on aarch64 via the kernel's 32-bit compat mode (CONFIG_COMPAT). Also use TARGET_CFLAGS/TARGET_LDFLAGS for the host tools on aarch64, since HOST_CFLAGS/HOST_LDFLAGS contain aarch64-specific include/library paths that are wrong for arm32. Skip selecting BR2_HOSTARCH_NEEDS_IA32_COMPILER on aarch64 since the IA32 multilib check is not applicable.
1 parent 4124f10 commit a176843

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

package/batocera/libraries/batocera-luajit/Config.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ config BR2_PACKAGE_BATOCERA_LUAJIT
2020
# luajit.mk uses the "-m32" compiler option to build 32bit
2121
# binaries, so check if that option is supported. See
2222
# luajit.mk for details.
23-
select BR2_HOSTARCH_NEEDS_IA32_COMPILER if !BR2_ARCH_IS_64
23+
select BR2_HOSTARCH_NEEDS_IA32_COMPILER if !BR2_ARCH_IS_64 && BR2_HOSTARCH != "aarch64"
2424
help
2525
LuaJIT implements the full set of language features defined
2626
by Lua 5.1. The virtual machine (VM) is API- and

package/batocera/libraries/batocera-luajit/batocera-luajit.mk

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,18 @@ ifeq ($(BR2_ARCH_IS_64),y)
2828
BATOCERA_LUAJIT_HOST_CC = $(HOSTCC)
2929
# There is no LUAJIT_ENABLE_GC64 option.
3030
else
31+
# On aarch64 hosts, there is no -m32 equivalent. Instead, use Buildroot's own
32+
# cross-compiler to build the host tools (minilua, buildvm) as static arm32
33+
# binaries, which run natively via the kernel's 32-bit compat mode (CONFIG_COMPAT).
34+
ifeq ($(HOSTARCH),aarch64)
35+
BATOCERA_LUAJIT_HOST_CC = $(TARGET_CC) -static
36+
BATOCERA_LUAJIT_HOST_CFLAGS = $(TARGET_CFLAGS)
37+
BATOCERA_LUAJIT_HOST_LDFLAGS = $(TARGET_LDFLAGS)
38+
else
3139
BATOCERA_LUAJIT_HOST_CC = $(HOSTCC) -m32
40+
BATOCERA_LUAJIT_HOST_CFLAGS = $(HOST_CFLAGS)
41+
BATOCERA_LUAJIT_HOST_LDFLAGS = $(HOST_LDFLAGS)
42+
endif
3243
BATOCERA_LUAJIT_XCFLAGS += -DLUAJIT_DISABLE_GC64
3344
endif
3445

@@ -44,8 +55,8 @@ define BATOCERA_LUAJIT_BUILD_CMDS
4455
TARGET_CFLAGS="$(TARGET_CFLAGS)" \
4556
TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
4657
HOST_CC="$(BATOCERA_LUAJIT_HOST_CC)" \
47-
HOST_CFLAGS="$(HOST_CFLAGS)" \
48-
HOST_LDFLAGS="$(HOST_LDFLAGS)" \
58+
HOST_CFLAGS="$(BATOCERA_LUAJIT_HOST_CFLAGS)" \
59+
HOST_LDFLAGS="$(BATOCERA_LUAJIT_HOST_LDFLAGS)" \
4960
BUILDMODE=dynamic \
5061
XCFLAGS="$(BATOCERA_LUAJIT_XCFLAGS)" \
5162
-C $(@D) amalg

0 commit comments

Comments
 (0)