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 49A02BB2A2B; Thu, 13 Jun 2024 18:47:03 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 49A02BB2A2B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1718293623; bh=GuM5tBweVg0VztZlpObzKanzbmL8ClVT554zq6a/Cpk=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TWOEhZ04AGPMi8lIUZxS/vU/X6QlHScahGmL7+w43izQ1FfxthmfULx5YYjL3cdWx e57MsAaAGC8yyB9ICyvp4pi8y3Vz1ozn7mrHJyXAIAQzaUlOoADBt2eH+FI3Wov5QZ B0XyeUALiTHVxeDXrypU2E+b8P1+FpuEIB8/SLN0= Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [95.163.41.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 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 B47BFBB2A02 for ; Thu, 13 Jun 2024 18:47:01 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B47BFBB2A02 Received: by smtp55.i.mail.ru with esmtpa (envelope-from ) id 1sHmfE-0000000EbVy-3O1z; Thu, 13 Jun 2024 18:47:01 +0300 Content-Type: multipart/alternative; boundary="------------1eeibvQM8TXtg4XnWTXHlYTU" Message-ID: <6875650e-463f-4709-9ffb-31fc113e34b0@tarantool.org> Date: Thu, 13 Jun 2024 18:47:00 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Sergey Bronnikov Cc: tarantool-patches@dev.tarantool.org References: <0968f450b5ddf3a14ef9ef865bafad99a5e626b4.1712841312.git.sergeyb@tarantool.org> <4d732fc9-d878-49ea-9216-68a8133da7de@tarantool.org> In-Reply-To: <4d732fc9-d878-49ea-9216-68a8133da7de@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9AC8CA0B4439200FAA6268B5D05BFD5F405B302337288676B00894C459B0CD1B9F9E0A2794F5A96341D0757D925629472E9055A930BDAAA075A2B1BA3BAC97EF3B92CE970A8DCB349 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE74B51810D54EC17F0C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6778DA827A17800CE745229D52CF30560CEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B043BF0FB74779F366E317BA51BB0A6216C588517161704DEF3E147DE89D06B6BA471835C12D1D9774AD6D5ED66289B5278DA827A17800CE7850F8B975A76562C9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C353FA85A707D24CADCC7F00164DA146DA6F5DAA56C3B73B237318B6A418E8EAB8D32BA5DBAC0009BE9E8FC8737B5C2249A1362912412C4C3276E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8BDB4C7129FAFA27FB3AA81AA40904B5D99C9F4D5AE37F343AD1F44FA8B9022EA23BBE47FD9DD3FB595F5C1EE8F4F765FC72CEEB2601E22B093A03B725D353964B2FFDA4F57982C5F435872C767BF85DA227C277FBC8AE2E8B654CE8ED7C2D004275ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 0D63561A33F958A5C0E729E37048717C5002B1117B3ED69679FE7F6451CC9503F5FEB6EB1EB183FD823CB91A9FED034534781492E4B8EEAD85CCBA673D36D1A4BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF867E4C51D707DEACFC19A20AD7457C61D4B7E9D44561BEA5BE338BEC767C24DA0AA6441730D2A0F004A26A3878DC133030273AA66F40E8CF0563713F9910CD6ED9E25E63B11132B25F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojP/c/PTD82AlPWX1zA8TWQg== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140F9E0A2794F5A96341D0757D925629472346F513F94B8EBDE0152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 4/4][v2] OSX/iOS/ARM64: Fix bytecode embedding in Mach-O object file. 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: Sergey Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" This is a multi-part message in MIME format. --------------1eeibvQM8TXtg4XnWTXHlYTU Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 13.06.2024 18:40, Sergey Bronnikov via Tarantool-patches wrote: > > Hi, Sergey > > > fixes applied and force-pushed > > On 12.04.2024 14:27, Sergey Kaplun via Tarantool-patches wrote: >> Hi, Sergey! >> Thanks for the fixes! >> LGTM, with a several minor nits below. >> >> On 11.04.24, Sergey Bronnikov wrote: >>> From: Mike Pall >>> >>> Thanks to Carlo Cabrera. >>> >>> (cherry picked from commit b98b37231bd2dcb79e10b0f974cefd91eb0d7b3a) >>> >>> Mach-O FAT object files generated by LuaJIT for ARM64 Had >> Typo: s/Had/had/ > Fixed, thanks! >>> an incorrect format due to the usage of the 32-bit version of >>> FFI structure. This patch adds the 64-bit structure definition >> Typo: s/FFI structure/the FFI structure/ > Fixed, thanks! >>> and uses it for ARM64. >>> >>> Sergey Bronnikov: >>> * added the description and the test for the problem >>> >>> Part of tarantool/tarantool#9595 >>> --- >>> src/jit/bcsave.lua | 14 ++++- >>> ...-865-cross-generation-mach-o-file.test.lua | 55 +++++++++++++++++-- >>> 2 files changed, 63 insertions(+), 6 deletions(-) >>> >> >> >>> >>> -- Mach-O FAT object header. >>> @@ -221,9 +263,11 @@ end >>> -- >>> local SUM_CPUTYPE = { >>> arm = 7 + 12, >>> + arm64 = 0x01000007 + 0x0100000c, >> Minor: The comment will be appreciated: >> | x64 + arm64. > Added, thanks! >>> } >>> local SUM_CPUSUBTYPE = { >>> arm = 3 + 9, >>> + arm64 = 3 + 0, >> Minor: The comment will be appreciated: >> | x64 + arm64. > > Added, thanks! > > > Iterative patch below > > > diff --git > a/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua > b/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua > index 661e148e..9c27e12d 100644 > --- > a/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua > +++ > b/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua > @@ -173,7 +173,7 @@ local function read_mach_o(buf, is64) >    local mach_fat_arch_type = ffi.typeof('mach_fat_arch *') >    for i = 0, res.header.nfat_arch - 1 do >      local fat_arch = ffi.cast(mach_fat_arch_type, obj.fat_arch[i]) > -    arch = { > +    local arch = { >        cputype = be32(fat_arch.cputype), >        cpusubtype = be32(fat_arch.cpusubtype), >      } > @@ -184,16 +184,18 @@ local function read_mach_o(buf, is64) >  end > >  -- Defined in . > -local sum_cputype = { > +local SUM_CPUTYPE = { >    x86 = 7, >    x64 = 0x01000007, >    arm = 7 + 12, > +  -- x64 + arm64. >    arm64 = 0x01000007 + 0x0100000c, >  } > -local sum_cpusubtype = { > +local SUM_CPUSUBTYPE = { >    x86 = 3, >    x64 = 3, >    arm = 3 + 9, > +  -- x64 + arm64. >    arm64 = 3 + 0, >  } > > @@ -257,8 +259,8 @@ local function build_and_check_mach_o(is64) >      total_cputype = total_cputype + mach_o.fat_arch[i].cputype >      total_cpusubtype = total_cpusubtype + mach_o.fat_arch[i].cpusubtype >    end > -  test:is(total_cputype, sum_cputype[arch], 'cputype is correct in > Mach-O, ' .. arch) > -  test:is(total_cpusubtype, sum_cpusubtype[arch], 'cpusubtype is > correct in Mach-O, ' .. arch) > +  test:is(total_cputype, SUM_CPUTYPE[arch], 'cputype is correct in > Mach-O, ' .. arch) > +  test:is(total_cpusubtype, SUM_CPUSUBTYPE[arch], 'cpusubtype is > correct in Mach-O, ' .. arch) >  end > >  -- ARM > This is a correct iterative patch: --- a/test/tarantool-tests/lj-865-cross-generation-mach-o-file.test.lua +++ b/test/tarantool-tests/lj-865-cross-generation-mach-o-file.test.lua @@ -262,13 +262,15 @@ end  -- 1. https://opensource.apple.com/source/xnu/xnu-4570.41.2/osfmk/mach/machine.h.auto.html  --  local SUM_CPUTYPE = { -  -- x86 + arm +  -- x86 + arm.    arm = 7 + 12, +  -- x64 + arm64.    arm64 = 0x01000007 + 0x0100000c,  }  local SUM_CPUSUBTYPE = { -  -- x86 + arm +  -- x86 + arm.    arm = 3 + 9, +  -- x64 + arm64.    arm64 = 3 + 0,  } > >>> } >>> >>> -- The function builds Mach-O FAT object file and retrieves >> >> >>> -- >>> 2.34.1 >>> --------------1eeibvQM8TXtg4XnWTXHlYTU Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit


On 13.06.2024 18:40, Sergey Bronnikov via Tarantool-patches wrote:

Hi, Sergey


fixes applied and force-pushed

On 12.04.2024 14:27, Sergey Kaplun via Tarantool-patches wrote:
Hi, Sergey!
Thanks for the fixes!
LGTM, with a several minor nits below.

On 11.04.24, Sergey Bronnikov wrote:
From: Mike Pall <mike>

Thanks to Carlo Cabrera.

(cherry picked from commit b98b37231bd2dcb79e10b0f974cefd91eb0d7b3a)

Mach-O FAT object files generated by LuaJIT for ARM64 Had
Typo: s/Had/had/
Fixed, thanks!
an incorrect format due to the usage of the 32-bit version of
FFI structure. This patch adds the 64-bit structure definition
Typo: s/FFI structure/the FFI structure/
Fixed, thanks!
and uses it for ARM64.

Sergey Bronnikov:
* added the description and the test for the problem

Part of tarantool/tarantool#9595
---
 src/jit/bcsave.lua                            | 14 ++++-
 ...-865-cross-generation-mach-o-file.test.lua | 55 +++++++++++++++++--
 2 files changed, 63 insertions(+), 6 deletions(-)

<snipped>

 
   -- Mach-O FAT object header.
@@ -221,9 +263,11 @@ end
 --
 local SUM_CPUTYPE = {
   arm = 7 + 12,
+  arm64 = 0x01000007 + 0x0100000c,
Minor: The comment will be appreciated:
| x64 + arm64.
Added, thanks!
 }
 local SUM_CPUSUBTYPE = {
   arm = 3 + 9,
+  arm64 = 3 + 0,
Minor: The comment will be appreciated:
| x64 + arm64.

Added, thanks!


Iterative patch below


diff --git a/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua b/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua
index 661e148e..9c27e12d 100644
--- a/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua
+++ b/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua
@@ -173,7 +173,7 @@ local function read_mach_o(buf, is64)
   local mach_fat_arch_type = ffi.typeof('mach_fat_arch *')
   for i = 0, res.header.nfat_arch - 1 do
     local fat_arch = ffi.cast(mach_fat_arch_type, obj.fat_arch[i])
-    arch = {
+    local arch = {
       cputype = be32(fat_arch.cputype),
       cpusubtype = be32(fat_arch.cpusubtype),
     }
@@ -184,16 +184,18 @@ local function read_mach_o(buf, is64)
 end
 
 -- Defined in <src/jit/bcsave.lua:bcsave_machobj>.
-local sum_cputype = {
+local SUM_CPUTYPE = {
   x86 = 7,
   x64 = 0x01000007,
   arm = 7 + 12,
+  -- x64 + arm64.
   arm64 = 0x01000007 + 0x0100000c,
 }
-local sum_cpusubtype = {
+local SUM_CPUSUBTYPE = {
   x86 = 3,
   x64 = 3,
   arm = 3 + 9,
+  -- x64 + arm64.
   arm64 = 3 + 0,
 }
 
@@ -257,8 +259,8 @@ local function build_and_check_mach_o(is64)
     total_cputype = total_cputype + mach_o.fat_arch[i].cputype
     total_cpusubtype = total_cpusubtype + mach_o.fat_arch[i].cpusubtype
   end
-  test:is(total_cputype, sum_cputype[arch], 'cputype is correct in Mach-O, ' .. arch)
-  test:is(total_cpusubtype, sum_cpusubtype[arch], 'cpusubtype is correct in Mach-O, ' .. arch)
+  test:is(total_cputype, SUM_CPUTYPE[arch], 'cputype is correct in Mach-O, ' .. arch)
+  test:is(total_cpusubtype, SUM_CPUSUBTYPE[arch], 'cpusubtype is correct in Mach-O, ' .. arch)
 end
 
 -- ARM

This is a correct iterative patch:


--- a/test/tarantool-tests/lj-865-cross-generation-mach-o-file.test.lua
+++ b/test/tarantool-tests/lj-865-cross-generation-mach-o-file.test.lua
@@ -262,13 +262,15 @@ end
 -- 1. https://opensource.apple.com/source/xnu/xnu-4570.41.2/osfmk/mach/machine.h.auto.html
 --
 local SUM_CPUTYPE = {
-  -- x86 + arm
+  -- x86 + arm.
   arm = 7 + 12,
+  -- x64 + arm64.
   arm64 = 0x01000007 + 0x0100000c,
 }
 local SUM_CPUSUBTYPE = {
-  -- x86 + arm
+  -- x86 + arm.
   arm = 3 + 9,
+  -- x64 + arm64.
   arm64 = 3 + 0,
 }
 


 }
 
 -- The function builds Mach-O FAT object file and retrieves
<snipped>

-- 
2.34.1

--------------1eeibvQM8TXtg4XnWTXHlYTU--