Skip to content

Commit

Permalink
Merge pull request #244 from graalvm/ls/native-static-images
Browse files Browse the repository at this point in the history
Upgrade native-static-images demo.
  • Loading branch information
olyagpl committed Dec 19, 2023
2 parents 4ec54e8 + 460f698 commit 27a2f40
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
7 changes: 1 addition & 6 deletions .github/workflows/native-static-images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
include:
- version: 'latest'
java-version: '17'
- version: 'dev'
java-version: 'dev'
java-version: ['21', 'dev']
steps:
- uses: actions/checkout@v3
- uses: graalvm/setup-graalvm@v1
with:
version: ${{ matrix.version }}
java-version: ${{ matrix.java-version }}
components: 'native-image'
native-image-musl: 'true'
Expand Down
11 changes: 5 additions & 6 deletions native-static-images/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Building Statically Linked or Mostly-Statically Linked Native Executables.
# Building Statically Linked or Mostly-Statically Linked Native Executables

GraalVM Native Image by default builds dynamically linked binaries: at build time it loads your application classes and interfaces and hooks them together in a process of dynamic linking.

Expand All @@ -24,14 +24,13 @@ This guide shows how to build a fully static and mostly-static native executable

## Preparation

1. Download and install the latest GraalVM JDK with Native Image using the [GraalVM JDK Downloader](https://github.com/graalvm/graalvm-jdk-downloader):
1. Download and install the latest GraalVM JDK using [SDKMAN!](https://sdkman.io/).
```bash
bash <(curl -sL https://get.graalvm.org/jdk) -c 'native-image'
sdk install java 21.0.1-graal
```

To meet the prerequisites, you need to install the `musl` toolchain, compile and install `zlib` into the toolchain.

2. Download the `musl` toolchain from [musl.cc](https://musl.cc/). (We recommend [this one](https://more.musl.cc/10/x86_64-linux-musl/x86_64-linux-musl-native.tgz). Extract the toolchain to a directory of your choice. This directory will be referred as `$TOOLCHAIN_DIR`.
2. Download the `musl` toolchain from [musl.cc](https://musl.cc/). We recommend [this one](https://more.musl.cc/10/x86_64-linux-musl/x86_64-linux-musl-native.tgz). Extract the toolchain to a directory of your choice. This directory will be referred as `$TOOLCHAIN_DIR`.

Download the latest `zlib` library sources from [zlib.net](https://zlib.net/) and extract them. (This documentation uses `zlib-1.2.11`.)
Create a new environment variable, named `CC`:
Expand Down Expand Up @@ -91,7 +90,7 @@ One way to check what dynamic libraries your application depends on is to run `l

With GraalVM Native Image you can build a mostly-static native executable that statically links everything except `libc`. Statically linking all your libraries except `libc` ensures your application has all the libraries it needs to run on any Linux `libc`-based distribution.

To build a a mostly-static native executable for the above _EnvMap.java_ demo, run:
To build a mostly-static native executable for the above _EnvMap.java_ demo, run:

```shell
$JAVA_HOME/bin/native-image -H:+StaticExecutableWithDynamicLibC EnvMap
Expand Down

0 comments on commit 27a2f40

Please sign in to comment.