diff options
author | Thiago Kenji Okada <thiagokokada@gmail.com> | 2022-04-19 19:36:51 +0100 |
---|---|---|
committer | Thiago Kenji Okada <thiagokokada@gmail.com> | 2022-04-19 20:33:03 +0100 |
commit | aa2a396048f3dfc42dc17bc99ef68ce7cc9c40d7 (patch) | |
tree | 6c888fb9c3bb5a97e13aec615bd63151bcb0786f /pkgs/development/compilers/graalvm | |
parent | bf27ea9cdb0c7cdc1f7aee1a29914b83684dac03 (diff) |
graalvmXX-ce: refactor
- Simplify `preFixup` phase - Update documentation - Quote some variables
Diffstat (limited to 'pkgs/development/compilers/graalvm')
-rw-r--r-- | pkgs/development/compilers/graalvm/community-edition/mkGraal.nix | 63 |
1 files changed, 28 insertions, 35 deletions
diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index 77f0fa9b7dc5e..eac94b7ec1eab 100644 --- a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix +++ b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix @@ -29,8 +29,8 @@ # See `update.nix` file for a description on how this file works , sourcesPath ? ./. + "/graalvm${javaVersion}-ce-sources.json" # Use musl instead of glibc to allow true static builds in GraalVM's - # Native Image (i.e.: `--static --libc=musl`). This will cause glibc builds - # to fail, so it should be used with care + # Native Image (i.e.: `--static --libc=musl`). This will cause glibc static + # builds to fail, so it should be used with care , useMusl ? false }: @@ -85,7 +85,7 @@ let ] ++ lib.optionals useMusl [ (lib.getDev musl) # GraalVM 21.3.0+ expects musl-gcc as <system>-musl-gcc - (writeShellScriptBin "${stdenv.system}-musl-gcc" ''${lib.getDev musl}/bin/musl-gcc "$@"'') + (writeShellScriptBin "${stdenv.hostPlatform.system}-musl-gcc" ''${lib.getDev musl}/bin/musl-gcc "$@"'') ]); withNativeImageSvm = builtins.elem "native-image-installable-svm" platform.products; @@ -169,8 +169,6 @@ let outputs = [ "out" "lib" ]; installPhase = '' - # ensure that $lib/lib exists to avoid breaking builds - mkdir -p $lib/lib # jni.h expects jni_md.h to be in the header search path. ln -s $out/include/linux/*_md.h $out/include/ @@ -181,25 +179,26 @@ let if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF ${ - lib.optionalString (stdenv.isLinux) '' - # provide libraries needed for static compilation - ${ - if useMusl then - "for f in ${musl.stdenv.cc.cc}/lib/* ${musl}/lib/* ${zlib.static}/lib/*; do" - else - "for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do" - } - ln -s $f $out/lib/svm/clibraries/${platform.arch}/$(basename $f) - done - - # add those libraries to $lib output too, so we can use them with - # `native-image -H:CLibraryPath=''${lib.getLib graalvmXX-ce}/lib ...` and reduce - # closure size by not depending on GraalVM $out (that is much bigger) - mkdir -p $lib/lib - for f in ${glibc}/lib/*; do - ln -s $f $lib/lib/$(basename $f) - done - '' + lib.optionalString (stdenv.isLinux) '' + # provide libraries needed for static compilation + ${ + if useMusl then + ''for f in "${musl.stdenv.cc.cc}/lib/"* "${musl}/lib/"* "${zlib.static}/lib/"*; do'' + else + ''for f in "${glibc}/lib/"* "${glibc.static}/lib/"* "${zlib.static}/lib/"*; do'' + } + ln -s "$f" "$out/lib/svm/clibraries/${platform.arch}/$(basename $f)" + done + + # add those libraries to $lib output too, so we can use them with + # `native-image -H:CLibraryPath=''${lib.getLib graalvmXX-ce}/lib ...` and reduce + # closure size by not depending on GraalVM $out (that is much bigger) + # we always use glibc here, since musl is only supported for static compilation + mkdir -p "$lib/lib" + for f in "${glibc}/lib/"*; do + ln -s "$f" "$lib/lib/$(basename $f)" + done + '' } ''; @@ -210,17 +209,11 @@ let autoPatchelfIgnoreMissingDeps = withRubySvm && stdenv.isDarwin; preFixup = lib.optionalString (stdenv.isLinux) '' - # We cannot use -exec since wrapProgram is a function but not a - # command. - # - # jspawnhelper is executed from JVM, so it doesn't need to wrap it, - # and it breaks building OpenJDK (#114495). - for bin in $( find "$out" -executable -type f -not -path '*/languages/ruby/lib/gems/*' -not -name jspawnhelper ); do - if patchelf --print-interpreter "$bin" &> /dev/null || head -n 1 "$bin" | grep '^#!' -q; then - wrapProgram "$bin" \ - --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" \ - --prefix PATH : "${runtimeDependencies}" - fi + # Find all executables in any directory that contains '/bin/' + for bin in $(find "$out" -executable -type f -wholename '*/bin/*'); do + wrapProgram "$bin" \ + --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" \ + --prefix PATH : "${runtimeDependencies}" done find "$out" -name libfontmanager.so -exec \ |