<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Hello Tyler,</p>
<p><br>
</p>
<p>First of all, thanks for trying this out!</p>
<p><br>
</p>
<p>To answer some of your questions:<br>
</p>
<p><br>
> Does this createLibffiBundle.sh get called programmatically
during the build process (I can't seem to find where that would
happen currently), or does each platform check in a bundle with a
compiled version of the library to source control (and the build
phase assumes it's present for those platforms that support it)? <br>
<br>
</p>
<p>I pointed to the createLibffiBundle.sh script as an example, so
you could get a rough idea of the steps I took. The script takes a
devkit as input, which is an artifact we use internally for our CI
builds. These bundles (devkit and libffi) are not distributed.<br>
</p>
<p><br>
</p>
<p>The libffi library is either automatically detected by the build
system if it is installed in a well-known system location, or it
can be provided manually using the --with-libffi configure option
(I've used the latter myself). I you'd like to know how the build
works, I suggest taking a look at the ./make/autoconf/lib-ffi.m4
file, which is responsible for pulling the contents of the
--with-libffi option into the build system. It basically sets up
several make variables with compiler and linker options. You could
grep through the rest of the ./make folder for some of the
LIBFFI_* variables that are 'exported' at the end of the
lib-ffi.m4 file using AC_SUBST. For the fallback linker you should
find the relevant usages in the ./make/modules/java.base/lib.gmk
file (near the end).</p>
<p></p>
<p><br>
</p>
<p>To incorporate the library (.dll/.so/.dylib) into the JDK, it is
essentially just copied into the right folder of the built JDK
image. Automatic copying can be turned on using the
--enable-libffi-bundling configuration flag. In practice, I'm
using `--with-libffi=<path to extracted bundle>
--enable-libffi-bundling --enable-fallback-linker` to create a
working JDK image.</p>
<p><br>
</p>
<p>> At present I'm getting an error at build time after enabling
the fallback linker on aix.<br>
<br>
This is likely caused by an outdated version of libffi. The
ffi_get_struct_offsets function was added in version 3.3, so that
one or a later version should work. I've done all my testing with
version 3.4.2, so I recommend going with that.</p>
<p><br>
</p>
<p>Also, note that we decided to postpone making the linker API
required for now. Given the deprecation of the 32-bit Windows x86
port in JDK 21, making the linker API required after that port is
removed would avoid the need of having to amend the public API and
implementation to allow selecting one of the 2 major ABIs on that
platform (cdecl or stdcall).<br>
</p>
<p><br>
</p>
<p>HTH,<br>
Jorn<br>
</p>
<p><br>
</p>
<div class="moz-cite-prefix">On 09/06/2023 19:02, Tyler Steele
wrote:<br>
</div>
<blockquote type="cite" cite="mid:CO1PR15MB50040FE20DAF13F96D6419158551A@CO1PR15MB5004.namprd15.prod.outlook.com">
<style type="text/css" style="display:none;">P {margin-top:0;margin-bottom:0;}</style>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0">
Hello Jorn and fellow porters,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0">
I am following up with this message from Jorn from a few months
ago [1]. I am generally supportive of their proposal, but I am
not certain how to implement it. I have successfully built and
bundled libffi on AIX, but I didn't use the
createLibffiBundle.sh script provided by the PR.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0 ContentPasted1">
What I'm feeling confused about is how libffi will be
incorporated into the jvm. Does this createLibffiBundle.sh get
called programmatically during the build process (I can't seem
to find where that would happen currently), or does each
platform check in a bundle with a compiled version of the
library to source control (and the build phase assumes it's
present for those platforms that support it)? At present I'm
getting an error at build time after enabling the fallback
linker on aix.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0 ContentPasted1">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0 ContentPasted1 ContentPasted2">
src/java.base/share/native/libfallbackLinker/fallbackLinker.c:66:10:
warning: implicit declaration of function
'ffi_get_struct_offsets' is invalid in C99
[-Wimplicit-function-declaration]
<div class="ContentPasted2"> return
ffi_get_struct_offsets((ffi_abi) abi, jlong_to_ptr(type),
jlong_to_ptr(offsets));</div>
<div class="ContentPasted2"> ^</div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0 ContentPasted1 ContentPasted2">
Which is not totally surprising given that I haven't figured out
how to link it yet.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0 ContentPasted1 ContentPasted2">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0 ContentPasted1 ContentPasted2">
Thanks in advance,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0 ContentPasted1 ContentPasted2">
Tyler</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif;
font-size: 12pt; color: rgb(0, 0, 0);" class="elementToProof
ContentPasted0">
[1]
<a class="moz-txt-link-freetext" href="https://mail.openjdk.org/pipermail/porters-dev/2023-March/000753.html">https://mail.openjdk.org/pipermail/porters-dev/2023-March/000753.html</a><br>
</div>
</blockquote>
</body>
</html>