From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id B9C966F3D4; Thu, 6 Oct 2022 12:50:00 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B9C966F3D4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1665049800; bh=aPXW4s7+gsOTT/D27ECFrLo+l38h+GdC4XY1Gwc9UeE=; h=To:Cc:Date:In-Reply-To:References:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Mt/9sAfRN0BwEL/DbP/FTaa3i96KUFXe7HL4wwA99/uxgcm4JAfbvIvpzVVlJOWvF s0TzxQ1mijtvc2VJiMAqE1qaEOeKSBsoVG2A2km8js9PJ7NxGeeWUCLmj334S2z+hX IgVGMGDHVtiH+xwhtj38eKR32O/BUJiS0pMY46aE= Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id F23846F3D4 for ; Thu, 6 Oct 2022 12:48:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F23846F3D4 Received: by mail-lj1-f177.google.com with SMTP id bs18so1609447ljb.1 for ; Thu, 06 Oct 2022 02:48:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=EOXvEZ+V0bbj99E0CziqposdHDHpIvjkDmz4XYK+TL8=; b=g4zPhQq2es8/E784oLVpW1jMJgMgBldfJkGWD2NhKHDLMmZX6cJkpY/VcgKUWI6BxH t2paPdH0oN5cbgCdUCtIskgNkVAhD5Ix2NadpGwnAxMcR5iz1jBd1IPsimzvpKWUN0im uPOrJyU1BENH8PAGgmmRFRjO+QghVO/KBnIKcQ7bbNI4w0mfPqB6CCbAkWjU9fN8mQ5F oGCPjVR5UUHiRyYLJLUTdUUjHPL1nC6bK2XQ1q1g0ia0U3ZrB+KQmOkrgHo6U/0GccjY OdKVndQRPpOvjKuBSrWjzTyq4I+j5V9AbvTRW9KcxYRzIVUhRQRukNe1aV3WmfqqiTmW gxkQ== X-Gm-Message-State: ACrzQf0GUiXZPOenhzmPCppH7IkG+Q3C/Kt45jEbVpwZ7492NiMmYt3M YCPoP9HPNwi7ECjChJhubzO7x5imSmqAi1YlBQI= X-Google-Smtp-Source: AMsMyM6u0Ar1Dws9Vi/S9DVsgX9O4rmqC61bsMqjzXSOpFRG31I7gP8EOuuQbF8knITl2O6YVYcH3Q== X-Received: by 2002:a2e:bf0f:0:b0:26d:e258:9ff6 with SMTP id c15-20020a2ebf0f000000b0026de2589ff6mr1536328ljr.356.1665049738110; Thu, 06 Oct 2022 02:48:58 -0700 (PDT) Received: from localhost.localdomain (128-69-252-100.broadband.corbina.ru. [128.69.252.100]) by smtp.gmail.com with ESMTPSA id o20-20020a056512231400b004979ec19380sm2628676lfu.285.2022.10.06.02.48.57 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 06 Oct 2022 02:48:57 -0700 (PDT) To: tarantool-patches@dev.tarantool.org, sergos@tarantool.org, skaplun@tarantool.org Cc: Maksim Kokryashkin Date: Thu, 6 Oct 2022 12:48:45 +0300 Message-Id: <20221006094849.85442-3-max.kokryashkin@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) In-Reply-To: <20221006094849.85442-1-max.kokryashkin@gmail.com> References: <20221006094849.85442-1-max.kokryashkin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH luajit v2 2/6] OSX: Fix build by hardcoding external frame unwinding. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Maksim Kokryashkin via Tarantool-patches Reply-To: Maksim Kokryashkin Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" 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 --- >I have two questions below and also there’s no mentioning in the message that >you removes the non-GC64 workflow for the Darwin platform. Why is it done >at all? Previous commit just mentioned that GC64 is enabled by default. My bad! As Sergey mentioned, we needed to clarify that it is not only enabled by default, it is now forbidden to run on MacOS in non-GC64 mode. Also, I moved those changes to the first patch, because it is more logical in terms of structure. >1. how is it relvant to grep?? > >> include: >> - BUILDTYPE: Debug >> CMAKEFLAGS: -DCMAKE_BUILD_TYPE=Debug -DLUA_USE_ASSERT=ON -DLUA_USE_APICHECK=ON >> @@ -69,15 +69,6 @@ jobs: >> - name: test >> run: cmake --build . --parallel --target test >> >> - test-tarantool-debug-wo-GC64: >> - name: Tarantool Debug GC64:OFF >> - needs: test-luajit >> - uses: tarantool/tarantool/.github/workflows/luajit-integration.yml@master >> - with: >> - GC64: OFF >> - buildtype: Debug >> - host: macos-11 >> - revision: ${{ github.sha }} > >(1) > >> test-tarantool-debug-w-GC64: >> name: Tarantool Debug GC64:ON >> needs: test-luajit >> @@ -87,15 +78,6 @@ jobs: >> buildtype: Debug >> host: macos-11 >> revision: ${{ github.sha }} >> - test-tarantool-release-wo-GC64: >> - name: Tarantool Release GC64:OFF >> - needs: test-luajit >> - uses: tarantool/tarantool/.github/workflows/luajit-integration.yml@master >> - with: >> - GC64: OFF >> - buildtype: RelWithDebInfo >> - host: macos-11 >> - revision: ${{ github.sha }} >(1) It is not relevant to grep in any way, see the comment above. >> - 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" > >2. I don’t see any changes to the grep operation here and below - does the cherry-pick message is relevant at all? Yes, there are no changes to grep, we just enable the external unwinding on every Darwin system without any checks at all, because of the issue with grep. It is reliable, because, clang always generates unwind tables. 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.32.1 (Apple Git-133)