diff --git a/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix b/pkgs/development/compilers/graalvm/community-edition/mkGraal.nix index 77f0fa9b7dc5..eac94b7ec1ea 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 -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 + 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 - '' + # 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 \