Transmutation of native binaries into JVM apps.
2.0K
clodl computes the closure of a shared object. That is, given
a shared library or a position independent executable (PIE), it
returns a single, self-contained file packing all dependencies. Think
of the result as a poor man's container image. Compared to containers:
Executing a closure in the address space of an existing process enables lightweight high-speed interop between the closure and the rest of the process. The closure can natively invoke any function in the process without marshalling/unmarshalling any arguments, and vice versa.
clodl is useful for "jarifying" native binaries. Provided shim Java
code, closures can be packed inside a JAR and then loaded at runtime
into the JVM. This makes JAR's an alternative packaging format to
publish and deploy native binaries.
clodl is implemented as a set
of Bazel build rules. It integrates with your
Bazel build system, e.g. as follows:
cc_binary(
name = "hello.so",
srcs = ["*.c"],
linkedshared = 1,
)
library_closure(
name = "hello-closure",
srcs = ["hello.so"],
testonly = True,
)
java_binary(
name = "hello-jar",
resources = [":hello-closure"],
main_class = ...,
srcs = ...,
runtime_deps = ...,
)
Requirements:
To build and test:
$ bazel test //...
Any position independent (dynamically linked) executable
(PIE) can be "closed" using clodl.
On OS X, all executables are PIE.
To create a PIE on Linux and other platforms, pass the -pie flag to
the linker. Currently, we furthermore require "origin processing" to
be turned on. Here is the full set of options to pass to ld:
$ gcc -pie -Wl,-z,origin -Wl,-rpath,$ORIGIN ...
Some distributions create position independent executables by default (Ubuntu and Debian on some architectures).
Copyright (c) 2015-2018 EURL Tweag.
All rights reserved.
clodl is free software, and may be redistributed under the terms specified in the LICENSE file.

clodl is maintained by Tweag I/O.
Have questions? Need help? Tweet at @tweagio.
Content type
Image
Digest
Size
723 MB
Last updated
almost 9 years ago
docker pull tweag/jarify