Description
Feature request
Build-once, run-anywhere, but for native-image
Is your feature request related to a problem? Please describe.
Currently, one must run a Native Image build for each operating system and architecture pair which they want to target with their software.
Describe the solution you'd like.
GraalVM supports targeting glibc
and musl
as LibC backends. If GraalVM additionally supported Cosmopolitan Libc, GraalVM users could compile once and ship to all major operating systems, and even micro-architectures, with one binary: Linux, macOS, Windows, FreeBSD, OpenBSD, NetBSD and even BIOS.
Describe who do you think will benefit the most.
Firstly this benefits GraalVM developers, because iteration on software could be much faster if native builds only needed to occur once and remained testable on multiple operating systems.
Secondly, this benefits consumers of software built by GraalVM developers, because a distribution option would become available which only involves one single binary.
Consider that CI systems, local development/testing, and nearly all popular forms of software distribution (downloads, archives, things like group policy) multiply in complexity with the number of output targets needed. By reducing these targets to just one (where appropriate) while maintaining cross-OS and cross-architecture compatibility, complexity of distribution of GraalVM native programs drops to meet Java's build-once-run-anywhere standard.
For use cases which should remain optimized to a target architecture, the pluggable nature of GraalVM's LibC support should still allow targeting glibc
or musl
(for example, tailored-for-purpose server binaries).
Describe alternatives you've considered.
-
Containers: Docker containers and other cross-platform virtualization methods are already supported by GraalVM, but incur a performance and tooling penalty; binaries cannot be run directly, only wrapped in a container, which must be built, downloaded, and executed with underlying OS support.
-
WASM: Although GraalVM can execute WASM, WebAssembly isn't ready for this task because GraalVM can't yet target WASM for
native-image
.
Additional context.
I tried to build a native-image
using Cosmopolitan, but wasn't able to get far, and I think contributing this feature is outside the scope of my skillset.
Express whether you'd like to help contributing this feature
I would be happy to help with a stacktrace, reproducer, or with contributions in Java. Justine Tunney, the author of Cosmo, is very open to contributions and there is an active community.