[Tarantool-patches] [PATCH luajit v4 2/8] OSX: Fix build by hardcoding external frame unwinding.

sergos sergos at tarantool.org
Mon Dec 5 19:06:45 MSK 2022


Hi!

Thanks for the patch!
LGTM.

Sergos


> On 28 Oct 2022, at 12:26, Maksim Kokryashkin <max.kokryashkin at gmail.com> wrote:
> 
> Apparently they can't even get 'grep' right, let alone a keyboard.
> 
> (cherry picked from commit d4a554d6ee1507f7313641b26ed09bf1b518fa1f)
> 
> MacOS uses BSD grep, which is slightly different from GNU grep.
> Because of that, the shell script determining whether external
> unwinding is possible doesn't work right.
> 
> External unwinding is possible on MacOS, so this patch enables
> it by default.
> 
> Maxim Kokryashkin:
> * added the description for the problem
> 
> Needed for tarantool/tarantool#6096
> Needed for tarantool/tarantool#7230
> ---
> cmake/SetTargetFlags.cmake | 28 ++++++++++++++++------------
> src/Makefile.original      | 15 ++++++++-------
> 2 files changed, 24 insertions(+), 19 deletions(-)
> 
> diff --git a/cmake/SetTargetFlags.cmake b/cmake/SetTargetFlags.cmake
> index 36896aff..a5a3407f 100644
> --- a/cmake/SetTargetFlags.cmake
> +++ b/cmake/SetTargetFlags.cmake
> @@ -15,18 +15,22 @@ endif()
> LuaJITTestArch(TESTARCH "${TARGET_C_FLAGS}")
> LuaJITArch(LUAJIT_ARCH "${TESTARCH}")
> 
> -string(FIND ${TARGET_C_FLAGS} "LJ_NO_UNWIND 1" UNWIND_POS)
> -if(UNWIND_POS EQUAL -1)
> -  execute_process(
> -    COMMAND bash -c "exec 2>/dev/null; echo 'extern void b(void);int a(void){b();return 0;}' | ${CMAKE_C_COMPILER} -c -x c - -o tmpunwind.o && grep -qa -e eh_frame -e __unwind_info tmpunwind.o && echo E; rm -f tmpunwind.o"
> -    WORKING_DIRECTORY ${LUAJIT_SOURCE_DIR}
> -    OUTPUT_VARIABLE TESTUNWIND
> -    RESULT_VARIABLE TESTUNWIND_RC
> -  )
> -  if(TESTUNWIND_RC EQUAL 0)
> -    string(FIND "${TESTUNWIND}" "E" UNW_TEST_POS)
> -    if(NOT UNW_TEST_POS EQUAL -1)
> -      AppendFlags(TARGET_C_FLAGS -DLUAJIT_UNWIND_EXTERNAL)
> +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
> +  AppendFlags(TARGET_C_FLAGS -DLUAJIT_UNWIND_EXTERNAL)
> +else()
> +  string(FIND ${TARGET_C_FLAGS} "LJ_NO_UNWIND 1" UNWIND_POS)
> +  if(UNWIND_POS EQUAL -1)
> +    execute_process(
> +      COMMAND bash -c "exec 2>/dev/null; echo 'extern void b(void);int a(void){b();return 0;}' | ${CMAKE_C_COMPILER} -c -x c - -o tmpunwind.o && grep -qa -e eh_frame -e __unwind_info tmpunwind.o && echo E; rm -f tmpunwind.o"
> +      WORKING_DIRECTORY ${LUAJIT_SOURCE_DIR}
> +      OUTPUT_VARIABLE TESTUNWIND
> +      RESULT_VARIABLE TESTUNWIND_RC
> +    )
> +    if(TESTUNWIND_RC EQUAL 0)
> +      string(FIND "${TESTUNWIND}" "E" UNW_TEST_POS)
> +      if(NOT UNW_TEST_POS EQUAL -1)
> +        AppendFlags(TARGET_C_FLAGS -DLUAJIT_UNWIND_EXTERNAL)
> +      endif()
>     endif()
>   endif()
> endif()
> diff --git a/src/Makefile.original b/src/Makefile.original
> index c9609700..d1373b40 100644
> --- a/src/Makefile.original
> +++ b/src/Makefile.original
> @@ -320,18 +320,12 @@ else
> ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
>   TARGET_XCFLAGS+= -fno-stack-protector
> endif
> -ifeq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
> -  # Find out whether the target toolchain always generates unwind tables.
> -  TARGET_TESTUNWIND=$(shell exec 2>/dev/null; echo 'extern void b(void);int a(void){b();return 0;}' | $(TARGET_CC) -c -x c - -o tmpunwind.o && grep -qa -e eh_frame -e __unwind_info tmpunwind.o && echo E; rm -f tmpunwind.o)
> -  ifneq (,$(findstring E,$(TARGET_TESTUNWIND)))
> -    TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
> -  endif
> -endif
> ifeq (Darwin,$(TARGET_SYS))
>   ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
>     export MACOSX_DEPLOYMENT_TARGET=10.4
>   endif
>   TARGET_STRIP+= -x
> +  TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
>   TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
>   TARGET_DYNXLDOPTS=
>   TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
> @@ -345,6 +339,13 @@ ifeq (iOS,$(TARGET_SYS))
>     TARGET_XCFLAGS+= -fno-omit-frame-pointer
>   endif
> else
> +  ifeq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
> +    # Find out whether the target toolchain always generates unwind tables.
> +    TARGET_TESTUNWIND=$(shell exec 2>/dev/null; echo 'extern void b(void);int a(void){b();return 0;}' | $(TARGET_CC) -c -x c - -o tmpunwind.o && grep -qa -e eh_frame -e __unwind_info tmpunwind.o && echo E; rm -f tmpunwind.o)
> +    ifneq (,$(findstring E,$(TARGET_TESTUNWIND)))
> +      TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
> +    endif
> +  endif
>   ifneq (SunOS,$(TARGET_SYS))
>     ifneq (PS3,$(TARGET_SYS))
>       TARGET_XLDFLAGS+= -Wl,-E
> -- 
> 2.37.0 (Apple Git-136)
> 



More information about the Tarantool-patches mailing list