Skip to content

Commit

Permalink
perform 2 step build to generate static jdk libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
hlolli committed Apr 27, 2020
1 parent ec862c9 commit 194eb09
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions pkgs/development/compilers/openjdk/8.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, cups, freetype, alsaLib, cacert, perl, liberation_ttf, fontconfig, zlib, glibc
, libX11, libICE, libXrender, libXext, libXt, libXtst, libXi, libXinerama, libXcursor, libXrandr
, xorgproto, libxcb, xtrans, libpthreadstubs, libXau, xcbproto, libXdmcp, xcbutilkeysyms
, autoconf, libpng, libjpeg, giflib
, autoconf, libpng, libjpeg, giflib, bzip2
, openjdk8-bootstrap
, setJavaClassPath
, headless ? false
Expand Down Expand Up @@ -120,10 +120,10 @@ let
"--disable-shared"
];
});
# bzip2-static = bzip2.override { linkStatic = true;};
bzip2-static = bzip2.override { linkStatic = true;};


openjdk8 = stdenv.mkDerivation {
openjdk8 = stdenv.mkDerivation rec {
pname = "openjdk" + lib.optionalString headless "-headless";
version = "8u${update}-${build}";

Expand All @@ -142,7 +142,7 @@ let
gtk2 gnome_vfs GConf glib
] ++ lib.optionals (static) [
autoconf
# bzip2-static
bzip2-static
freetype-static
glibc
glibc.static
Expand Down Expand Up @@ -204,11 +204,7 @@ let
"--disable-freetype-bundling"
"--with-zlib=system"
"--with-giflib=system"
] ++ lib.optionals static [
"--enable-static-build=yes"
"--verbose"
"--host=${stdenv.hostPlatform.system}"
];
];

separateDebugInfo = true;

Expand All @@ -225,10 +221,24 @@ let
"-Wno-error"
]);

buildFlags = if (static) then [ "images" ] else [ "all" ];
buildFlags = [ "all" ];

doCheck = false; # fails with "No rule to make target 'y'."

# static build here means to include static-jdk-libs
# this will require two stage build
# https://github.com/oracle/graal/issues/1755#issuecomment-542590772
buildPhase = lib.optionalString static ''
# Stage1: build statically to generate static-libs
./configure ${toString (configureFlags ++ [ "--enable-static-build=yes" ])}
make images
mv build STAGE_1
# Stage2: compile normally
./configure ${toString (configureFlags ++ [ "--enable-static-build=no" ])}
make images
'';

installPhase = ''
mkdir -p $out/lib
Expand Down Expand Up @@ -288,6 +298,8 @@ let
ln -s $out/lib/openjdk/bin $out/bin
ln -s $jre/lib/openjdk/jre/bin $jre/bin
ln -s $jre/lib/openjdk/jre $out/jre
${lib.optionalString static "cp ./STAGE_1/*/jdk/lib/*.a $out/lib"}
'';

propagatedBuildInputs = [ setJavaClassPath ];
Expand Down

0 comments on commit 194eb09

Please sign in to comment.