Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jre_minimal: strip libraries #115523

Merged
merged 1 commit into from Apr 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 24 additions & 9 deletions pkgs/development/compilers/openjdk/jre.nix
@@ -1,19 +1,34 @@
{ jdk
, runCommand
, patchelf
{ stdenv
, jdk
, lib
, modules ? [ "java.base" ]
}:

let
jre = runCommand "${jdk.name}-jre" {
nativeBuildInputs = [ patchelf ];
jre = stdenv.mkDerivation {
name = "${jdk.name}-minimal-jre";
version = jdk.version;

buildInputs = [ jdk ];

dontUnpack = true;

# Strip more heavily than the default '-S', since if you're
# using this derivation you probably care about this.
stripDebugFlags = [ "--strip-unneeded" ];

buildPhase = ''
runHook preBuild

jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out

runHook postBuild
'';

dontInstall = true;

passthru = {
home = "${jre}";
};
} ''
jlink --module-path ${jdk}/lib/openjdk/jmods --add-modules ${lib.concatStringsSep "," modules} --output $out
patchelf --shrink-rpath $out/bin/* $out/lib/jexec $out/lib/jspawnhelper $out/lib/*.so $out/lib/*/*.so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose --shrink-rpath has become redundant?
It would be nice to have a test in passthru. Perhaps just a small package that uses this jre in its tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose --shrink-rpath has become redundant?

Yes - I tried patchelf --shrink-rpath on the resulting binaries and it doesn't produce any change anymore

It would be nice to have a test in passthru. Perhaps just a small package that uses this jre in its tests.

I agree that would be nice, though I'd rather not grow this PR with it..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I respect that.

'';
};
in jre