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

SWT reproducibility #59999

Merged
merged 5 commits into from Oct 27, 2021
Merged

SWT reproducibility #59999

merged 5 commits into from Oct 27, 2021

Conversation

bb010g
Copy link
Member

@bb010g bb010g commented Apr 22, 2019

Motivation for this change

More reproducibility! And less likelihood of breakage moving forward into new versions. Also, the build-support/setup-hooks/canonicalize-jars-hook hook added to support this was pulled from the unused build-support/release/ant-build (& functions only used there sourced from build-support/release/functions.sh), which has been deleted due to being weird and old and not imported by any package built on Hydra in the last 3+ years.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
    • Tested with applications/editor/music/tuxguitar & applications/networking/ipscan (in my NUR repo; planning to submit to Nixpkgs after this merges since it requires upgraded SWT).
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
    • Decrease from 648420920 to 648403736
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@bb010g
Copy link
Member Author

bb010g commented Apr 27, 2019

@edolstra may also want to review this, as I think the build-support/release stuff was mostly him?

Copy link
Member

@rycee rycee left a comment

Choose a reason for hiding this comment

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

I think this is very nice! Having the ability to easily canonicalize Jar files is very convenient!

pkgs/build-support/java/canonicalize-jar.nix Outdated Show resolved Hide resolved
pkgs/build-support/java/canonicalize-jar.sh Outdated Show resolved Hide resolved
pkgs/build-support/java/canonicalize-jar.sh Outdated Show resolved Hide resolved
pkgs/build-support/java/canonicalize-jar.sh Show resolved Hide resolved
pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
@bb010g bb010g force-pushed the swt-reproducibility branch 2 times, most recently from 8a9a17c to f8f3d03 Compare October 7, 2019 00:43
@bb010g
Copy link
Member Author

bb010g commented Oct 7, 2019

Ok, rebased and ready for review.

@doronbehar doronbehar mentioned this pull request Dec 13, 2019
10 tasks
@doronbehar
Copy link
Contributor

Please fix the merge conflicts.

@bb010g
Copy link
Member Author

bb010g commented Feb 25, 2020

Rebased.

@stale
Copy link

stale bot commented Aug 23, 2020

Hello, I'm a bot and I thank you in the name of the community for your contributions.

Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do:

If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list.

If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past.

If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments.

Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 23, 2020
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 3, 2020
@bb010g
Copy link
Member Author

bb010g commented Jan 16, 2021

Rebased.

@bb010g
Copy link
Member Author

bb010g commented Jun 2, 2021

Rebased. Reminder that this is blocking SWT upgrades.

pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
pkgs/build-support/setup-hooks/canonicalize-jars.sh Outdated Show resolved Hide resolved
pkgs/build-support/java/canonicalize-jar.sh Outdated Show resolved Hide resolved
@fzakaria
Copy link
Contributor

I recently wrote https://fzakaria.com/2021/06/27/java-nix-reproducibility.html
Curious about the delta between the hook and other canonicalization vs. just adding strip-nondeterminism to the fixupPhase?

@fzakaria
Copy link
Contributor

Can the PR description's motivation be augmented to describe the problem and the fixes?
I'm aware of the mtime fixes but not the other canonicalizations that are needed.

Doing it in a hook vs the fixupPhase is also of interest (see earlier comment)

@bb010g
Copy link
Member Author

bb010g commented Sep 21, 2021

Rebased, and @pSub removed as maintainer due to a lack of activity with this PR over the last 2 years.

@fzakaria It looks like META-INF/MANIFEST.MF is sorted & empty lines removed? It's been a while since I submitted this patch; that behavior was carried over from the original canonicalizeJarManifest function. Further documentation or fixes are welcome; I know that this PR works and just want it to finally get merged so I can use ipscan from upstream Nixpkgs.

Doing it in a hook vs the fixupPhase is also of interest

canonicalizeJarsIn is called in fixupOutputHooks, which are ran directly after runHook preFixup in the default fixupPhase.

Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

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

I'd also squash the last two commits into 1.

