You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/12/13 22:01:36 UTC
[maven-mvnd] branch master updated: Build mostly static native image, loose linux glibc requirement to 2.12 (#730)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git
The following commit(s) were added to refs/heads/master by this push:
new 1249211b Build mostly static native image, loose linux glibc requirement to 2.12 (#730)
1249211b is described below
commit 1249211b49dccae770a8602dd17c2ac275f7981a
Author: James Z.M. Gao <ga...@360.cn>
AuthorDate: Wed Dec 14 06:01:31 2022 +0800
Build mostly static native image, loose linux glibc requirement to 2.12 (#730)
---
.github/workflows/early-access.yaml | 19 ++++++++++++++-
.github/workflows/release.yaml | 19 ++++++++++++++-
client/pom.xml | 47 ++++++++++++++++++++++++++++++-------
3 files changed, 75 insertions(+), 10 deletions(-)
diff --git a/.github/workflows/early-access.yaml b/.github/workflows/early-access.yaml
index 3715c969..865331c8 100644
--- a/.github/workflows/early-access.yaml
+++ b/.github/workflows/early-access.yaml
@@ -57,8 +57,25 @@ jobs:
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
+ - name: 'Maven clean'
+ run: ./mvnw clean -Dmrm=false -B -ntp -e
+
+ - name: 'Patch Graal libs for only requiring glibc 2.12'
+ shell: bash
+ run: |
+ if [[ $OS == linux ]] && [[ $GRAALVM_HOME ]] && [[ -d "$GRAALVM_HOME/lib/static/linux-amd64/glibc" ]]; then
+ mkdir -p client/target/graalvm-libs-for-glibc-2.12
+ echo "memcpy memcpy@GLIBC_2.2.5" >client/target/glibc.redef
+ echo "posix_spawn posix_spawn@GLIBC_2.2.5" >>client/target/glibc.redef
+ find "$GRAALVM_HOME/lib/static/linux-amd64/glibc" -name '*.a' | while IFS= read -r input; do
+ output="client/target/graalvm-libs-for-glibc-2.12/$(basename -- "$input")"
+ objcopy --redefine-syms=client/target/glibc.redef -- "$input" "$output" 2>/dev/null
+ done
+ find /usr/lib -name libz.a | xargs -r -I {} objcopy --redefine-syms=client/target/glibc.redef {} client/target/graalvm-libs-for-glibc-2.12/libz.a
+ fi
+
- name: 'Build native distribution'
- run: ./mvnw clean verify -Pnative -Dmrm=false -B -ntp -e
+ run: ./mvnw verify -Pnative -Dmrm=false -B -ntp -e
- name: 'Upload daemon test logs'
if: always()
diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml
index 6b1c9063..3e0590e1 100644
--- a/.github/workflows/release.yaml
+++ b/.github/workflows/release.yaml
@@ -58,8 +58,25 @@ jobs:
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
+ - name: 'Maven clean'
+ run: ./mvnw clean -Dmrm=false -B -ntp -e
+
+ - name: 'Patch Graal libs for only requiring glibc 2.12'
+ shell: bash
+ run: |
+ if [[ $OS == linux ]] && [[ $GRAALVM_HOME ]] && [[ -d "$GRAALVM_HOME/lib/static/linux-amd64/glibc" ]]; then
+ mkdir -p client/target/graalvm-libs-for-glibc-2.12
+ echo "memcpy memcpy@GLIBC_2.2.5" >client/target/glibc.redef
+ echo "posix_spawn posix_spawn@GLIBC_2.2.5" >>client/target/glibc.redef
+ find "$GRAALVM_HOME/lib/static/linux-amd64/glibc" -name '*.a' | while IFS= read -r input; do
+ output="client/target/graalvm-libs-for-glibc-2.12/$(basename -- "$input")"
+ objcopy --redefine-syms=client/target/glibc.redef -- "$input" "$output" 2>/dev/null
+ done
+ find /usr/lib -name libz.a | xargs -r -I {} objcopy --redefine-syms=client/target/glibc.redef {} client/target/graalvm-libs-for-glibc-2.12/libz.a
+ fi
+
- name: 'Build native distribution'
- run: ./mvnw clean verify -Pnative -Dmrm=false -B -ntp -e -DskipTests
+ run: ./mvnw verify -Pnative -Dmrm=false -B -ntp -e -DskipTests
- name: 'Upload artifact'
uses: actions/upload-artifact@v2
diff --git a/client/pom.xml b/client/pom.xml
index 81f90dd6..3b082ecf 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -33,6 +33,8 @@
<properties>
<maven.compiler.target>11</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
+ <graalvm-native-static-opt/>
+ <graalvm-native-glibc-opt/>
</properties>
<dependencies>
@@ -134,8 +136,34 @@
<profiles>
<profile>
- <id>native</id>
+ <id>enable-partial-static-native</id>
+ <activation>
+ <os>
+ <family>!mac</family>
+ </os>
+ </activation>
+ <properties>
+ <graalvm-native-static-opt>-H:+StaticExecutableWithDynamicLibC</graalvm-native-static-opt>
+ </properties>
+ </profile>
+ <profile>
+ <id>linux-image-only-require-glibc-2.12</id>
+ <activation>
+ <os>
+ <family>linux</family>
+ </os>
+ <file>
+ <exists>target/graalvm-libs-for-glibc-2.12</exists>
+ </file>
+ </activation>
+ <properties>
+ <graalvm-native-glibc-opt>-H:CLibraryPath=${project.build.directory}/graalvm-libs-for-glibc-2.12</graalvm-native-glibc-opt>
+ </properties>
+ </profile>
+
+ <profile>
+ <id>native</id>
<build>
<plugins>
<plugin>
@@ -146,13 +174,16 @@
<mainClass>org.mvndaemon.mvnd.client.DefaultClient</mainClass>
<imageName>mvnd</imageName>
<buildArgs>--no-server
- --no-fallback
- --allow-incomplete-classpath
- -H:IncludeResources=org/mvndaemon/mvnd/.*
- -H:IncludeResources=mvnd-bash-completion.bash
- -H:-ParseRuntimeOptions
- -H:+AddAllCharsets
- -ea</buildArgs>
+ --no-fallback
+ --allow-incomplete-classpath
+ ${graalvm-native-static-opt}
+ ${graalvm-native-glibc-opt}
+ -H:IncludeResources=org/mvndaemon/mvnd/.*
+ -H:IncludeResources=mvnd-bash-completion.bash
+ -H:-ParseRuntimeOptions
+ -H:+AddAllCharsets
+ -H:+ReportExceptionStackTraces
+ -ea</buildArgs>
</configuration>
<executions>
<execution>