diff --git a/easybuild/easyconfigs/r/Rust/Rust-1.70.0-GCCcore-12.3.0.eb b/easybuild/easyconfigs/r/Rust/Rust-1.70.0-GCCcore-12.3.0.eb new file mode 100644 index 00000000000..2d73f5a4efa --- /dev/null +++ b/easybuild/easyconfigs/r/Rust/Rust-1.70.0-GCCcore-12.3.0.eb @@ -0,0 +1,55 @@ +easyblock = 'ConfigureMake' + +name = 'Rust' +version = '1.70.0' + +homepage = 'https://www.rust-lang.org' +description = """Rust is a systems programming language that runs blazingly fast, prevents segfaults, + and guarantees thread safety.""" + +toolchain = {'name': 'GCCcore', 'version': '12.3.0'} + +source_urls = ['https://static.rust-lang.org/dist/'] +sources = ['rustc-%(version)s-src.tar.gz'] +patches = ['Rust-1.70_sysroot-fix-interpreter.patch'] +checksums = [ + {'rustc-1.70.0-src.tar.gz': 'b2bfae000b7a5040e4ec4bbc50a09f21548190cb7570b0ed77358368413bd27c'}, + {'Rust-1.70_sysroot-fix-interpreter.patch': '220129db55e022a98d25028da5dcc9f26b252dd995c3ac92f6312dbb1e362cb1'}, +] + +builddependencies = [ + ('binutils', '2.40'), + ('CMake', '3.26.3'), + ('Python', '3.11.3'), + ('Ninja', '1.11.1'), + ('pkgconf', '1.9.5'), +] + +dependencies = [ + ('OpenSSL', '1.1', '', SYSTEM), +] + +configopts = "--enable-extended --sysconfdir=%(installdir)s/etc " + +# Use ./x.py to bootstrap so that options like -j N are correctly passed through +# see: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html#what-is-xpy +# (ConfigureMake already adds `-j %(parallel)s` to the `build_cmd`) +build_cmd = "./x.py build" +install_cmd = "./x.py install -j %(parallel)s" + +# avoid failure when home directory is an NFS mount, +# see https://github.com/rust-lang/cargo/issues/6652 +prebuildopts = "export CARGO_HOME=%(builddir)s/cargo && " +preinstallopts = prebuildopts + +sanity_check_paths = { + 'files': ['bin/cargo', 'bin/rustc', 'bin/rustdoc'], + 'dirs': ['lib/rustlib', 'share/doc', 'share/man'], +} + +sanity_check_commands = [ + "cargo --version", + "rustc --version", +] + +moduleclass = 'lang' diff --git a/easybuild/easyconfigs/r/Rust/Rust-1.70_sysroot-fix-interpreter.patch b/easybuild/easyconfigs/r/Rust/Rust-1.70_sysroot-fix-interpreter.patch new file mode 100644 index 00000000000..a5e3d50eb2b --- /dev/null +++ b/easybuild/easyconfigs/r/Rust/Rust-1.70_sysroot-fix-interpreter.patch @@ -0,0 +1,44 @@ +Use patchelf to fix interpreter of binaries that are used during Rust bootstrap procedure +when EasyBuild is configured to build in an alternate sysroot + +This fixes problems like due to a clash with the interpreter from the host, and a more recent libc.so.6 that's picked up +from the alternate sysroot: +error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /tmp/easybuild/build/Rust/1.52.1/GCCcore-10.3.0/rustc-1.52.1-src/build/bootstrap/debug/deps/libproc_macro_error_attr-fbfef320d848b049.so) + +author: Kenneth Hoste (HPC-UGent) +updated by: micketeer@gmail.com + +--- rustc-1.70.0-src.orig/src/bootstrap/bootstrap.py 2023-05-31 21:28:10.000000000 +0200 ++++ rustc-1.70.0-src/src/bootstrap/bootstrap.py 2023-06-04 14:15:39.784929373 +0200 +@@ -481,6 +481,10 @@ + if self._should_fix_bins_and_dylibs is not None: + return self._should_fix_bins_and_dylibs + ++ if os.getenv("EASYBUILD_SYSROOT"): ++ self._should_fix_bins_and_dylibs = True ++ return True ++ + def get_answer(): + default_encoding = sys.getdefaultencoding() + try: +@@ -531,6 +535,20 @@ + assert self._should_fix_bins_and_dylibs is True + print("attempting to patch", fname) + ++ easybuild_sysroot = os.getenv("EASYBUILD_SYSROOT") ++ if easybuild_sysroot: ++ if not fname.endswith(".so"): ++ # determine patch to interpreter in host via output produced by 'readelf -l /bin/bash' ++ readelf_out = subprocess.check_output(['readelf', '-l', '/bin/bash']).decode('ascii', 'ignore').strip() ++ regex = re.compile('.*program interpreter: ([^\]]+)', re.M) ++ res = regex.search(readelf_out) ++ interpreter_path = os.path.join(easybuild_sysroot, res.group(1).lstrip('/')) ++ if not os.path.exists(interpreter_path): ++ raise Exception("Derived path to interpreter does not exist: %s" % interpreter_path) ++ cmd = ["patchelf", "--set-interpreter", interpreter_path, fname] ++ run(cmd, verbose=True) ++ return ++ + # Only build `.nix-deps` once. + nix_deps_dir = self.nix_deps_dir + if not nix_deps_dir: