Unverified Commit 88c5afe1 authored by Thiago Kenji Okada's avatar Thiago Kenji Okada Committed by GitHub
Browse files

Merge pull request #257433 from thiagokokada/graalvm-bump

graalvm-ce: 22.3.1 -> 21.0.0
parents bd9b686c 6a871922
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -165,6 +165,10 @@

- PHP now defaults to PHP 8.2, updated from 8.1.

- GraalVM has been updated to the latest version, and this brings significant changes. Upstream don't release multiple versions targeting different JVMs anymore, so now we only have one GraalVM derivation (`graalvm-ce`). While at first glance the version may seem a downgrade (22.3.1 -> 21.0.0), the major version is now following the JVM it targets (so this latest version targets JVM 21). Also some products like `llvm-installable-svm` and `native-image-svm` were incorporate to the main GraalVM derivation, so they're included by default.

- GraalPy (`graalCEPackages.graalpy`), TruffleRuby (`graalCEPackages.truffleruby`), GraalJS (`graalCEPackages.graaljs`) and GraalNodeJS (`grallCEPackages.graalnodejs`) are now indepedent from the main GraalVM derivation.

- The ISC DHCP package and corresponding module have been removed, because they are end of life upstream. See https://www.isc.org/blogs/isc-dhcp-eol/ for details and switch to a different DHCP implementation like kea or dnsmasq.

- `prometheus-unbound-exporter` has been replaced by the Let's Encrypt maintained version, since the previous version was archived. This requires some changes to the module configuration, most notable `controlInterface` needs migration
+0 −2
Original line number Diff line number Diff line
@@ -71,7 +71,5 @@ stdenv.mkDerivation ({
    platforms = graalvmDrv.meta.platforms;
    # default to executable name
    mainProgram = executable;
    # need to have native-image-installable-svm available
    broken = !(builtins.any (p: (p.product or "") == "native-image-installable-svm") graalvmDrv.products);
  } // meta;
} // extraArgs)
+90 −42
Original line number Diff line number Diff line
@@ -7,20 +7,23 @@
, darwin
, fontconfig
, glib
, glibc
, gtk3
, makeWrapper
, musl
, runCommandCC
, setJavaClassPath
, unzip
, xorg
, zlib
  # extra params
, javaVersion
, meta ? { }
, products ? [ ]
, extraCLibs ? [ ]
, gtkSupport ? stdenv.isLinux
, useMusl ? false
, ...
} @ args:

assert useMusl -> stdenv.isLinux;
let
  extraArgs = builtins.removeAttrs args [
    "lib"
@@ -32,24 +35,56 @@ let
    "darwin"
    "fontconfig"
    "glib"
    "glibc"
    "gtk3"
    "makeWrapper"
    "musl"
    "runCommandCC"
    "setJavaClassPath"
    "unzip"
    "xorg"
    "zlib"
    "javaVersion"
    "meta"
    "products"
    "extraCLibs"
    "gtkSupport"
    "useMusl"
    "passthru"
    "meta"
  ];

  cLibs = lib.optionals stdenv.isLinux (
    [ glibc zlib.static ]
    ++ lib.optionals (!useMusl) [ glibc.static ]
    ++ lib.optionals useMusl [ musl ]
    ++ extraCLibs
  );

  # GraalVM 21.3.0+ expects musl-gcc as <system>-musl-gcc
  musl-gcc = (runCommandCC "musl-gcc" { } ''
    mkdir -p $out/bin
    ln -s ${lib.getDev musl}/bin/musl-gcc $out/bin/${stdenv.hostPlatform.system}-musl-gcc
  '');
  # GraalVM 23.0.0+ (i.e.: JDK 21.0.0+) clean-up the environment inside darwin
  # So we need to re-added some env vars to make everything work correctly again
  darwin-cc = (runCommandCC "darwin-cc"
    {
      nativeBuildInputs = [ makeWrapper ];
      buildInputs = [ darwin.apple_sdk.frameworks.Foundation zlib ];
    } ''
    makeWrapper ${stdenv.cc}/bin/cc $out/bin/cc \
      --prefix NIX_CFLAGS_COMPILE_${stdenv.cc.suffixSalt} : "$NIX_CFLAGS_COMPILE" \
      --prefix NIX_LDFLAGS_${stdenv.cc.suffixSalt} : "$NIX_LDFLAGS"
  '');
  binPath = lib.makeBinPath (
    lib.optionals stdenv.isDarwin [ darwin-cc ]
    ++ lib.optionals useMusl [ musl-gcc ]
    ++ [ stdenv.cc ]
  );

  runtimeLibraryPath = lib.makeLibraryPath
    ([ cups ] ++ lib.optionals gtkSupport [ cairo glib gtk3 ]);
  mapProducts = key: default: (map (p: p.graalvmPhases.${key} or default) products);
  concatProducts = key: lib.concatStringsSep "\n" (mapProducts key "");

  graalvmXXX-ce = stdenv.mkDerivation ({
    pname = "graalvm${javaVersion}-ce";
  graalvm-ce = stdenv.mkDerivation ({
    pname = "graalvm-ce";

    unpackPhase = ''
      runHook preUnpack
@@ -81,12 +116,6 @@ let
      runHook postUnpack
    '';

    postUnpack = ''
      for product in ${toString products}; do
        cp -Rv $product/* $out
      done
    '';

    dontStrip = true;

    nativeBuildInputs = [ unzip makeWrapper ]
@@ -106,7 +135,6 @@ let
      xorg.libXtst
    ];

    preInstall = concatProducts "preInstall";
    postInstall = ''
      # jni.h expects jni_md.h to be in the header search path.
      ln -sf $out/include/linux/*_md.h $out/include/
@@ -117,14 +145,17 @@ let
      cat > $out/nix-support/setup-hook << EOF
      if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi
      EOF
    '' + concatProducts "postInstall";

      wrapProgram $out/bin/native-image \
        --prefix PATH : ${binPath} \
        ${toString (map (l: "--add-flags '-H:CLibraryPath=${l}/lib'") cLibs)}
    '';

    preFixup = lib.optionalString (stdenv.isLinux) ''
      for bin in $(find "$out/bin" -executable -type f); do
        wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}"
      done
    '' + concatProducts "preFixup";
    postFixup = concatProducts "postFixup";
    '';

    doInstallCheck = true;
    installCheckPhase = ''
@@ -136,31 +167,48 @@ let
        echo '1 + 1' | $out/bin/jshell
      ''}

      echo ${
        lib.escapeShellArg ''
      echo ${lib.escapeShellArg ''
        public class HelloWorld {
          public static void main(String[] args) {
            System.out.println("Hello World");
          }
        }
        ''
      } > HelloWorld.java
      ''} > HelloWorld.java
      $out/bin/javac HelloWorld.java

      # run on JVM with Graal Compiler
      echo "Testing GraalVM"
      $out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World'

      ${concatProducts "installCheckPhase"}
      echo "Ahead-Of-Time compilation"
      $out/bin/native-image -H:+UnlockExperimentalVMOptions -H:-CheckToolchain -H:+ReportExceptionStackTraces HelloWorld
      ./helloworld | fgrep 'Hello World'

      ${# --static is only available in Linux
      lib.optionalString (stdenv.isLinux && !useMusl) ''
        echo "Ahead-Of-Time compilation with -H:+StaticExecutableWithDynamicLibC"
        $out/bin/native-image -H:+UnlockExperimentalVMOptions -H:+StaticExecutableWithDynamicLibC HelloWorld
        ./helloworld | fgrep 'Hello World'

        echo "Ahead-Of-Time compilation with --static"
        $out/bin/native-image --static HelloWorld
        ./helloworld | fgrep 'Hello World'
      ''}

      ${# --static is only available in Linux
      lib.optionalString (stdenv.isLinux && useMusl) ''
        echo "Ahead-Of-Time compilation with --static and --libc=musl"
        $out/bin/native-image --static HelloWorld --libc=musl
        ./helloworld | fgrep 'Hello World'
      ''}

      runHook postInstallCheck
    '';

    passthru = {
      inherit products;
      home = graalvmXXX-ce;
      updateScript = ./update.sh;
    };
      home = graalvm-ce;
      updateScript = [ ./update.sh "graalvm-ce" ];
    } // (args.passhtru or { });

    meta = with lib; ({
      homepage = "https://www.graalvm.org/";
@@ -169,7 +217,7 @@ let
      sourceProvenance = with sourceTypes; [ binaryNativeCode ];
      mainProgram = "java";
      maintainers = with maintainers; teams.graalvm-ce.members ++ [ ];
    } // meta);
    } // (args.meta or { }));
  } // extraArgs);
in
graalvmXXX-ce
graalvm-ce
+23 −55
Original line number Diff line number Diff line
{ lib
, stdenv
, autoPatchelfHook
, darwin
, graalvm-ce
, makeWrapper
, perl
, unzip
, zlib
, libxcrypt-legacy
  # extra params
, product
, javaVersion
, extraBuildInputs ? [ ]
, extraNativeBuildInputs ? [ ]
, graalvmPhases ? { }
, meta ? { }
, passthru ? { }
, ...
} @ args:

@@ -23,24 +18,21 @@ let
    "lib"
    "stdenv"
    "autoPatchelfHook"
    "darwin"
    "graalvm-ce"
    "libxcrypt-legacy"
    "makeWrapper"
    "perl"
    "unzip"
    "zlib"
    "product"
    "javaVersion"
    "extraBuildInputs"
    "extraNativeBuildInputs"
    "graalvmPhases"
    "meta"
    "passthru"
  ];
in
stdenv.mkDerivation ({
  pname = "${product}-java${javaVersion}";
  pname = product;

  nativeBuildInputs = [ perl unzip makeWrapper ]
  nativeBuildInputs = [ makeWrapper ]
    ++ lib.optional stdenv.isLinux autoPatchelfHook
    ++ extraNativeBuildInputs;

@@ -48,61 +40,37 @@ stdenv.mkDerivation ({
    stdenv.cc.cc.lib # libstdc++.so.6
    zlib
    libxcrypt-legacy # libcrypt.so.1 (default is .2 now)
  ] ++ extraBuildInputs;
  ]
  ++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Foundation
  ++ extraBuildInputs;

  unpackPhase = ''
    runHook preUnpack

    unpack_jar() {
      local jar="$1"
      unzip -q -o "$jar" -d "$out"
      perl -ne 'use File::Path qw(make_path);
                use File::Basename qw(dirname);
                if (/^(.+) = (.+)$/) {
                  make_path dirname("$ENV{out}/$1");
                  symlink $2, "$ENV{out}/$1";
                }' "$out/META-INF/symlinks"
      perl -ne 'if (/^(.+) = ([r-])([w-])([x-])([r-])([w-])([x-])([r-])([w-])([x-])$/) {
                  my $mode = ($2 eq 'r' ? 0400 : 0) + ($3 eq 'w' ? 0200 : 0) + ($4  eq 'x' ? 0100 : 0) +
                              ($5 eq 'r' ? 0040 : 0) + ($6 eq 'w' ? 0020 : 0) + ($7  eq 'x' ? 0010 : 0) +
                              ($8 eq 'r' ? 0004 : 0) + ($9 eq 'w' ? 0002 : 0) + ($10 eq 'x' ? 0001 : 0);
                  chmod $mode, "$ENV{out}/$1";
                }' "$out/META-INF/permissions"
      rm -rf "$out/META-INF"
    }
    mkdir -p "$out"

    unpack_jar "$src"
    tar xf "$src" -C "$out" --strip-components=1

    runHook postUnpack
  '';

  # Allow autoPatchelf to automatically fix lib references between products
  fixupPhase = ''
    runHook preFixup
    # Sanity check
    if [ ! -d "$out/bin" ]; then
      echo "The `bin` is directory missing after extracting the graalvm"
      echo "tarball, please compare the directory structure of the"
      echo "tarball with what happens in the unpackPhase (in particular"
      echo "with regards to the `--strip-components` flag)."
      exit 1
    fi

    mkdir -p $out/lib
    shopt -s globstar
    ln -s $out/languages/**/lib/*.so $out/lib

    runHook postFixup
    runHook postUnpack
  '';

  dontInstall = true;
  dontBuild = true;
  dontStrip = true;

  passthru = {
    inherit product javaVersion;
    # build phases that are going to run during GraalVM derivation build,
    # since they depend in having the fully setup GraalVM environment
    # e.g.: graalvmPhases.installCheckPhase will run the checks only after
    # GraalVM+products is build
    # see buildGraalvm.nix file for the available phases
    inherit graalvmPhases;
  } // passthru;
    updateScript = [ ./update.sh product ];
  } // (args.passhtru or { });

  meta = with lib; ({
  meta = ({
    inherit (graalvm-ce.meta) homepage license sourceProvenance maintainers platforms;
    description = "High-Performance Polyglot VM (Product: ${product})";
  } // meta);
  } // (args.meta or { }));
} // extraArgs)
+8 −225
Original line number Diff line number Diff line
@@ -4,237 +4,20 @@
, fetchurl
}:

let
{
  buildGraalvm = callPackage ./buildGraalvm.nix;
  buildGraalvmProduct = callPackage ./buildGraalvmProduct.nix;
  javaPlatform = {
    "aarch64-linux" = "linux-aarch64";
    "x86_64-linux" = "linux-amd64";
    "aarch64-darwin" = "darwin-aarch64";
    "x86_64-darwin" = "darwin-amd64";
  };
  javaPlatformVersion = javaVersion:
    "${javaVersion}-${javaPlatform.${stdenv.system} or (throw "Unsupported platform: ${stdenv.system}")}";
  source = product: javaVersion: (import ./hashes.nix).${product}.${javaPlatformVersion javaVersion}
    or (throw "Unsupported product combination: product=${product} java=${javaVersion} system=${stdenv.system}");

in
rec {
  inherit buildGraalvm buildGraalvmProduct;

  ### Java 11 ###

  # Mostly available for build purposes, not to be exposed at the top level
  graalvm11-ce-bare = buildGraalvm rec {
    version = "22.3.1";
    javaVersion = "11";
    src = fetchurl (source "graalvm-ce" javaVersion);
    meta.platforms = builtins.attrNames javaPlatform;
    products = [ ];
  };

  graalvm11-ce = graalvm11-ce-bare.override {
    products = [ native-image-installable-svm-java11 ];
  };

  # Mostly available for testing, not to be exposed at the top level
  graalvm11-ce-full = graalvm11-ce-bare.override {
    products = [
      js-installable-svm-java11
      llvm-installable-svm-java11
      native-image-installable-svm-java11
      nodejs-installable-svm-java11
      python-installable-svm-java11
      ruby-installable-svm-java11
      wasm-installable-svm-java11
    ];
  };

  js-installable-svm-java11 = callPackage ./js-installable-svm.nix rec {
    javaVersion = "11";
    version = "22.3.1";
    src = fetchurl (source "js-installable-svm" javaVersion);
  };

  llvm-installable-svm-java11 = callPackage ./llvm-installable-svm.nix rec {
    javaVersion = "11";
    version = "22.3.1";
    src = fetchurl (source "llvm-installable-svm" javaVersion);
  };

  native-image-installable-svm-java11 = callPackage ./native-image-installable-svm.nix rec {
    javaVersion = "11";
    version = "22.3.1";
    src = fetchurl (source "native-image-installable-svm" javaVersion);
  };

  nodejs-installable-svm-java11 = callPackage ./nodejs-installable-svm.nix rec {
    javaVersion = "11";
    version = "22.3.1";
    src = fetchurl (source "nodejs-installable-svm" javaVersion);
    graalvm-ce = graalvm11-ce-bare;
  };

  python-installable-svm-java11 = callPackage ./python-installable-svm.nix rec {
    javaVersion = "11";
    version = "22.3.1";
    src = fetchurl (source "python-installable-svm" javaVersion);
  };

  ruby-installable-svm-java11 = callPackage ./ruby-installable-svm.nix rec {
    javaVersion = "11";
    version = "22.3.1";
    src = fetchurl (source "ruby-installable-svm" javaVersion);
    llvm-installable-svm = llvm-installable-svm-java11;
  };

  wasm-installable-svm-java11 = callPackage ./wasm-installable-svm.nix rec {
    javaVersion = "11";
    version = "22.3.1";
    src = fetchurl (source "wasm-installable-svm" javaVersion);
  };

  ### Java 17 ###

  # Mostly available for build purposes, not to be exposed at the top level
  graalvm17-ce-bare = buildGraalvm rec {
    version = "22.3.1";
    javaVersion = "17";
    src = fetchurl (source "graalvm-ce" javaVersion);
    meta.platforms = builtins.attrNames javaPlatform;
    products = [ ];
  };

  graalvm17-ce = graalvm17-ce-bare.override {
    products = [ native-image-installable-svm-java17 ];
  };

  # Mostly available for testing, not to be exposed at the top level
  graalvm17-ce-full = graalvm17-ce-bare.override {
    products = [
      js-installable-svm-java17
      llvm-installable-svm-java17
      native-image-installable-svm-java17
      nodejs-installable-svm-java17
      python-installable-svm-java17
      ruby-installable-svm-java17
      wasm-installable-svm-java17
    ];
  };

  js-installable-svm-java17 = callPackage ./js-installable-svm.nix rec {
    javaVersion = "17";
    version = "22.3.1";
    src = fetchurl (source "js-installable-svm" javaVersion);
  };

  llvm-installable-svm-java17 = callPackage ./llvm-installable-svm.nix rec {
    javaVersion = "17";
    version = "22.3.1";
    src = fetchurl (source "llvm-installable-svm" javaVersion);
  };

  native-image-installable-svm-java17 = callPackage ./native-image-installable-svm.nix rec {
    javaVersion = "17";
    version = "22.3.1";
    src = fetchurl (source "native-image-installable-svm" javaVersion);
  };

  nodejs-installable-svm-java17 = callPackage ./nodejs-installable-svm.nix rec {
    javaVersion = "17";
    version = "22.3.1";
    src = fetchurl (source "nodejs-installable-svm" javaVersion);
    graalvm-ce = graalvm17-ce-bare;
  };

  python-installable-svm-java17 = callPackage ./python-installable-svm.nix rec {
    javaVersion = "17";
    version = "22.3.1";
    src = fetchurl (source "python-installable-svm" javaVersion);
  };

  ruby-installable-svm-java17 = callPackage ./ruby-installable-svm.nix rec {
    javaVersion = "17";
    version = "22.3.1";
    src = fetchurl (source "ruby-installable-svm" javaVersion);
    llvm-installable-svm = llvm-installable-svm-java17;
  };

  wasm-installable-svm-java17 = callPackage ./wasm-installable-svm.nix rec {
    javaVersion = "17";
    version = "22.3.1";
    src = fetchurl (source "wasm-installable-svm" javaVersion);
  };

  ### Java 19 ###

  # Mostly available for build purposes, not to be exposed at the top level
  graalvm19-ce-bare = buildGraalvm rec {
    version = "22.3.1";
    javaVersion = "19";
    src = fetchurl (source "graalvm-ce" javaVersion);
    meta.platforms = builtins.attrNames javaPlatform;
    products = [ ];
  };

  graalvm19-ce = graalvm19-ce-bare.override {
    products = [ native-image-installable-svm-java19 ];
  };

  # Mostly available for testing, not to be exposed at the top level
  graalvm19-ce-full = graalvm19-ce-bare.override {
    products = [
      js-installable-svm-java19
      llvm-installable-svm-java19
      native-image-installable-svm-java19
      nodejs-installable-svm-java19
      python-installable-svm-java19
      ruby-installable-svm-java19
      wasm-installable-svm-java19
    ];
  };

  js-installable-svm-java19 = callPackage ./js-installable-svm.nix rec {
    javaVersion = "19";
    version = "22.3.1";
    src = fetchurl (source "js-installable-svm" javaVersion);
  };
  buildGraalvmProduct = callPackage ./buildGraalvmProduct.nix;

  llvm-installable-svm-java19 = callPackage ./llvm-installable-svm.nix rec {
    javaVersion = "19";
    version = "22.3.1";
    src = fetchurl (source "llvm-installable-svm" javaVersion);
  };
  graalvm-ce = callPackage ./graalvm-ce { };

  native-image-installable-svm-java19 = callPackage ./native-image-installable-svm.nix rec {
    javaVersion = "19";
    version = "22.3.1";
    src = fetchurl (source "native-image-installable-svm" javaVersion);
  };
  graalvm-ce-musl = callPackage ./graalvm-ce { useMusl = true; };

  nodejs-installable-svm-java19 = callPackage ./nodejs-installable-svm.nix rec {
    javaVersion = "19";
    version = "22.3.1";
    src = fetchurl (source "nodejs-installable-svm" javaVersion);
    graalvm-ce = graalvm19-ce-bare;
  };
  graaljs = callPackage ./graaljs { };

  python-installable-svm-java19 = callPackage ./python-installable-svm.nix rec {
    javaVersion = "19";
    version = "22.3.1";
    src = fetchurl (source "python-installable-svm" javaVersion);
  };
  graalnodejs = callPackage ./graalnodejs { };

  ruby-installable-svm-java19 = callPackage ./ruby-installable-svm.nix rec {
    javaVersion = "19";
    version = "22.3.1";
    src = fetchurl (source "ruby-installable-svm" javaVersion);
    llvm-installable-svm = llvm-installable-svm-java19;
  };
  graalpy = callPackage ./graalpy { };

  wasm-installable-svm-java19 = callPackage ./wasm-installable-svm.nix rec {
    javaVersion = "19";
    version = "22.3.1";
    src = fetchurl (source "wasm-installable-svm" javaVersion);
  };
  truffleruby = callPackage ./truffleruby { };
}
Loading