pkgs/top-level/all-packages.nix Show resolved Hide resolved
pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
sed -i 's/ \+$//' ./*.mak
'';

postPatch = let makefile-sed = builtins.toFile "swt-makefile.sed" (''
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered applying a patch and suggesting it upstream?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I figured upstream submissions could be figured out after our SWT was up-to-date first. I don't think 4.5 is still maintained. My original idea was to upgrade SWT after this was merged first, to keep each PR easier to follow.

Copy link
Contributor

Choose a reason for hiding this comment

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

I tried to update SWT once..

#75609

Copy link
Member

Choose a reason for hiding this comment

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

Do you still plan to update SWT now that this PR has been merged? @bb010g

I'm trying to fix ipscan, which fails to start up, with:

***WARNING: GTK+ version too new (major mismatch)
***WARNING: SWT requires GTK 2.18.0
***WARNING: Detected: 2.24.33

And then a JVM segfault:

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007fe4605448bc, pid=2188, tid=2189
#
# JRE version: OpenJDK Runtime Environment (17.0.1+12) (build 17.0.1+12-nixos)
# Java VM: OpenJDK 64-Bit Server VM (17.0.1+12-nixos, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libX11.so.6+0x308bc]  XInternAtom+0x3c

Hoping an updated SWT will fix this...

Copy link
Contributor

@doronbehar doronbehar left a comment

Choose a reason for hiding this comment

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

I noticed some dependencies can be cleaned and added:

diff --git i/pkgs/development/libraries/java/swt/default.nix w/pkgs/development/libraries/java/swt/default.nix
index 348af9d255d..f965a1dc3c5 100644
--- i/pkgs/development/libraries/java/swt/default.nix
+++ w/pkgs/development/libraries/java/swt/default.nix
@@ -1,6 +1,15 @@
-{ lib, stdenv, fetchzip, pkgsBuildHost
-, atk, glib, gtk2, jdk, libGL, libGLU, libXi, libXt, libXtst, libsoup
-, webkitgtk, xorg
+{ lib
+, stdenv
+, fetchzip
+, pkgsBuildHost
+, atk
+, glib
+, gtk2
+, jdk
+, libGL
+, libGLU
+, libXtst
+, gnome2
 }:
 
 let
@@ -56,11 +65,10 @@ in stdenv.mkDerivation rec {
     jdk
     libGL
     libGLU
-    libXi
-    libXt
     libXtst
-    libsoup
-    webkitgtk
+    gnome2.gnome_vfs
+    gnome2.libgnomeui
+    gnome2.libgnome
   ];
 
   patches = [ ./awt-libs.patch ./gtk-libs.patch ];

pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
pkgs/development/libraries/java/swt/default.nix Outdated Show resolved Hide resolved
@doronbehar
Copy link
Contributor

ping @bb010g .

bb010g and others added 5 commits October 27, 2021 13:21
A build hook to run functions previously only implemented privately in
`pkgs/build-support/release/functions.sh`.
The sole consumer in Nixpkgs of `releaseTools.antBuild` is
`pkgs/development/libraries/junit`, which has been broken since
2015-09-08. The sole consumer in Nixpkgs of `junit` is
`pkgs/development/libraries/junixsocket`, which hasn't built due to
`junit` since 2015-09-08. All three are removed due to their obvious
lack of use.

All other packages in Nixpkgs depending on junit consume
`pkgs/development/java-modules/junit`, which is not broken.

Any downstreams that have kept using these `junit` or `junixsocket`
packages since 2015-09-08 have basically already vendored the packages
via patching them, so no aliases are provided.
Cleaner nested unpacking, as well as general robustness improvements.
Turns out the LFLAGS stuff was from upstream not trusting pkg-config on
their boxes, but it works great for us. (Or rather, it works great after
fixing some of their pkg-config invocations.)

Assisted by the diffoscope ( https://diffoscope.org/ ) and readelf
grepping based on its output.
@doronbehar
Copy link
Contributor

Apparently swt_jdk8 does need libXt. I added that dependency conditionally, and marked areca as broken` since it won't launch a GUI.

@doronbehar doronbehar merged commit 51acb65 into NixOS:master Oct 27, 2021
@bb010g bb010g deleted the swt-reproducibility branch November 9, 2021 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants