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 4DE28BB2A1D; Thu, 13 Jun 2024 18:40:30 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4DE28BB2A1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1718293230; bh=rjRh0OJdUrR/SLHY4w+rjZnkdhQyvWkxnJNH7tYLjaE=; 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=NKBL9V7ZIWb2/KhkwEo49wjtDm3BcwGzL2ffuA1slPrCP4UVsqqwciRpXDGQyM298 3wkWR7CqcdN8nkq6XdwqrarbwWVZ87uegGQGwTu+U1SJLt0UB8i5d/mL1issJrKKsA 1w09nOulnHNvoMjlxr2+pXs/cG5P0SHv31HY5SIo= Received: from smtp30.i.mail.ru (smtp30.i.mail.ru [95.163.41.71]) (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 AC377BB2A02 for ; Thu, 13 Jun 2024 18:40:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org AC377BB2A02 Received: by smtp30.i.mail.ru with esmtpa (envelope-from ) id 1sHmYt-0000000161e-17CD; Thu, 13 Jun 2024 18:40:27 +0300 Content-Type: multipart/alternative; boundary="------------wuc35KrzbJv5buyM0x0hI1hQ" Message-ID: <4d732fc9-d878-49ea-9216-68a8133da7de@tarantool.org> Date: Thu, 13 Jun 2024 18:40:27 +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> In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9923B2AA154DF63C61EC445C97C7F2A689B9B2CF16763F2F11313CFAB8367EF908E2BE116634AD74DA0417E9C232C8EA7F6D241D2C75691C5AB96D2E101A55A20DE8015D30FE5A0BDDAEE934B56E2D9F8 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE73F300A97FDD4E158EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374F897F3E43A934888638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8C62F567BA4836042A70CE2429498D5BA517041E2AA3B7404CC7F00164DA146DAFE8445B8C89999728AA50765F79006372A3B24BF85B2E607389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8ED96AA85C75E140D117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CFB74263D4D5690889BA3038C0950A5D36C8A9BA7A39EFB766D91E3A1F190DE8FDBA3038C0950A5D36D5E8D9A59859A8B6A237A0FE984815BC76E601842F6C81A1F004C906525384303E02D724532EE2C3F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C789C969B8F27C422C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5483119A642F8E2C25002B1117B3ED6968F21F5E5278DB57A3E67C18142C611B7823CB91A9FED034534781492E4B8EEAD9CFA8CFAC159CE19BDAD6C7F3747799A X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF0208255F7AE7BB1A8B661A05254FB8303F8040476C376B0BC3C74FEDE2920624245B1B6CBED8166A04A26A3878DC13304F985BF1A344E7A00076F189A56B1DC2BF34D5914844E08A5F4332CA8FE04980913E6812662D5F2AB9AF64DB4688768036DF5FE9C0001AF333F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojP/c/PTD82AlMCSWRGDzWHg== X-Mailru-Sender: 520A125C2F17F0B1E52FEF5D219D6140A0417E9C232C8EA7F6D241D2C75691C5E9C1576FCA86E0A10152A3D17938EB451EB5A0BCEC6A560B3DDE9B364B0DF289BE2DA36745F2EEB5CEBA01FB949A1F1EEAB4BC95F72C04283CDA0F3B3F5B9367 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. --------------wuc35KrzbJv5buyM0x0hI1hQ Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 > >> } >> >> -- The function builds Mach-O FAT object file and retrieves > > >> -- >> 2.34.1 >> --------------wuc35KrzbJv5buyM0x0hI1hQ Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

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


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

-- 
2.34.1


    
--------------wuc35KrzbJv5buyM0x0hI1hQ--