From 4db2b83833fa31bb90522af7b0e92414f5c5140a Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Fri, 29 Oct 2021 17:45:18 -0700 Subject: [PATCH 1/3] Bump luajit to latest HEAD of v2.1 branch --- deps/luajit | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/luajit b/deps/luajit index 1d8b747c..b4b2dce9 160000 --- a/deps/luajit +++ b/deps/luajit @@ -1 +1 @@ -Subproject commit 1d8b747c161db457e032a023ebbff511f5de5ec2 +Subproject commit b4b2dce9fc3ffaaaede39b36d06415311e2aa516 From 8a1d9d61ce0502cc74d3ed011c281005c6963343 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Fri, 29 Oct 2021 20:41:18 -0700 Subject: [PATCH 2/3] luajit.cmake: Add lib_buffer.c --- deps/luajit.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/deps/luajit.cmake b/deps/luajit.cmake index 169d7cb1..f1e18fc9 100644 --- a/deps/luajit.cmake +++ b/deps/luajit.cmake @@ -238,6 +238,7 @@ SET(SRC_LJLIB ${LUAJIT_DIR}/src/lib_debug.c ${LUAJIT_DIR}/src/lib_jit.c ${LUAJIT_DIR}/src/lib_ffi.c + ${LUAJIT_DIR}/src/lib_buffer.c ) SET(SRC_LIBAUX From 13d034b395854edd174bebcde20d209856590f33 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Fri, 29 Oct 2021 20:41:52 -0700 Subject: [PATCH 3/3] luajit.cmake: Attempt to port LUAJIT_UNWIND_EXTERNAL logic from luajit's src/Makefile --- deps/luajit.cmake | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/deps/luajit.cmake b/deps/luajit.cmake index f1e18fc9..189aabd4 100644 --- a/deps/luajit.cmake +++ b/deps/luajit.cmake @@ -73,7 +73,6 @@ ENDIF() if ( WIN32 AND NOT CYGWIN ) set ( LJVM_MODE peobj ) elseif ( APPLE ) - set ( CMAKE_EXE_LINKER_FLAGS "-pagezero_size 10000 -image_base 100000000 ${CMAKE_EXE_LINKER_FLAGS}" ) set ( LJVM_MODE machasm ) else () set ( LJVM_MODE elfasm ) @@ -213,6 +212,39 @@ IF(TARGET_LJARCH STREQUAL "ppc") ENDIF() ENDIF() +IF(APPLE) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUAJIT_UNWIND_EXTERNAL") +ELSEIF(NOT WIN32) + IF(NOT LJ_NO_UNWIND_1) + # Find out whether the target toolchain always generates unwind tables. + MESSAGE(STATUS "Checking if the toolchain always generates unwind tables") + SET(TOOLCHAIN_GENERATES_UNWIND_TABLES 0) + SET(TMPUNWIND_DIR "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp") + file(WRITE "${TMPUNWIND_DIR}/tmpunwind.c" "extern void b(void);int a(void){b();return 0;}") + # This seems flimsy; it would be better to use something like CMake's try_compile but + # there doesn't seem to be a way to avoid linking when using try_compile so this particular + # code can't use it (at least without modifying the test code) + execute_process(COMMAND "${CMAKE_C_COMPILER}" -c -x c "${TMPUNWIND_DIR}/tmpunwind.c" -o "${TMPUNWIND_DIR}/tmpunwind.o" + RESULT_VARIABLE UNWIND_TEST_ERRORED) + IF(NOT UNWIND_TEST_ERRORED) + file(READ "${TMPUNWIND_DIR}/tmpunwind.o" TMPUNWIND_O) + string(FIND "${TMPUNWIND_O}" "eh_frame" EH_FRAME_FOUND) + string(FIND "${TMPUNWIND_O}" "__unwind_info" UNWIND_INFO_FOUND) + IF(EH_FRAME_FOUND OR UNWIND_INFO_FOUND) + SET(TOOLCHAIN_GENERATES_UNWIND_TABLES 1) + ENDIF() + ENDIF() + + IF(TOOLCHAIN_GENERATES_UNWIND_TABLES) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLUAJIT_UNWIND_EXTERNAL") + MESSAGE(STATUS "Toolchain does generate unwind tables") + ELSE() + MESSAGE(STATUS "Toolchain does not generate unwind tables") + ENDIF() + ENDIF() +ENDIF() + + add_executable(minilua ${LUAJIT_DIR}/src/host/minilua.c) SET_TARGET_PROPERTIES(minilua PROPERTIES COMPILE_DEFINITIONS "${TARGET_ARCH}") CHECK_LIBRARY_EXISTS(m sin "" MINILUA_USE_LIBM)