From 981cac8e1076ae68563d2ba872f6c1edb0258bb3 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Sat, 25 Jan 2014 02:29:14 +0100 Subject: [PATCH] openjdk: Hackery to ensure that tools.jar is found HotSpot uses the absolute path of libjvm.so to determine the java.home property (ignoring $JAVA_HOME), which is in turn used by ToolProvider.getSystemJavaCompiler() to load tools.jar. So we need to do some trickery to ensure that if java gets invoked from the jdk output (ratherthan the jre output), it finds libjvm.so in the jdk output. --- .../development/compilers/openjdk/default.nix | 19 ++++++++++++++----- .../compilers/openjdk/fix-java-home.patch | 17 +++++++++++++++++ 2 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 pkgs/development/compilers/openjdk/fix-java-home.patch diff --git a/pkgs/development/compilers/openjdk/default.nix b/pkgs/development/compilers/openjdk/default.nix index 306337fac9c6..50f01f413720 100644 --- a/pkgs/development/compilers/openjdk/default.nix +++ b/pkgs/development/compilers/openjdk/default.nix @@ -1,6 +1,6 @@ { stdenv, fetchurl, unzip, zip, procps, coreutils, alsaLib, ant, freetype, cups -, which, jdk, nettools, libX11, libXt, libXext, libXrender, libXtst, libXi, libXinerama -, libXcursor, fontconfig, cpio, cacert, perl, setJavaClassPath }: +, which, jdk, nettools, xorg +, fontconfig, cpio, cacert, perl, setJavaClassPath }: let @@ -33,7 +33,8 @@ stdenv.mkDerivation rec { buildInputs = [ unzip procps ant which zip cpio nettools alsaLib - libX11 libXt libXext libXrender libXtst libXi libXinerama libXcursor + xorg.libX11 xorg.libXt xorg.libXext xorg.libXrender xorg.libXtst + xorg.libXi xorg.libXinerama xorg.libXcursor xorg.lndir fontconfig perl ]; @@ -48,7 +49,7 @@ stdenv.mkDerivation rec { openjdk/{jdk,corba}/make/common/shared/Defs-utils.gmk ''; - patches = [ ./cppflags-include-fix.patch ]; + patches = [ ./cppflags-include-fix.patch ./fix-java-home.patch ]; NIX_NO_SELF_RPATH = true; @@ -80,6 +81,9 @@ stdenv.mkDerivation rec { mv $out/lib/openjdk/include $out/include mv $out/lib/openjdk/man $out/share/man + # jni.h expects jni_md.h to be in the header search path. + ln -s $out/include/linux/*_md.h $out/include/ + # Remove some broken manpages. rm -rf $out/share/man/ja* @@ -88,10 +92,15 @@ stdenv.mkDerivation rec { # Move the JRE to a separate output. mv $out/lib/openjdk/jre $jre/lib/openjdk/ - ln -s $jre/lib/openjdk/jre $out/lib/openjdk/jre + mkdir $out/lib/openjdk/jre + lndir $jre/lib/openjdk/jre $out/lib/openjdk/jre + + rm -rf $out/lib/openjdk/jre/bin + ln -s $out/lib/openjdk/bin $out/lib/openjdk/jre/bin # Remove duplicate binaries. for i in $(cd $out/lib/openjdk/bin && echo *); do + if [ "$i" = java ]; then continue; fi if cmp -s $out/lib/openjdk/bin/$i $jre/lib/openjdk/jre/bin/$i; then ln -sfn $jre/lib/openjdk/jre/bin/$i $out/lib/openjdk/bin/$i fi diff --git a/pkgs/development/compilers/openjdk/fix-java-home.patch b/pkgs/development/compilers/openjdk/fix-java-home.patch new file mode 100644 index 000000000000..5def344f1717 --- /dev/null +++ b/pkgs/development/compilers/openjdk/fix-java-home.patch @@ -0,0 +1,17 @@ +diff -ru -x '*~' openjdk-orig/hotspot/src/os/linux/vm/os_linux.cpp openjdk/hotspot/src/os/linux/vm/os_linux.cpp +--- openjdk-orig/hotspot/src/os/linux/vm/os_linux.cpp 2013-09-06 20:22:03.000000000 +0200 ++++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp 2014-01-24 22:44:08.223857012 +0100 +@@ -2358,12 +2358,10 @@ + CAST_FROM_FN_PTR(address, os::jvm_path), + dli_fname, sizeof(dli_fname), NULL); + assert(ret, "cannot locate libjvm"); + char *rp = NULL; + if (ret && dli_fname[0] != '\0') { +- rp = realpath(dli_fname, buf); ++ snprintf(buf, buflen, "%s", dli_fname); + } +- if (rp == NULL) +- return; + + if (Arguments::created_by_gamma_launcher()) { + // Support for the gamma launcher. Typical value for buf is