2018-02-20 22:44:40 +00:00
|
|
|
{ stdenv
|
2018-07-21 00:44:44 +00:00
|
|
|
, runCommand, fetchurl, zlib
|
2015-06-08 04:01:17 +00:00
|
|
|
|
|
|
|
, version
|
|
|
|
}:
|
2012-08-25 02:29:23 +00:00
|
|
|
|
2018-02-20 22:44:40 +00:00
|
|
|
assert stdenv.hostPlatform.libc == "glibc";
|
|
|
|
|
2012-08-25 02:29:23 +00:00
|
|
|
let
|
2018-04-01 06:00:55 +00:00
|
|
|
fetchboot = version: arch: sha256: fetchurl {
|
|
|
|
name = "openjdk${version}-bootstrap-${arch}-linux.tar.xz";
|
|
|
|
url = "http://tarballs.nixos.org/openjdk/2018-03-31/${version}/${arch}-linux.tar.xz";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2018-02-20 22:44:40 +00:00
|
|
|
src = if stdenv.hostPlatform.system == "x86_64-linux" then
|
2018-04-01 06:00:55 +00:00
|
|
|
(if version == "10" then fetchboot "10" "x86_64" "08085fsxc1qhqiv3yi38w8lrg3vm7s0m2yvnwr1c92v019806yq2"
|
|
|
|
else if version == "8" then fetchboot "8" "x86_64" "18zqx6jhm3lizn9hh6ryyqc9dz3i96pwaz8f6nxfllk70qi5gvks"
|
2018-10-14 16:47:04 +00:00
|
|
|
else throw "No bootstrap jdk for version ${version}")
|
2018-02-20 22:44:40 +00:00
|
|
|
else if stdenv.hostPlatform.system == "i686-linux" then
|
2018-04-01 06:00:55 +00:00
|
|
|
(if version == "10" then fetchboot "10" "i686" "1blb9gyzp8gfyggxvggqgpcgfcyi00ndnnskipwgdm031qva94p7"
|
|
|
|
else if version == "8" then fetchboot "8" "i686" "1yx04xh8bqz7amg12d13rw5vwa008rav59mxjw1b9s6ynkvfgqq9"
|
2015-06-08 04:01:17 +00:00
|
|
|
else throw "No bootstrap for version")
|
2018-10-14 16:47:04 +00:00
|
|
|
else throw "No bootstrap jdk for system ${stdenv.hostPlatform.system}";
|
2012-08-25 02:29:23 +00:00
|
|
|
|
2015-06-06 23:14:43 +00:00
|
|
|
bootstrap = runCommand "openjdk-bootstrap" {
|
|
|
|
passthru.home = "${bootstrap}/lib/openjdk";
|
|
|
|
} ''
|
|
|
|
tar xvf ${src}
|
|
|
|
mv openjdk-bootstrap $out
|
2014-02-19 17:45:58 +00:00
|
|
|
|
2015-06-08 04:01:17 +00:00
|
|
|
LIBDIRS="$(find $out -name \*.so\* -exec dirname {} \; | sort | uniq | tr '\n' ':')"
|
|
|
|
|
2018-02-20 22:44:40 +00:00
|
|
|
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
|
2018-03-29 22:43:42 +00:00
|
|
|
patchelf --set-rpath "${stdenv.cc.libc}/lib:${stdenv.cc.cc.lib}/lib:${zlib}/lib:$LIBDIRS" "$elf" || true
|
2015-06-06 23:14:43 +00:00
|
|
|
done
|
2015-01-19 22:24:47 +00:00
|
|
|
|
2015-06-06 23:14:43 +00:00
|
|
|
# Temporarily, while NixOS's OpenJDK bootstrap tarball doesn't have PaX markings:
|
2018-02-20 22:44:40 +00:00
|
|
|
find "$out/bin" -type f -print0 | while IFS= read -r -d "" elf; do
|
|
|
|
isELF "$elf" || continue
|
|
|
|
paxmark m "$elf"
|
2015-06-06 23:14:43 +00:00
|
|
|
# On x86 for heap sizes over 700MB disable SEGMEXEC and PAGEEXEC as well.
|
2018-02-20 22:44:40 +00:00
|
|
|
${stdenv.lib.optionalString stdenv.isi686 ''paxmark msp "$elf"''}
|
2015-06-06 23:14:43 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
in bootstrap
|