about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/compilers/graalvm
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/compilers/graalvm')
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/community-edition.nix142
-rw-r--r--nixpkgs/pkgs/development/compilers/graalvm/enterprise-edition.nix2
2 files changed, 105 insertions, 39 deletions
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/community-edition.nix b/nixpkgs/pkgs/development/compilers/graalvm/community-edition.nix
index 76245a440817..f3a03b364743 100644
--- a/nixpkgs/pkgs/development/compilers/graalvm/community-edition.nix
+++ b/nixpkgs/pkgs/development/compilers/graalvm/community-edition.nix
@@ -1,48 +1,60 @@
-{ lib, stdenv, fetchurl, perl, unzip, glibc, zlib, setJavaClassPath }:
+{ lib, stdenv, fetchurl, perl, unzip, glibc, zlib, setJavaClassPath, Foundation, openssl }:
 
 let
+  platform = if stdenv.isDarwin then "darwin-amd64" else "linux-amd64";
   common = javaVersion:
     let
+      javaVersionPlatform = "${javaVersion}-${platform}";
       graalvmXXX-ce = stdenv.mkDerivation rec {
         pname = "graalvm${javaVersion}-ce";
-        version = "20.2.0";
+        version = "20.3.0";
         srcs = [
           (fetchurl {
-             sha256 = {  "8" = "1s64zkkrns1ykh6dwpjrqy0hs9m1bb08cf7ss7msx33h9ivir5b0";
-                        "11" = "0aaf0sjsnlckhgsh3j4lph0shahw6slf4yndqcm2swc8i1dlpdsx";
-                      }.${javaVersion};
-             url    = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/graalvm-ce-java${javaVersion}-linux-amd64-${version}.tar.gz";
+             sha256 = {  "8-linux-amd64"  = "195b20ivvv8ipjn3qq2313j8qf96ji93pqm99nvn20bq23wasp25";
+                        "11-linux-amd64"  = "1mdk1zhazvvh1fa01bzi5v5fxhvx592xmbakx0y1137vykbayyjm";
+                         "8-darwin-amd64" = "1rrs471204p71knyxpjxymdi8ws98ph2kf5j0knk529g0d24rs01";
+                        "11-darwin-amd64" = "008dl8dbf37mv4wahb9hbd6jp8svvmpy1rgsiqkn3i4hypxnkf12";
+                      }.${javaVersionPlatform};
+             url    = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/graalvm-ce-java${javaVersionPlatform}-${version}.tar.gz";
           })
           (fetchurl {
-             sha256 = {  "8" = "1cisyyzab4pdvzavnivhy9w6dwn36ybaxw40w767m142fbi06m3b";
-                        "11" = "0p4j6mxajmb0xl41c79154pk4vb8bffgg1nmwislahqjky9jkd4j";
-                      }.${javaVersion};
-             url    = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/native-image-installable-svm-java${javaVersion}-linux-amd64-${version}.jar";
+             sha256 = {  "8-linux-amd64"  = "1rzbhllz28x5ps8n304v998hykr4m8z1gfg53ybi6laxhkbx3i13";
+                        "11-linux-amd64"  = "09ipdl1489xnbckwl6sl9y7zy7kp5qf5fgf3kgz5d69jrk2z6rvf";
+                         "8-darwin-amd64" = "1iy2943jbrarh8bm9wy15xk7prnskqwik2ham07a6ybp4j4b81xi";
+                        "11-darwin-amd64" = "0vk2grlirghzc78kvwg66w0xriy5p8qkcp7qx83i62d7sj0kvwnf";
+                      }.${javaVersionPlatform};
+             url    = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/native-image-installable-svm-java${javaVersionPlatform}-${version}.jar";
           })
           (fetchurl {
-             sha256 = {  "8" = "0rwwvk1mkfnl0b50xg7kh6015kjmsw2ra0ckrzmabl88z4bnzh2y";
-                        "11" = "0lc9as2a00j74lp7jby4p10vn5bbkiydzvzk28zfcbsp28p4wvwn";
-                      }.${javaVersion};
-             url    = "https://github.com/oracle/truffleruby/releases/download/vm-${version}/ruby-installable-svm-java${javaVersion}-linux-amd64-${version}.jar";
+             sha256 = {  "8-linux-amd64"  = "0v98v44vblhyi3jhrngmvrkb3a6d607x4fpmrb4mrrsg75vbvc6d";
+                        "11-linux-amd64"  = "0kb9472ilwqg40gyw1c4lmzkd9s763raw560sw80ljm3p75k4sc7";
+                         "8-darwin-amd64" = "192n9ckr4p8qirpxr67ji3wzxpng33yfr7kxynlrcp7b3ghfic6p";
+                        "11-darwin-amd64" = "1wqdk8wphywa00kl3xikiskclb84rx3nw5a4vi5y2n060kclcp22";
+                      }.${javaVersionPlatform};
+             url    = "https://github.com/oracle/truffleruby/releases/download/vm-${version}/ruby-installable-svm-java${javaVersionPlatform}-${version}.jar";
           })
           (fetchurl {
-             sha256 = {  "8" = "0mj8p72qgvvrwpsbk0bsqldynlz1wq07icf951wq5xdbr0whj1gz";
-                        "11" = "1lkszqn4islsza011iabayv6riym0dwnkv83pkmk06b230qjfhzb";
-                      }.${javaVersion};
-             url    = "https://github.com/graalvm/graalpython/releases/download/vm-${version}/python-installable-svm-java${javaVersion}-linux-amd64-${version}.jar";
+             sha256 = {  "8-linux-amd64"  = "1iskmkhrrwlhcq92g1ljvsfi9q403xxkwgzn9m282z5llh2fxv74";
+                        "11-linux-amd64"  = "13bg2gs22rzbngnbw8j68jqgcknbiw30kpxac5jjcn55rf2ymvkz";
+                         "8-darwin-amd64" = "08pib13q7s5wymnbykkyif66ll146vznxw4yz12qwhb419882jc7";
+                        "11-darwin-amd64" = "0cb9lhc21yr2dnrm4kwa68laaczvsdnzpcbl2qix50d0v84xl602";
+                      }.${javaVersionPlatform};
+             url    = "https://github.com/graalvm/graalpython/releases/download/vm-${version}/python-installable-svm-java${javaVersionPlatform}-${version}.jar";
           })
           (fetchurl {
-             sha256 = {  "8" = "1br7camk7y8ych43ws57096100f9kzjvqznh2flmws78ipcrrb66";
-                        "11" = "10swxspjvzh0j82lbpy38dckk69lw1pawqkhnj1hxd05ls36fwq5";
-                      }.${javaVersion};
-             url    = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/wasm-installable-svm-java${javaVersion}-linux-amd64-${version}.jar";
+             sha256 = {  "8-linux-amd64"  = "12lvcl1vmc35wh3xw5dqca7yiijsd432x4lim3knzppipy7fmflq";
+                        "11-linux-amd64"  = "1s8zfgjyyw6w53974h9a2ig8a1bvc97aplyrdziywfrijgp6zkqk";
+                         "8-darwin-amd64" = "06i1n42hkhcf1pfb2bly22ws4a09xgydsgh8b0kvjmb1fapd4paq";
+                        "11-darwin-amd64" = "1r2bqhfxnw09izxlsc562znlp3m9c1isqzhlki083h3vp548vv9s";
+                      }.${javaVersionPlatform};
+             url    = "https://github.com/graalvm/graalvm-ce-builds/releases/download/vm-${version}/wasm-installable-svm-java${javaVersionPlatform}-${version}.jar";
           })
         ];
         nativeBuildInputs = [ unzip perl ];
         unpackPhase = ''
            unpack_jar() {
              jar=$1
-             unzip -o $jar -d $out
+             unzip -q -o $jar -d $out
              perl -ne 'use File::Path qw(make_path);
                        use File::Basename qw(dirname);
                        if (/^(.+) = (.+)$/) {
@@ -60,7 +72,27 @@ let
 
            mkdir -p $out
            arr=($srcs)
-           tar xf ''${arr[0]} -C $out --strip-components=1
+
+           # The tarball on Linux has the following directory structure:
+           #
+           #   graalvm-ce-java11-20.3.0/*
+           #
+           # while on Darwin it looks like this:
+           #
+           #   graalvm-ce-java11-20.3.0/Contents/Home/*
+           #
+           # We therefor use --strip-components=1 vs 3 depending on the platform.
+           tar xf ''${arr[0]} -C $out --strip-components=${if stdenv.isLinux then "1" else "3"}
+
+           # 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
+
            unpack_jar ''${arr[1]}
            unpack_jar ''${arr[2]}
            unpack_jar ''${arr[3]}
@@ -68,7 +100,7 @@ let
         '';
 
         installPhase = {
-          "8" = ''
+          "8-linux-amd64" = ''
             # BUG workaround http://mail.openjdk.java.net/pipermail/graal-dev/2017-December/005141.html
             substituteInPlace $out/jre/lib/security/java.security \
               --replace file:/dev/random    file:/dev/./urandom \
@@ -76,13 +108,13 @@ let
 
             # provide libraries needed for static compilation
             for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do
-              ln -s $f $out/jre/lib/svm/clibraries/linux-amd64/$(basename $f)
+              ln -s $f $out/jre/lib/svm/clibraries/${platform}/$(basename $f)
             done
 
             # allow using external truffle-api.jar and languages not included in the distrubution
             rm $out/jre/lib/jvmci/parentClassLoader.classpath
           '';
-          "11" = ''
+          "11-linux-amd64" = ''
             # BUG workaround http://mail.openjdk.java.net/pipermail/graal-dev/2017-December/005141.html
             substituteInPlace $out/conf/security/java.security \
               --replace file:/dev/random    file:/dev/./urandom \
@@ -90,10 +122,17 @@ let
 
             # provide libraries needed for static compilation
             for f in ${glibc}/lib/* ${glibc.static}/lib/* ${zlib.static}/lib/*; do
-              ln -s $f $out/lib/svm/clibraries/linux-amd64/$(basename $f)
+              ln -s $f $out/lib/svm/clibraries/${platform}/$(basename $f)
             done
-           '';
-        }.${javaVersion};
+          '';
+          "8-darwin-amd64" = ''
+            # allow using external truffle-api.jar and languages not included in the distrubution
+            rm $out/jre/lib/jvmci/parentClassLoader.classpath
+          '';
+          "11-darwin-amd64" = ''
+            echo ""
+          '';
+        }.${javaVersionPlatform};
 
         dontStrip = true;
 
@@ -116,15 +155,22 @@ let
               zlib             # libz.so.1
             ]}"
 
+          ${lib.optionalString stdenv.isLinux ''
           for f in $(find $out -type f -perm -0100); do
             patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" "$f" || true
             patchelf --set-rpath   "$rpath"                                    "$f" || true
-
             if ldd "$f" | fgrep 'not found'; then echo "in file $f"; fi
           done
+          ''}
         '';
 
-        propagatedBuildInputs = [ setJavaClassPath zlib ]; # $out/bin/native-image needs zlib to build native executables
+        # $out/bin/native-image needs zlib to build native executables.
+        propagatedBuildInputs = [ setJavaClassPath zlib ] ++
+          # On Darwin native-image calls clang and it
+          # tries to include <Foundation/Foundation.h>,
+          # and Interactive Ruby (irb) requires OpenSSL
+          # headers.
+          lib.optionals stdenv.hostPlatform.isDarwin [ Foundation openssl ];
 
         doInstallCheck = true;
         installCheckPhase = ''
@@ -141,13 +187,33 @@ let
           $out/bin/java -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:+UseJVMCICompiler HelloWorld | fgrep 'Hello World'
 
           # Ahead-Of-Time compilation
-          $out/bin/native-image --no-server HelloWorld
+          $out/bin/native-image -H:-CheckToolchain -H:+ReportExceptionStackTraces --no-server HelloWorld
           ./helloworld | fgrep 'Hello World'
 
-          # Ahead-Of-Time compilation with --static
-          $out/bin/native-image --no-server --static HelloWorld
-          ./helloworld | fgrep 'Hello World'
-        '';
+          ${lib.optionalString stdenv.isLinux ''
+            # Ahead-Of-Time compilation with --static
+            # --static flag doesn't work for darwin
+            $out/bin/native-image --no-server --static HelloWorld
+            ./helloworld | fgrep 'Hello World'
+          ''}
+
+          echo "Testing interpreted languages"
+          $out/bin/graalpython -c 'print(1 + 1)'
+          $out/bin/ruby -e 'puts(1 + 1)'
+          $out/bin/node -e 'console.log(1 + 1)'
+
+          echo '1 + 1' | $out/bin/graalpython
+
+          # TODO: `irb` on MacOS gives an error saying "Could not find OpenSSL
+          # headers, install via Homebrew or MacPorts or set OPENSSL_PREFIX", even
+          # though `openssl` is in `propagatedBuildInputs`. For more details see:
+          # https://github.com/NixOS/nixpkgs/pull/105815
+          # echo '1 + 1' | $out/bin/irb
+
+          echo '1 + 1' | $out/bin/node -i
+        ${lib.optionalString (javaVersion == "11") ''
+          echo '1 + 1' | $out/bin/jshell
+        ''}'';
 
         passthru.home = graalvmXXX-ce;
 
@@ -156,7 +222,7 @@ let
           description = "High-Performance Polyglot VM";
           license = with licenses; [ upl gpl2Classpath bsd3 ];
           maintainers = with maintainers; [ bandresen volth hlolli glittershark ];
-          platforms = [ "x86_64-linux" ];
+          platforms = [ "x86_64-linux" "x86_64-darwin" ];
         };
       };
     in
diff --git a/nixpkgs/pkgs/development/compilers/graalvm/enterprise-edition.nix b/nixpkgs/pkgs/development/compilers/graalvm/enterprise-edition.nix
index c9c5206f6da3..eb3045d52ad6 100644
--- a/nixpkgs/pkgs/development/compilers/graalvm/enterprise-edition.nix
+++ b/nixpkgs/pkgs/development/compilers/graalvm/enterprise-edition.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, requireFile, perl, unzip, glibc, zlib, bzip2, gdk-pixbuf, xorg, glib, fontconfig, freetype, cairo, pango, gtk3, gtk2, ffmpeg, libGL, atk, alsaLib, libav_0_8, setJavaClassPath }:
+{ lib, stdenv, requireFile, perl, unzip, glibc, zlib, bzip2, gdk-pixbuf, xorg, glib, fontconfig, freetype, cairo, pango, gtk3, gtk2, ffmpeg, libGL, atk, alsaLib, setJavaClassPath }:
 
 let
   common = javaVersion: