summary refs log tree commit diff
path: root/pkgs/development/compilers/openjdk/bootstrap.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/openjdk/bootstrap.nix')
-rw-r--r--pkgs/development/compilers/openjdk/bootstrap.nix29
1 files changed, 14 insertions, 15 deletions
diff --git a/pkgs/development/compilers/openjdk/bootstrap.nix b/pkgs/development/compilers/openjdk/bootstrap.nix
index 48a22638813..668ca552adf 100644
--- a/pkgs/development/compilers/openjdk/bootstrap.nix
+++ b/pkgs/development/compilers/openjdk/bootstrap.nix
@@ -1,11 +1,14 @@
-{ stdenv, runCommand, glibc, fetchurl, file
+{ stdenv
+, runCommand, fetchurl, file
 
 , version
 }:
 
+assert stdenv.hostPlatform.libc == "glibc";
+
 let
   # !!! These should be on nixos.org
-  src = if glibc.system == "x86_64-linux" then
+  src = if stdenv.hostPlatform.system == "x86_64-linux" then
     (if version == "8" then
       fetchurl {
         url = "https://www.dropbox.com/s/a0lsq2ig4uguky5/openjdk8-bootstrap-x86_64-linux.tar.xz?dl=1";
@@ -17,7 +20,7 @@ let
         sha256 = "024gg2sgg4labxbc1nhn8lxls2p7d9h3b82hnsahwaja2pm1hbra";
       }
     else throw "No bootstrap for version")
-  else if glibc.system == "i686-linux" then
+  else if stdenv.hostPlatform.system == "i686-linux" then
     (if version == "8" then
       fetchurl {
         url = "https://www.dropbox.com/s/rneqjhlerijsw74/openjdk8-bootstrap-i686-linux.tar.xz?dl=1";
@@ -39,22 +42,18 @@ let
 
     LIBDIRS="$(find $out -name \*.so\* -exec dirname {} \; | sort | uniq | tr '\n' ':')"
 
-    for i in $out/bin/*; do
-      patchelf --set-interpreter ${glibc.out}/lib/ld-linux*.so.2 $i || true
-      patchelf --set-rpath "${glibc.out}/lib:$LIBDIRS" $i || true
-    done
-
-    find $out -name \*.so\* | while read lib; do
-      patchelf --set-interpreter ${glibc.out}/lib/ld-linux*.so.2 $lib || true
-      patchelf --set-rpath "${glibc.out}/lib:${stdenv.cc.cc.lib}/lib:$LIBDIRS" $lib || true
+    find "$out" -type f -print0 | while IFS= read -r -d "" elf; do
+      isELF "$elf" || continue
+      patchelf --set-interpreter $(cat "${stdenv.cc}/nix-support/dynamic-linker") "$elf" || true
+      patchelf --set-rpath "${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib:$LIBDIRS" "$elf" || true
     done
 
     # Temporarily, while NixOS's OpenJDK bootstrap tarball doesn't have PaX markings:
-    exes=$(${file}/bin/file $out/bin/* 2> /dev/null | grep -E 'ELF.*(executable|shared object)' | sed -e 's/: .*$//')
-    for file in $exes; do
-      paxmark m "$file"
+    find "$out/bin" -type f -print0 | while IFS= read -r -d "" elf; do
+      isELF "$elf" || continue
+      paxmark m "$elf"
       # On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well.
-      ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$file"''}
+      ${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$elf"''}
     done
   '';
 in bootstrap