Closed leasses closed 1 year ago
The following is the full modified script:
#!/usr/bin/env sh
# From https://github.com/mjansson/lua_lib/blob/master/lua/luajit/build-android.sh
# Fixed https://github.com/LuaJIT/LuaJIT/issues/440#issuecomment-438809840
# From https://github.com/gudzpoz/luajava/blob/main/luajit/jni/scripts/build-android.sh
# Add sopport to Windows
# /cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit
LUAJIT=.
BUILD_DIR=$LUAJIT/lib
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
rm *.a 1>/dev/null 2>/dev/null
HOST_OS=windows
TARGET_SYS=Linux
NDK=/cygdrive/c/Users/29169/AppData/Local/Android/Sdk/ndk/25.2.9519653
TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_OS-x86_64
NDKB=$TOOLCHAIN/bin
NDKAPI=19
echo "########## Building armv7-a ##########"
TARGET=armv7a-linux-androideabi
NDKP=$NDKB/${TARGET}-
NDKCC=$NDKB/${TARGET}${NDKAPI}-clang
NDKARCH="-march=armv7-a -mhard-float -mfpu=vfpv3-d16 -mfloat-abi=softfp -D_NDK_MATH_NO_SOFTFP=1 -marm -DNO_RTLD_DEFAULT=1"
make HOST_CC="gcc -m32 -I/usr/i686-linux-gnu/include" CROSS=$NDKP \
STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
TARGET_LD=$NDKCC TARGET_AR="$NDKB/llvm-ar rcus" TARGET_STRIP=$NDKB/llvm-strip \
CFLAGS=-fPIC TARGET_FLAGS="$NDKARCH" TARGET_SYS="$TARGET_SYS" \
clean
make HOST_CC="gcc -m32 -I/usr/i686-linux-gnu/include" CROSS=$NDKP \
STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
TARGET_LD=$NDKCC TARGET_AR="$NDKB/llvm-ar rcus" TARGET_STRIP=$NDKB/llvm-strip \
CFLAGS=-fPIC TARGET_FLAGS="$NDKARCH" TARGET_SYS="$TARGET_SYS" \
amalg
mkdir -p $BUILD_DIR/armeabi-v7a
mv $LUAJIT/src/libluajit.a $BUILD_DIR/armeabi-v7a/libluajit.a
echo "########## Building i686 ##########"
TARGET=i686-linux-android
NDKP=$NDKB/${TARGET}-
NDKCC=$NDKB/${TARGET}${NDKAPI}-clang
NDKARCH="-DNO_RTLD_DEFAULT=1"
make HOST_CC="gcc -m32 -I/usr/i686-linux-gnu/include" CROSS=$NDKP \
STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
TARGET_LD=$NDKCC TARGET_AR="$NDKB/llvm-ar rcus" TARGET_STRIP=$NDKB/llvm-strip \
CFLAGS=-fPIC TARGET_FLAGS="$NDKARCH" TARGET_SYS="$TARGET_SYS" \
clean
make HOST_CC="gcc -m32 -I/usr/i686-linux-gnu/include" CROSS=$NDKP \
STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
TARGET_LD=$NDKCC TARGET_AR="$NDKB/llvm-ar rcus" TARGET_STRIP=$NDKB/llvm-strip \
CFLAGS=-fPIC TARGET_FLAGS="$NDKARCH" TARGET_SYS="$TARGET_SYS" \
amalg
mkdir $BUILD_DIR/x86
mv $LUAJIT/src/libluajit.a $BUILD_DIR/x86/libluajit.a
NDKAPI=21
echo "########## Building arm64-v8a ##########"
TARGET=aarch64-linux-android
NDKP=$NDKB/${TARGET}-
NDKCC=$NDKB/${TARGET}${NDKAPI}-clang
NDKARCH="-DLJ_ABI_SOFTFP=0 -DLJ_ARCH_HASFPU=1 -DLUAJIT_ENABLE_GC64=1 -DNO_RTLD_DEFAULT=1"
make HOST_CC="gcc -m64" CROSS=$NDKP \
STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
TARGET_LD=$NDKCC TARGET_AR="$NDKB/llvm-ar rcus" TARGET_STRIP=$NDKB/llvm-strip \
CFLAGS=-fPIC TARGET_FLAGS="$NDKARCH" TARGET_SYS="$TARGET_SYS" \
clean
make HOST_CC="gcc -m64" CROSS=$NDKP \
STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
TARGET_LD=$NDKCC TARGET_AR="$NDKB/llvm-ar rcus" TARGET_STRIP=$NDKB/llvm-strip \
CFLAGS=-fPIC TARGET_FLAGS="$NDKARCH" TARGET_SYS="$TARGET_SYS" \
amalg
mkdir -p $BUILD_DIR/arm64-v8a
mv $LUAJIT/src/libluajit.a $BUILD_DIR/arm64-v8a/libluajit.a
echo "########## Building x86_64 ##########"
TARGET=x86_64-linux-android
NDKP=$NDKB/${TARGET}-
NDKCC=$NDKB/${TARGET}${NDKAPI}-clang
NDKARCH="-DLUAJIT_ENABLE_GC64=1 -DNO_RTLD_DEFAULT=1"
make HOST_CC="gcc -m64" CROSS=$NDKP \
STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
TARGET_LD=$NDKCC TARGET_AR="$NDKB/llvm-ar rcus" TARGET_STRIP=$NDKB/llvm-strip \
CFLAGS=-fPIC TARGET_FLAGS="$NDKARCH" TARGET_SYS="$TARGET_SYS" \
clean
make HOST_CC="gcc -m64" CROSS=$NDKP \
STATIC_CC=$NDKCC DYNAMIC_CC="$NDKCC -fPIC" \
TARGET_LD=$NDKCC TARGET_AR="$NDKB/llvm-ar rcus" TARGET_STRIP=$NDKB/llvm-strip \
CFLAGS=-fPIC TARGET_FLAGS="$NDKARCH" TARGET_SYS="$TARGET_SYS" \
amalg
mkdir -p $BUILD_DIR/x86_64
mv $LUAJIT/src/libluajit.a $BUILD_DIR/x86_64/libluajit.a
The following is the full log:
29169@DESKTOP-6HQ2M02 /cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit
$ sh build.sh
########## Building armv7-a ##########
make -C src clean
make[1]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
rm -f luajit libluajit.a libluajit.so host/minilua.exe host/buildvm.exe lj_vm.S lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h luajit.h luajit_relver.txt jit/vmdef.lua *.o host/*.o *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
make[1]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
==== Building LuaJIT 2.1 (amalgamation) ====
make -C src amalg
make[1]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make all "LJCORE_O=ljamalg.o"
make[2]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
HOSTCC host/minilua.o
In file included from /usr/include/sys/signal.h:23:0,
from /usr/include/signal.h:6,
from /usr/include/machine/setjmp.h:410,
from /usr/include/setjmp.h:10,
from host/minilua.c:39:
/usr/include/cygwin/signal.h:102:2: error: #error unimplemented for this target
#error unimplemented for this target
^~~~~
In file included from /usr/include/sys/signal.h:379:0,
from /usr/include/signal.h:6,
from /usr/include/machine/setjmp.h:410,
from /usr/include/setjmp.h:10,
from host/minilua.c:39:
/usr/include/sys/ucontext.h:17:13: error: field ‘uc_mcontext’ has incomplete type
mcontext_t uc_mcontext;
^~~~~~~~~~~
make[2]: *** [Makefile:715: host/minilua.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make[1]: *** [Makefile:619: amalg] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make: *** [Makefile:165: amalg] Error 2
mv: cannot stat './src/libluajit.a': No such file or directory
########## Building i686 ##########
make -C src clean
make[1]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
rm -f luajit libluajit.a libluajit.so host/minilua.exe host/buildvm.exe lj_vm.S lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h luajit.h luajit_relver.txt jit/vmdef.lua *.o host/*.o *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
make[1]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
==== Building LuaJIT 2.1 (amalgamation) ====
make -C src amalg
make[1]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make all "LJCORE_O=ljamalg.o"
make[2]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
HOSTCC host/minilua.o
In file included from /usr/include/sys/signal.h:23:0,
from /usr/include/signal.h:6,
from /usr/include/machine/setjmp.h:410,
from /usr/include/setjmp.h:10,
from host/minilua.c:39:
/usr/include/cygwin/signal.h:102:2: error: #error unimplemented for this target
#error unimplemented for this target
^~~~~
In file included from /usr/include/sys/signal.h:379:0,
from /usr/include/signal.h:6,
from /usr/include/machine/setjmp.h:410,
from /usr/include/setjmp.h:10,
from host/minilua.c:39:
/usr/include/sys/ucontext.h:17:13: error: field ‘uc_mcontext’ has incomplete type
mcontext_t uc_mcontext;
^~~~~~~~~~~
make[2]: *** [Makefile:715: host/minilua.o] Error 1
make[2]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make[1]: *** [Makefile:619: amalg] Error 2
make[1]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make: *** [Makefile:165: amalg] Error 2
mv: cannot stat './src/libluajit.a': No such file or directory
########## Building arm64-v8a ##########
make -C src clean
make[1]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
rm -f luajit libluajit.a libluajit.so host/minilua.exe host/buildvm.exe lj_vm.S lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h luajit.h luajit_relver.txt jit/vmdef.lua *.o host/*.o *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
make[1]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
==== Building LuaJIT 2.1 (amalgamation) ====
make -C src amalg
make[1]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make all "LJCORE_O=ljamalg.o"
make[2]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
HOSTCC host/minilua.o
HOSTLINK host/minilua.exe
VERSION luajit.h
DYNASM host/buildvm_arch.h
HOSTCC host/buildvm.o
HOSTCC host/buildvm_asm.o
HOSTCC host/buildvm_peobj.o
HOSTCC host/buildvm_lib.o
HOSTCC host/buildvm_fold.o
HOSTLINK host/buildvm.exe
BUILDVM lj_vm.S
ASM lj_vm.o
BUILDVM lj_ffdef.h
BUILDVM lj_bcdef.h
BUILDVM lj_folddef.h
BUILDVM lj_recdef.h
BUILDVM lj_libdef.h
CC ljamalg.o
AR libluajit.a
CC luajit.o
BUILDVM jit/vmdef.lua
DYNLINK libluajit.so
LINK luajit
OK Successfully built LuaJIT
make[2]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make[1]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
==== Successfully built LuaJIT 2.1 (amalgamation) ====
########## Building x86_64 ##########
make -C src clean
make[1]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
rm -f luajit libluajit.a libluajit.so host/minilua.exe host/buildvm.exe lj_vm.S lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h host/buildvm_arch.h luajit.h luajit_relver.txt jit/vmdef.lua *.o host/*.o *.obj *.lib *.exp *.dll *.exe *.manifest *.pdb *.ilk
make[1]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
==== Building LuaJIT 2.1 (amalgamation) ====
make -C src amalg
make[1]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make all "LJCORE_O=ljamalg.o"
make[2]: Entering directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
HOSTCC host/minilua.o
HOSTLINK host/minilua.exe
VERSION luajit.h
DYNASM host/buildvm_arch.h
HOSTCC host/buildvm.o
HOSTCC host/buildvm_asm.o
HOSTCC host/buildvm_peobj.o
HOSTCC host/buildvm_lib.o
HOSTCC host/buildvm_fold.o
HOSTLINK host/buildvm.exe
BUILDVM lj_vm.S
ASM lj_vm.o
BUILDVM lj_ffdef.h
BUILDVM lj_bcdef.h
BUILDVM lj_folddef.h
BUILDVM lj_recdef.h
BUILDVM lj_libdef.h
CC ljamalg.o
AR libluajit.a
CC luajit.o
BUILDVM jit/vmdef.lua
DYNLINK libluajit.so
LINK luajit
OK Successfully built LuaJIT
make[2]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
make[1]: Leaving directory '/cygdrive/c/Users/29169/Documents/AndroidProjects/Zuie/app/src/main/jni/luajit/src'
==== Successfully built LuaJIT 2.1 (amalgamation) ====
Hello gudzpoz, long time no see. I want to compile a Luajit for myself because I need to modify sources of Luajit to add some features like continue keyword, switch and case, etc.
So these days I did some research on it:
Thanks!