Skip to content

patch Java binaries/libraries when using alternate sysroot to ensure correct glibc & co are picked up + add custom sanity check#2557

Merged
ocaisa merged 5 commits intoeasybuilders:developfrom
boegel:java_patchelf
Sep 5, 2023
Merged

patch Java binaries/libraries when using alternate sysroot to ensure correct glibc & co are picked up + add custom sanity check#2557
ocaisa merged 5 commits intoeasybuilders:developfrom
boegel:java_patchelf

Conversation

@boegel
Copy link
Copy Markdown
Member

@boegel boegel commented Aug 24, 2021

Enhancement for custom easyblock for Java to fix problems that occur when using Java in the context of an alternate sysroot and using RPATH (see EESSI/software-layer#123)

Also adds basic custom sanity check for Java, including running java -help and javac -help, which work for Java 1.7.x, 1.8.x, 11.x, 13.x

This is a draft PR because this should be cleaned up a bit, by adding support in EasyBuild framework for leveraging patchelf, so it's a lot cleaner to patch a binary installation like this (we may also need this for other stuff, like CUDA, Intel tools, etc.)

…correct glibc & co are picked up + add basic custom sanity check for Java
@boegel
Copy link
Copy Markdown
Member Author

boegel commented Aug 24, 2021

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS Java-11.0.8-aarch64.eb
  • SUCCESS Java-1.8_265-b01-OpenJDK-aarch64.eb
  • SUCCESS Java-11.eb
  • SUCCESS Java-1.8.eb

Build succeeded for 4 out of 4 (2 easyconfigs in total)
select-pika-c6gd-2xlarge-0001 - Linux centos linux 8.3.2011, AArch64, ARM UNKNOWN (graviton2), Python 3.6.8
See https://gist.github.com/1edb00fae023ea8c1b16cb9531945a89 for a full test report.

edit: no --sysroot or --rpath used, just verifying the custom sanity check on aarch64

@boegel
Copy link
Copy Markdown
Member Author

boegel commented Aug 24, 2021

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS Java-1.6.0_24.eb
  • SUCCESS Java-1.7.0_10.eb
  • SUCCESS Java-1.7.0_15.eb
  • SUCCESS Java-1.7.0_21.eb
  • SUCCESS Java-1.7.0_40.eb
  • SUCCESS Java-1.7.0_45.eb
  • SUCCESS Java-1.7.0_60.eb
  • SUCCESS Java-1.7.0_75.eb
  • SUCCESS Java-1.7.0_76.eb
  • SUCCESS Java-1.7.0_79.eb
  • SUCCESS Java-1.7.0_80.eb
  • SUCCESS Java-1.8.0_112.eb
  • SUCCESS Java-1.8.0_121.eb
  • SUCCESS Java-1.8.0_131.eb
  • SUCCESS Java-1.8.0_141.eb
  • SUCCESS Java-1.8.0_144.eb
  • SUCCESS Java-1.8.0_152.eb
  • SUCCESS Java-1.8.0_162.eb
  • SUCCESS Java-1.8.0_172.eb
  • SUCCESS Java-1.8.0_181.eb
  • SUCCESS Java-1.8.0_192.eb
  • SUCCESS Java-1.8.0_20.eb
  • SUCCESS Java-1.8.0_202.eb
  • SUCCESS Java-1.8.0_212.eb
  • SUCCESS Java-1.8.0_221.eb
  • SUCCESS Java-1.8.0_231.eb
  • SUCCESS Java-1.8.0_241.eb
  • SUCCESS Java-1.8.0_25.eb
  • SUCCESS Java-1.8.0_271.eb
  • SUCCESS Java-1.8.0_281.eb
  • SUCCESS Java-1.8.0_31.eb
  • SUCCESS Java-1.8.0_40.eb
  • SUCCESS Java-1.8.0_45.eb
  • SUCCESS Java-1.8.0_60.eb
  • SUCCESS Java-1.8.0_65.eb
  • SUCCESS Java-1.8.0_66.eb
  • SUCCESS Java-1.8.0_72.eb
  • SUCCESS Java-1.8.0_74.eb
  • SUCCESS Java-1.8.0_77.eb
  • SUCCESS Java-1.8.0_92.eb
  • SUCCESS Java-1.8.eb
  • SUCCESS Java-1.9.0.4.eb
  • SUCCESS Java-11.0.2.eb
  • SUCCESS Java-11.eb
  • SUCCESS Java-13.0.2.eb
  • SUCCESS Java-13.eb
  • SUCCESS Java-16.0.1.eb
  • SUCCESS Java-16.eb

Build succeeded for 48 out of 48 (48 easyconfigs in total)
node2639.swalot.os - Linux centos linux 7.9.2009, x86_64, Intel(R) Xeon(R) CPU E5-2660 v3 @ 2.60GHz (haswell), Python 3.6.8
See https://gist.github.com/446147fb667daab212342adbd426ace4 for a full test report.

edit: no --sysroot or --rpath used, just verifying the custom sanity check on x86_64

@boegel boegel changed the title patch Java binaries/libraries when using alternate sysroot to ensure correct glibc & co are picked up (WIP) patch Java binaries/libraries when using alternate sysroot to ensure correct glibc & co are picked up + add custom sanity check (WIP) Aug 24, 2021
@boegel
Copy link
Copy Markdown
Member Author

boegel commented Aug 25, 2021

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS Java-11.0.6-ppc64le.eb
  • SUCCESS Java-1.8_191-b26-OpenJDK.eb
  • SUCCESS Java-11.eb
  • SUCCESS Java-1.8.eb

Build succeeded for 4 out of 4 (2 easyconfigs in total)
easybuild2.novalocal - Linux centos linux 8.3.2011, POWER, IBM pSeries (emulated by qemu) (power9le), Python 3.6.8
See https://gist.github.com/9a45cdbbe706e6ce41ec32000a15de59 for a full test report.

edit: no --sysroot or --rpath used, just verifying the custom sanity check on ppc64le

Copy link
Copy Markdown
Member

@ocaisa ocaisa left a comment

Choose a reason for hiding this comment

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

With a few changes the post install step could be made completely independent of the package and placed in framework instead.

Comment thread easybuild/easyblocks/j/java.py Outdated
if elf_interp is None:
raise EasyBuildError("Failed to isolate ELF interpreter!")

bindir = os.path.join(self.installdir, 'bin')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Everything up until now has been independent of the actual package being installed. Rather than an explicit bin, can we just check all the dirs that are being added to PATH?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we "guaranteed" to have the additions to PATH finalised by this point?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not really, since make_module_req_guess and make_module_extra are generally responsible for specifying what gets included in $PATH (and $LD_LIBRARY_PATH).

The way that's done currently is by emitting Tcl or Lua statements to update these environment variables directly, we would need to do some extra bookkeeping to know what's being added to $PATH and/or $LD_LIBRARY_PATH in a clean way in post_install_step already...

Copy link
Copy Markdown
Member

@ocaisa ocaisa Sep 4, 2023

Choose a reason for hiding this comment

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

make_module_req_guess just returns a dict which contains the guess for PATH and LIBRARY_PATH, so we can just call it? We also know that make_module_extra doesn't handle PATH or LIBRARY_PATH, unless there is a reason for an exception somewhere

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

(I'm explicitly saying LIBRARY_PATH as we filter LD_LIBRARY_PATH in EESSI)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

PR to do this at boegel#41

Comment thread easybuild/easyblocks/j/java.py Outdated
curr_rpath, _ = run_cmd("patchelf --print-rpath %s" % path, simple=False, trace=False)
self.log.debug("RPATH for %s (after shrinking): %s" % (path, curr_rpath))

libdir = os.path.join(self.installdir, 'lib')
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here, can we just check all the paths that are being added to LIBRARY_PATH

@boegel boegel changed the title patch Java binaries/libraries when using alternate sysroot to ensure correct glibc & co are picked up + add custom sanity check (WIP) patch Java binaries/libraries when using alternate sysroot to ensure correct glibc & co are picked up + add custom sanity check Sep 4, 2023
@boegel boegel marked this pull request as ready for review September 4, 2023 15:49
@boegel
Copy link
Copy Markdown
Member Author

boegel commented Sep 4, 2023

@ocaisa I'm fine with leveraging some of the code being added here to framework, but I feel we can still do that later, maybe only once we have a second use case for using patchelf like we do here.

I would really like to see this PR merged as is, since it has been used to install Java in EESSI for a while now.
Once similar functionality is supported in framework, we can update the Java accordingly to use that rather than implement it's own approach?

@ocaisa
Copy link
Copy Markdown
Member

ocaisa commented Sep 4, 2023

Sure we can move it to framework later, but I think it is already good practice to leverage the additions to PATH and LIBRARY_PATH when we decide what we are going to run patchelf on (rather than work off of bin and lib assumptions).

EDIT:
PR for this in boegel#41

@boegel
Copy link
Copy Markdown
Member Author

boegel commented Sep 5, 2023

Retested in EESSI pilot 2021.12, still works like a charm.

@boegel
Copy link
Copy Markdown
Member Author

boegel commented Sep 5, 2023

Test report by @boegel

Overview of tested easyconfigs (in order)

  • SUCCESS Java-1.8.0_311.eb
  • SUCCESS Java-1.8.eb
  • SUCCESS Java-8.362.eb
  • SUCCESS Java-8.eb
  • SUCCESS Java-11.0.20.eb
  • SUCCESS Java-11.eb
  • SUCCESS Java-15.0.1.eb
  • SUCCESS Java-17.0.6.eb

Build succeeded for 8 out of 8 (8 easyconfigs in total)
node3116.skitty.os - Linux RHEL 8.6, x86_64, Intel(R) Xeon(R) Gold 6140 CPU @ 2.30GHz (skylake_avx512), Python 3.6.8
See https://gist.github.com/boegel/363f693d378f247bee9607ffd4bd1b14 for a full test report.

@ocaisa ocaisa enabled auto-merge September 5, 2023 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix EESSI Related to EESSI project enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants