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

{lang}[GCCcore/12.3.0] Rust v1.70.0 #18016

Merged
merged 5 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
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
55 changes: 55 additions & 0 deletions easybuild/easyconfigs/r/Rust/Rust-1.70.0-GCCcore-12.3.0.eb
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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: