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 package does not strip libjvm.so by default to make package size smaller #115486

Closed
vroad opened this issue Mar 9, 2021 · 1 comment · Fixed by #115523
Closed
Assignees
Labels
0.kind: enhancement Add something new

Comments

@vroad
Copy link
Contributor

vroad commented Mar 9, 2021

Describe the bug
jre_minimal package does not strip jlink result file. It should strip libjvm.so by default to save disk space.
If I run strip -p --strip-unneeded ./lib/server/libjvm.so, the size goes down to 17.5MB from 232.6MB.

To Reproduce
Steps to reproduce the behavior:

Create some derivation that uses jre_minimal. jre_minimal will create libjvm.so using jlink, though it doesn't strip the binary at all.

{ jre, stdenv }:
stdenv.mkDerivation {
  # other configs...
  installPhase = ''
    # other scripts...
    wrapProgram "$out/bin/my-app" \
      --set JAVA_HOME "${jre.home}"
  '';
}
let
  sources = import ./sources.nix;
  pkgs = import sources.nixpkgs { };
  jre = pkgs.jre_minimal.override {
    modules = [
      "java.base"
    ];
    jdk = pkgs.jdk11_headless;
  };
  myApp = pkgs.callPackage ./my-app.nix {
    inherit jre;
  };
in
myApp

Expected behavior
jre_minimal strip the binary by default to make libjvm.so smaller.

Additional context
Related GitHub issue: docker-library/openjdk#217
Related NixOS discourse discussion: https://discourse.nixos.org/t/how-to-create-a-docker-image-with-minimal-jdk-11-there-is-no-jre11-headless/11849/8

I don't know how strip works. What's the difference between --strip-unneeded and --strip-debug? Which one is better in this case?

Notify maintainers

@raboof
@roberth

Metadata
Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

 - system: `"x86_64-linux"`
 - host os: `Linux 4.19.121-linuxkit, Alpine Linux, noversion`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.3.10`
 - channels(root): `"nixpkgs-21.05pre273941.a2b0ea6865b"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixpkgs`
@vroad vroad added the 0.kind: bug Something is broken label Mar 9, 2021
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-create-a-docker-image-with-minimal-jdk-11-there-is-no-jre11-headless/11849/10

@raboof raboof self-assigned this Mar 9, 2021
@raboof raboof added 0.kind: enhancement Add something new and removed 0.kind: bug Something is broken labels Mar 9, 2021
raboof added a commit to raboof/nixpkgs that referenced this issue Mar 11, 2021
runCommand doesn't invoke the automatic stripping from stdenv,
expanding the derivation like this does.

Fixes NixOS#115486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: enhancement Add something new
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants