pages tagged iperlENETDOWNhttp://enetdown.org//tag/iperl/ENETDOWNikiwiki2022-09-14T20:06:25ZZMQ::FFI for IPerlhttp://enetdown.org//hacktivity/posts/2022/09/14/zmq-ffi-for-iperl/zaki2022-09-14T20:06:25Z2022-09-14T20:06:25Z
<p>Like many FOSS hacking stories, it all started on IRC. Somebody in <code>#perl</code>
mentioned that they were having issues with working with ZeroMQ and an event
loop. I mentioned that I had a module
<a href="https://p3rl.org/Net::Async::ZMQ">Net::Async::ZMQ</a> that could help. Turns out that they
had been reading the code for that but were trying to make it work with
<a href="https://p3rl.org/ZMQ::FFI">ZMQ::FFI</a>
instead of
<a href="https://p3rl.org/ZMQ::LibZMQ3">ZMQ::LibZMQ3</a> and
<a href="https://p3rl.org/ZMQ::LibZMQ4">ZMQ::LibZMQ4</a> which it was originally
designed for.</p>
<p>So I <a href="https://github.com/zmughal-CPAN/p5-Net-Async-ZMQ/pull/5">added support for <code>ZMQ::FFI</code></a>.
But for my CI build to pass, I needed Windows support and <code>ZMQ::FFI</code> did not
support Windows yet.</p>
<p>I then did the next obvious thing which is patch <code>ZMQ::FFI</code> to work on Windows.
In my first attempt, I found tests that were using <code>fork(2)</code>, <code>Sys::SigAction</code>,
and the ZeroMQ <code>ipc://</code> transport (<code>zmq_ipc(7)</code>) which do not work on Windows,
so I left those as is and just decided to have <code>ZMQ::FFI</code> look for <code>.dll</code> in
addition to <code>.so</code> and <code>.dylib</code> files. That's not great; those tests should
really pass before a release can be made.</p>
<p>As time went by, I went ahead and released <a href="https://metacpan.org/release/ZMUGHAL/Net-Async-ZMQ-0.002">Net-Async-ZMQ-0.002</a>.
No use in waiting for Windows to pass for <code>ZMQ::FFI</code> when it never did before.</p>
<p>Until one night I acquired a round tuit and went ahead and <a href="https://github.com/zeromq/perlzmq/pull/44">fixed all the <code>ZMQ::FFI</code> Windows compatibility issues</a>.
I also changed the <code>ipc://</code> transport to <code>inproc://</code> where possible, however,
this changes the tests on Unix-likes. So I went with another attempt that <a href="https://github.com/zeromq/perlzmq/pull/47">refactored
the tests based on OS capability</a>.
This and several CI build fixes got rolled into <a href="https://metacpan.org/release/GHENRY/ZMQ-FFI-1.18">ZMQ-FFI-1.18</a>.</p>
<p>While I was working on all this, I decided that I wanted to port
<a href="https://p3rl.org/Devel::IPerl">Devel::IPerl</a> to use <code>ZMQ::FFI</code> because it
could be easier to install for users on Windows than <code>ZMQ::LibZMQ3</code> which
requires a compiler to link the XS with the ZeroMQ DLL. This is currently a
pain point for <code>Devel::IPerl</code> that I work around by providing a script that sets up
<code>Alien::ZMQ::latest</code> to install the ZeroMQ DLL and then points the
<code>ZMQ::LibZMQ3</code> install script to use that DLL for linking. Removing that script
will make things less complicated overall.</p>
<p>Which is what I did in <a href="https://github.com/EntropyOrg/p5-Devel-IPerl/pull/113">this PR</a>.
It did not take much, just replace functions such as <code>zmq_init()</code> with <code>ZMQ::FFI->new</code> and
<code>zmq_socket($zmq_ctx, $type)</code> with <code>$zmq_ctx->socket($type)</code>.</p>
<p>This is now available on CPAN as <a href="https://metacpan.org/release/ZMUGHAL/Devel-IPerl-0.012">Devel-IPerl-0.012</a>.</p>
<h1 id="appendix:listofissuesandpullrequestsparticipatedinalongtheway">Appendix: List of issues and pull requests participated in along the way</h1>
<h2 id="devel::iperl">Devel::IPerl</h2>
<ul>
<li><a href="https://github.com/EntropyOrg/p5-Devel-IPerl/pull/113">Port from ZMQ::LibZMQ3 to ZMQ::FFI by zmughal · Pull Request #113 · EntropyOrg/p5-Devel-IPerl · GitHub</a></li>
</ul>
<h2 id="zmq::ffi">ZMQ::FFI</h2>
<ul>
<li><a href="https://github.com/zeromq/perlzmq/pull/44">Add MSWin32 support and cross-platform CI testing by zmughal · Pull Request #44 · zeromq/perlzmq · GitHub</a></li>
<li><a href="https://github.com/zeromq/perlzmq/pull/45">Add Docker test using GitHub Actions by zmughal · Pull Request #45 · zeromq/perlzmq · GitHub</a></li>
<li><a href="https://github.com/zeromq/perlzmq/pull/47">MSWin32 compatibility and test portability by zmughal · Pull Request #47 · zeromq/perlzmq · GitHub</a></li>
<li><a href="https://github.com/zeromq/perlzmq/pull/48">Optional support for Alien::ZMQ::latest by zmughal · Pull Request #48 · zeromq/perlzmq · GitHub</a></li>
<li><a href="https://github.com/zeromq/perlzmq/pull/49">Fix build needed for release by zmughal · Pull Request #49 · zeromq/perlzmq · GitHub</a></li>
<li><a href="https://github.com/zeromq/perlzmq/pull/50">GHA: disable fail-fast by zmughal · Pull Request #50 · zeromq/perlzmq · GitHub</a></li>
</ul>
<h2 id="alien::zmq::latest">Alien::ZMQ::latest</h2>
<ul>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/pull/7">Only use Alien::gmake for shared install by zmughal · Pull Request #7 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/pull/8">Update CI to use GHA by zmughal · Pull Request #8 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/pull/9">Add workflow for Strawberry Perl by zmughal · Pull Request #9 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/issues/10">Try to get CMake working on Windows · Issue #10 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/pull/11">Add option for choosing build configuration tool by zmughal · Pull Request #11 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/pull/12">Set make for autoconf build by zmughal · Pull Request #12 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/pull/13">Use Download::GitHub by zmughal · Pull Request #13 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/issues/14">CMake build not working on new Windows Strawberry Perl install · Issue #14 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Alien-ZMQ-latest/pull/15">Set CMAKE_MAKE_PROGRAM by zmughal · Pull Request #15 · zmughal-CPAN/p5-Alien-ZMQ-latest · GitHub</a></li>
</ul>
<h2 id="net::async::zmq">Net::Async::ZMQ</h2>
<ul>
<li><a href="https://github.com/zmughal-CPAN/p5-Net-Async-ZMQ/issues/3">Look into supporting ZMQ::FFI backend · Issue #3 · zmughal-CPAN/p5-Net-Async-ZMQ · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Net-Async-ZMQ/pull/4">Switch from Test::Requires to Test::Needs by zmughal · Pull Request #4 · zmughal-CPAN/p5-Net-Async-ZMQ · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Net-Async-ZMQ/pull/5">Add support for ZMQ::FFI by zmughal · Pull Request #5 · zmughal-CPAN/p5-Net-Async-ZMQ · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Net-Async-ZMQ/pull/6">Update CI, use GHA by zmughal · Pull Request #6 · zmughal-CPAN/p5-Net-Async-ZMQ · GitHub</a></li>
<li><a href="https://github.com/zmughal-CPAN/p5-Net-Async-ZMQ/pull/7">Use ZMQ_POLLIN event by zmughal · Pull Request #7 · zmughal-CPAN/p5-Net-Async-ZMQ · GitHub</a></li>
</ul>
<h2 id="microsoftvcpkg">microsoft/vcpkg</h2>
<ul>
<li><a href="https://github.com/microsoft/vcpkg/pull/22681">(zeromq) Cherry pick patches to fix build issues by LilyWangLL · Pull Request #22681 · microsoft/vcpkg · GitHub</a></li>
<li><a href="https://github.com/microsoft/vcpkg/pull/23435">(zeromq) Download patch files for GitHub PRs by zmughal · Pull Request #23435 · microsoft/vcpkg · GitHub</a></li>
<li><a href="https://github.com/microsoft/vcpkg/issues/23461">zeromq build failure because of port file with invalid hash (inconsistent) · Issue #23461 · microsoft/vcpkg · GitHub</a></li>
</ul>
<h2 id="run-vcpkggithubaction">run-vcpkg GitHub Action</h2>
<ul>
<li><a href="https://github.com/lukka/run-vcpkg/issues/135">vcpkgGitURL seems to have no effect · Issue #135 · lukka/run-vcpkg · GitHub</a></li>
</ul>
<h2 id="githubthewebsiteitself">GitHub (the website itself)</h2>
<ul>
<li><a href="https://github.com/orgs/community/discussions/12531">Patch URL from pull requests should use full index to maintain stable contents · Discussion #12531 · community · GitHub</a></li>
</ul>