<!DOCTYPE html>
<html data-lt-installed="true">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body style="padding-bottom: 1px;">
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 13.06.2024 18:40, Sergey Bronnikov
      via Tarantool-patches wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:4d732fc9-d878-49ea-9216-68a8133da7de@tarantool.org">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <p>Hi, Sergey</p>
      <p><br>
      </p>
      <p>fixes applied and force-pushed<br>
      </p>
      <div class="moz-cite-prefix">On 12.04.2024 14:27, Sergey Kaplun
        via Tarantool-patches wrote:<br>
      </div>
      <blockquote type="cite" cite="mid:ZhkaspQGR4Hi94n0@root">
        <pre class="moz-quote-pre" wrap="">Hi, Sergey!
Thanks for the fixes!
LGTM, with a several minor nits below.

On 11.04.24, Sergey Bronnikov wrote:
</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">From: Mike Pall <mike>

Thanks to Carlo Cabrera.

(cherry picked from commit b98b37231bd2dcb79e10b0f974cefd91eb0d7b3a)

Mach-O FAT object files generated by LuaJIT for ARM64 Had
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">Typo: s/Had/had/</pre>
      </blockquote>
      Fixed, thanks!<br>
      <blockquote type="cite" cite="mid:ZhkaspQGR4Hi94n0@root">
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">an incorrect format due to the usage of the 32-bit version of
FFI structure. This patch adds the 64-bit structure definition
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">Typo: s/FFI structure/the FFI structure/</pre>
      </blockquote>
      Fixed, thanks!<br>
      <blockquote type="cite" cite="mid:ZhkaspQGR4Hi94n0@root">
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">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(-)

</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap=""><snipped>

</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap=""> 
   -- Mach-O FAT object header.
@@ -221,9 +263,11 @@ end
 --
 local SUM_CPUTYPE = {
   arm = 7 + 12,
+  arm64 = 0x01000007 + 0x0100000c,
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">Minor: The comment will be appreciated:
| x64 + arm64.
</pre>
      </blockquote>
      Added, thanks!<br>
      <blockquote type="cite" cite="mid:ZhkaspQGR4Hi94n0@root">
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap=""> }
 local SUM_CPUSUBTYPE = {
   arm = 3 + 9,
+  arm64 = 3 + 0,
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap="">Minor: The comment will be appreciated:
| x64 + arm64.</pre>
      </blockquote>
      <p>Added, thanks!</p>
      <p><br>
      </p>
      <p>Iterative patch below</p>
      <p><br>
      </p>
      <p>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<br>
        index 661e148e..9c27e12d 100644<br>
        ---
a/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua<br>
        +++
b/test/tarantool-tests/lj-865-fix_generation_of_mach-o_object_files.test.lua<br>
        @@ -173,7 +173,7 @@ local function read_mach_o(buf, is64)<br>
           local mach_fat_arch_type = ffi.typeof('mach_fat_arch *')<br>
           for i = 0, res.header.nfat_arch - 1 do<br>
             local fat_arch = ffi.cast(mach_fat_arch_type,
        obj.fat_arch[i])<br>
        -    arch = {<br>
        +    local arch = {<br>
               cputype = be32(fat_arch.cputype),<br>
               cpusubtype = be32(fat_arch.cpusubtype),<br>
             }<br>
        @@ -184,16 +184,18 @@ local function read_mach_o(buf, is64)<br>
         end<br>
         <br>
         -- Defined in <src/jit/bcsave.lua:bcsave_machobj>.<br>
        -local sum_cputype = {<br>
        +local SUM_CPUTYPE = {<br>
           x86 = 7,<br>
           x64 = 0x01000007,<br>
           arm = 7 + 12,<br>
        +  -- x64 + arm64.<br>
           arm64 = 0x01000007 + 0x0100000c,<br>
         }<br>
        -local sum_cpusubtype = {<br>
        +local SUM_CPUSUBTYPE = {<br>
           x86 = 3,<br>
           x64 = 3,<br>
           arm = 3 + 9,<br>
        +  -- x64 + arm64.<br>
           arm64 = 3 + 0,<br>
         }<br>
         <br>
        @@ -257,8 +259,8 @@ local function build_and_check_mach_o(is64)<br>
             total_cputype = total_cputype + mach_o.fat_arch[i].cputype<br>
             total_cpusubtype = total_cpusubtype +
        mach_o.fat_arch[i].cpusubtype<br>
           end<br>
        -  test:is(total_cputype, sum_cputype[arch], 'cputype is correct
        in Mach-O, ' .. arch)<br>
        -  test:is(total_cpusubtype, sum_cpusubtype[arch], 'cpusubtype
        is correct in Mach-O, ' .. arch)<br>
        +  test:is(total_cputype, SUM_CPUTYPE[arch], 'cputype is correct
        in Mach-O, ' .. arch)<br>
        +  test:is(total_cpusubtype, SUM_CPUSUBTYPE[arch], 'cpusubtype
        is correct in Mach-O, ' .. arch)<br>
         end<br>
         <br>
         -- ARM<br>
      </p>
    </blockquote>
    <p>This is a correct iterative patch:</p>
    <p><br>
    </p>
    <p>---
      a/test/tarantool-tests/lj-865-cross-generation-mach-o-file.test.lua<br>
      +++
      b/test/tarantool-tests/lj-865-cross-generation-mach-o-file.test.lua<br>
      @@ -262,13 +262,15 @@ end<br>
       -- 1.
<a class="moz-txt-link-freetext" href="https://opensource.apple.com/source/xnu/xnu-4570.41.2/osfmk/mach/machine.h.auto.html">https://opensource.apple.com/source/xnu/xnu-4570.41.2/osfmk/mach/machine.h.auto.html</a><br>
       --<br>
       local SUM_CPUTYPE = {<br>
      -  -- x86 + arm<br>
      +  -- x86 + arm.<br>
         arm = 7 + 12,<br>
      +  -- x64 + arm64.<br>
         arm64 = 0x01000007 + 0x0100000c,<br>
       }<br>
       local SUM_CPUSUBTYPE = {<br>
      -  -- x86 + arm<br>
      +  -- x86 + arm.<br>
         arm = 3 + 9,<br>
      +  -- x64 + arm64.<br>
         arm64 = 3 + 0,<br>
       }<br>
       <br>
    </p>
    <blockquote type="cite"
      cite="mid:4d732fc9-d878-49ea-9216-68a8133da7de@tarantool.org">
      <p> <br>
      </p>
      <blockquote type="cite" cite="mid:ZhkaspQGR4Hi94n0@root">
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap=""> }
 
 -- The function builds Mach-O FAT object file and retrieves
</pre>
        </blockquote>
        <pre class="moz-quote-pre" wrap=""><snipped>

</pre>
        <blockquote type="cite">
          <pre class="moz-quote-pre" wrap="">-- 
2.34.1

</pre>
        </blockquote>
      </blockquote>
      <lt-container></lt-container>
    </blockquote>
  </body>
</html>