Skip to content

Add support for libc-specific Linux native library variants - #1748

Open
EduardoRadieske wants to merge 1 commit into
java-native-access:masterfrom
EduardoRadieske:feat/add-support-multiple-variants
Open

EduardoRadieske wants to merge 1 commit into
java-native-access:masterfrom
EduardoRadieske:feat/add-support-multiple-variants

Conversation

@EduardoRadieske

Copy link
Copy Markdown

Closes #1694

Summary

Allow multiple Linux native library variants compiled for glibc and musl to coexist on the classpath, selecting the matching variant at runtime based on the libc used by the current process.

Resource layout

For example, on Linux x86-64, resources can be packaged using the following layout:

linux-x86-64-glibc/
    libexample.so
linux-x86-64-musl/
    libexample.so
linux-x86-64/
    libexample.so

The libc-specific directories follow the naming convention <RESOURCE_PREFIX>-<libc>, where <libc> is glibc or musl.

The existing linux-x86-64/ resource path remains available as a legacy fallback, preserving compatibility with existing resource layouts.

Changes

  • Detect the libc implementation used by the current Linux process through /proc/self/maps.
  • Prefer the matching libc-specific resource when resolving non-absolute classpath resource names.
  • Fall back to the legacy resource when the libc is unknown or the matching variant is unavailable.
  • Preserve existing resource lookup behavior for absolute resource paths and non-Linux platforms.

Tests

  • Add PlatformTest coverage for libc detection, ambiguous or missing indicators, read failures, deleted mappings, and false-positive paths.
  • Add LibraryLoadTest coverage for variant selection, prevention of selecting the opposite libc variant, and fallback behavior.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for libraries based on C-standard library musl

1 participant