<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <p>Hey,</p>
    <p>Are you building jextract yourself? Note that only LLVM version
      13 works, as the naming of unnamed structs and unions in later
      versions leads to these weird struct names.</p>
    <p>See also: <a class="moz-txt-link-freetext" href="https://bugs.openjdk.org/browse/CODETOOLS-7903480">https://bugs.openjdk.org/browse/CODETOOLS-7903480</a><br>
    </p>
    <p>Jorn<br>
    </p>
    <div class="moz-cite-prefix">On 17-7-2024 17:09, Alison Gravley
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:CADo9z7LEEaTWXfBwKk08Z_UGodf3R6GnKhQTndMMwr3VWn-BEA@mail.gmail.com">
      
      <div dir="ltr">I meant to send this months ago, but after commit
        aa5f25003554dffa18289f1be535ea23f75c29c3, which is from January
        18, 2024, I can no longer use this tool on OSX (Arm) as the
        generated wrapper for in6 is invalid and cannot compile. I think
        the commit after this one is where the "--source" flag was
        removed.
        <div><br>
        </div>
        <div><font face="arial, sans-serif">Basically, there are
            "unnamed at
/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/netinet6/in6.h:153:2"
            within the generated java that does not allow it to compile.<br>
          </font>
          <div><br>
          </div>
          <div>I am not able to share the 3rd party library that I am
            using jextract on due to licensing, but in.h is from the OS.
            I am assuming this is being generated due to the library
            including these:</div>
          <div><br>
          </div>
          <div>```</div>
          <div><font face="monospace">#include <signal.h><br>
              #include <sys/socket.h><br>
              #include <arpa/inet.h><br>
              #include <netinet/tcp.h><br>
              #include <netinet/in.h><br>
              #include <netdb.h></font><br>
          </div>
          <div>```</div>
          <div><br>
          </div>
          <div>
            <div>Back in January, the generated in6_addr.java looked
              like this:</div>
            <div><br>
              <font face="monospace">```</font></div>
            <div><font face="monospace">import
                java.lang.invoke.MethodHandle;<br>
                import java.lang.invoke.VarHandle;<br>
                import java.nio.ByteOrder;<br>
                import java.lang.foreign.*;<br>
                import static java.lang.foreign.ValueLayout.*;<br>
                /**<br>
                 * {@snippet :<br>
                 * struct in6_addr {<br>
                 *     union  __u6_addr;<br>
                 * };<br>
                 * }<br>
                 */<br>
                public class in6_addr {<br>
                <br>
                    public static MemoryLayout $LAYOUT() {<br>
                        return constants$41.const$0;<br>
                    }<br>
                    /**<br>
                     * {@snippet :<br>
                     * union {<br>
                     *     unsigned char __u6_addr8[16];<br>
                     *     unsigned short __u6_addr16[8];<br>
                     *     unsigned int __u6_addr32[4];<br>
                     * };<br>
                     * }<br>
                     */<br>
                    public static final class __u6_addr {<br>
                <br>
                        // Suppresses default constructor, ensuring
                non-instantiability.<br>
                        private __u6_addr() {}<br>
                        public static MemoryLayout $LAYOUT() {<br>
                            return constants$41.const$1;<br>
                        }<br>
                        public static MemorySegment
                __u6_addr8$slice(MemorySegment seg) {<br>
                            return seg.asSlice(0, 16);<br>
                        }<br>
                        public static MemorySegment
                __u6_addr16$slice(MemorySegment seg) {<br>
                            return seg.asSlice(0, 16);<br>
                        }<br>
                        public static MemorySegment
                __u6_addr32$slice(MemorySegment seg) {<br>
                            return seg.asSlice(0, 16);<br>
                        }<br>
                        public static long sizeof() { return
                $LAYOUT().byteSize(); }<br>
                        public static MemorySegment
                allocate(SegmentAllocator allocator) { return
                allocator.allocate($LAYOUT()); }<br>
                        public static MemorySegment allocateArray(long
                len, SegmentAllocator allocator) {<br>
                            return
                allocator.allocate(MemoryLayout.sequenceLayout(len,
                $LAYOUT()));<br>
                        }<br>
                        public static MemorySegment
                ofAddress(MemorySegment addr, Arena scope) { return
                RuntimeHelper.asArray(addr, $LAYOUT(), 1, scope); }<br>
                    }<br>
                <br>
                    public static MemorySegment
                __u6_addr$slice(MemorySegment seg) {<br>
                        return seg.asSlice(0, 16);<br>
                    }<br>
                    public static long sizeof() { return
                $LAYOUT().byteSize(); }<br>
                    public static MemorySegment
                allocate(SegmentAllocator allocator) { return
                allocator.allocate($LAYOUT()); }<br>
                    public static MemorySegment allocateArray(long len,
                SegmentAllocator allocator) {<br>
                        return
                allocator.allocate(MemoryLayout.sequenceLayout(len,
                $LAYOUT()));<br>
                    }<br>
                    public static MemorySegment ofAddress(MemorySegment
                addr, Arena scope) { return RuntimeHelper.asArray(addr,
                $LAYOUT(), 1, scope); }<br>
                }</font><br>
            </div>
            <div>```</div>
          </div>
          <div><br>
          </div>
          <div>Now I get lines like this in the generated java. I
            attached the full version:</div>
          <div><span style="font-family:monospace">private static final
              GroupLayout $LAYOUT = MemoryLayout.structLayout(</span><br style="font-family:monospace">
            <span style="font-family:monospace">        in6_addr.union
              (unnamed at /Library/Developer/</span><span style="font-family:monospace">CommandLineTools/SDKs/</span><span style="font-family:monospace">MacOSX14.sdk/usr/include/</span><span style="font-family:monospace">netinet6/in6.h:153:2).layout()</span><span style="font-family:monospace">.withName("__u6_addr")</span><br style="font-family:monospace">
            <span style="font-family:monospace">   
              ).withName("in6_addr");</span><br>
          </div>
          <div><br>
          </div>
          <div><br>
          </div>
        </div>
      </div>
    </blockquote>
  </body>
</html>