From 31ab4480bdc94b1028fcf3512899bf37c2b62682 Mon Sep 17 00:00:00 2001 From: Ben Taylor Date: Wed, 7 Feb 2024 22:33:58 +0000 Subject: [PATCH] Add a crossCompile build flag to enable libz linking fix on aarch64 --- installers/linux/universal/tar/build.gradle | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/installers/linux/universal/tar/build.gradle b/installers/linux/universal/tar/build.gradle index 07a1f127c0d..4b6b886dc4b 100644 --- a/installers/linux/universal/tar/build.gradle +++ b/installers/linux/universal/tar/build.gradle @@ -89,6 +89,22 @@ task executeBuild(type: Exec) { dependsOn configureBuild workingDir "$buildRoot" commandLine 'make', 'images' + /* When cross-compiling for aarch64, gcc incorrectly links against + * libz.so, provided by the -devel packages, instead of libz.so.1 + * This can lead to runtime errors of the form + * javac: error while loading shared libraries: libz.so: cannot open shared object file: No such file or directory + * As a workaround, use patchelf to update all references to libz.so to the expected libz.so.1 + * + * See also: + * - https://github.com/AppImage/AppImageKit/issues/964 + * - https://github.com/AppImage/AppImageKit/issues/1092 + * - https://github.com/electron-userland/electron-builder/issues/7835 + * - https://github.com/CollaboraOnline/richdocumentscode/issues/68 + * - https://github.com/Sienci-Labs/gsender/issues/420 + */ + if (project.hasProperty("corretto.crossCompile")) { + commandLine 'bash', '-c', "find ${imageDir} -type f -exec patchelf --replace-needed libz.so libz.so.1 {} \\; 2>/dev/null" + } outputs.dir jdkResultingImage }