GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Zig cross-compilation of native libraries by bp-alex · Pull Request #217 · lmdbjava/lmdbjava

Conversation

@bp-alex

@bp-alex bp-alex commented Apr 23, 2023

Copy link
Copy Markdown
Member

This new approach provides a number of benefits:

  1. The LmdbJava Native project can be archived. This project required coordination with LmdbJava module releases and added extra artifacts to Maven Central simply to wrap native libraries. The native project also required a great deal of Maven configuration and it was always tedious to support additional platforms. Using Zig eliminates the need to run QEMU emulators in builds to support unusual platforms etc.

  2. Zig supports numerous cross-compilation targets straight out of the box. A full list is available via zig targets | jq -r '.libc[]' and this presently lists 64 on my machine. This is likely to accommodate most LmdbJava platform support requests we are likely to receive.

  3. Platform naming conventions have now been standardised based on the Zig target name. Support for individual build chains or specific processors is now simplified and much more transparent.

  4. The GitHub Action has been amended to perform cross-compilation under Linux and upload the resulting native artifacts for later build steps. The later build steps run the Verifier on a native VM where available (eg Windows, Mac OS) and this therefore tests the cross-compiled libraries.

  5. Target name resolution logic has been refactored and externalised in its own class with corresponding unit tests to ensure corner cases are duly considered and any bugs more easily reproduced and permanently rectified.

This change is backwards compatible with users who used (and may continue to use) the lmdbjava.native.lib system property.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@bp-alex
Zig cross-compilation of native libraries
ae0257a
This new approach provides a number of benefits:

1. The LmdbJava Native project can be archived. This project required
coordination with LmdbJava module releases and added extra artifacts
to Maven Central simply to wrap native libraries. The native project
also required a great deal of Maven configuration and it was always
tedious to support additional platforms. Using Zig eliminates the need
to run QEMU emulators in builds to support unusual platforms etc.

2. Zig supports numerous cross-compilation targets straight out of the
box. A full list is available via zig targets | jq -r '.libc[]' and
this presently lists 64 on my machine. This is likely to accommodate
most LmdbJava platform support requests we are likely to receive.

3. Platform naming conventions have now been standardised based on the
Zig target name. Support for individual build chains or specific
processors is now simplified and much more transparent.

4. The GitHub Action has been amended to perform cross-compilation
under Linux and upload the resulting native artifacts for later build
steps. The later build steps run the Verifier on a native VM where
available (eg Windows, Mac OS) and this therefore tests the
cross-compiled libraries.

5. Target name resolution logic has been refactored and externalised
in its own class with corresponding unit tests to ensure corner cases
are duly considered and any bugs more easily reproduced and
permanently rectified.

This change is backwards compatible with users who used (and may
continue to use) the lmdbjava.native.lib system property.
@bp-alex bp-alex mentioned this pull request Apr 23, 2023
Add support for Linux and Mac ARM platforms #216
Closed
@wardle

wardle commented Apr 23, 2023

Copy link
Copy Markdown
Contributor

I can use mvn package with no test errors on Linux x86 and Mac OS X ARM64 with master branch head, and the same with this new PR. I will do some more tests using mvn package on mac arm64, but the build jar files appear to work.

bp-alex and mrmeszaros reacted with hooray emoji
All reactions
  • 🎉 2 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bp-alex
bp-alex merged commit 288bb09 into lmdbjava:master Apr 24, 2023
This was referenced Apr 24, 2023
Add cross-compilation for Mac and Linux ARM systems lmdbjava/native#13
Closed
aarch64, ppc64le, Profiles for secondary archs, Linux and Linux with Android NDK installed lmdbjava/native#9
Closed
Ports to aarch64 and ppc64le systems with OS pages 65536 bytes big #165
Closed
bp-alex added a commit that referenced this pull request Apr 24, 2023
@bp-alex
JavaDoc corrections (follows #217)
d87bc4b
bp-alex added a commit that referenced this pull request Apr 24, 2023
@bp-alex
Remove hard-coded package name resolution (follows #217)
98c233d
@bp-alex bp-alex mentioned this pull request Apr 24, 2023
Compatibility with Java 19 - Modularize? Minimizing use of unsupported JDK parts? #208
Closed
@phraktle phraktle mentioned this pull request Apr 24, 2023
Bug: Library not found for Arch64 SpaiR/imgui-java#165
Closed
@jubax

jubax commented Oct 9, 2023

Copy link
Copy Markdown

I'm not 100% sure about the state of this issue. My impression: It has been fixed, but so far there is not public release which contains the fix. Is that correct? In that case it would be really nice to ship a new lmdbjava version (current: 0.8.3).

mrmeszaros reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bp-alex

bp-alex commented Oct 9, 2023

Copy link
Copy Markdown
Member Author

@jubax, you are correct in that this is scheduled for inclusion in 0.9.0 as per the Change Log.

I need to have a closer look at #215 before I release 0.9.0 in case it's a bug, after which I will make a release (I've follow a "Zero Bug Policy" for a couple of decades now; it's the only way to keep on top of them!).

jubax, mrmeszaros, and garrett-hopper reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bp-alex added a commit that referenced this pull request Oct 30, 2025
@bp-alex
Replace Zig cross-compilation with native library artifact
e5b510c
Commit 288bb09 introduced Zig cross-compilation of LMDB (#217).
Benchmarking as part of #262 revealed the cross-compiled libraries are
significantly slower than LMDB compiled with native toolchains. Using
the methodology from e634b3f:

Library Source                  Score (ms)   Delta vs Baseline
--------------------------------------------------------------
System Arch Linux (GCC)         45.00        Baseline
Fetched Arch Linux (GCC)        45.03        +0.05%
Zig unoptimized (debug)         59.01        +31.12%
Zig optimized (-O2 stripped)    58.82        +30.70%

This removes Zig cross-compilation and adopts the org.lmdbjava:native
artifact, which packages LMDB libraries compiled with native toolchains
from distribution package managers. This simplifies building as Zig
installation and cross-compile.sh are no longer required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@bp-alex @wardle @jubax
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.