Page MenuHomeFreeBSD

lang/rust: Enable on FreeBSD/aarch64 + various fixes
ClosedPublic

Authored by dumbbell on May 22 2017, 3:30 PM.

Details

Summary

The port now uses an unofficial bootstrap of Rust 1.17.0 and Cargo 0.18.0 to build on FreeBSD/aarch64.

Here are my notes on creating the bootstraps:
https://gist.github.com/dumbbell/b587da50ef014078da9e732a4331ebad

The port's Makefile was changed to:

  • Allow to override the versions and directories of the bootstrap archives
  • Patch the bootstrap script and manifest with those versions/directories

Beside changes to support aarch64, the port received the following fixes:

  • Pass python path to the configure script.
  • Fix and simplify the extraction of rust-std bootstrap by re-using existing variables.
  • Make sure tar(1) doesn't produce sparse file entries when it recreates the rust-std bootstrap because Python 2's tarfile module doesn't support them.
Test Plan

I build-tested the port on ref12-aarch64.freebsd.org. I'm not a sudoer so I couldn't install it. I simply executed rustc --version to see if the executable was valid. Because the cross-compiled bootstrap is working, I'm confident the natively-built version is fine. Once the Cargo port is also enabled FreeBSD/aarch64, I'll do more thorough tests.

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Also, the patch doesn't contain that yet, but we should depend on Python 3 to build, not any Python, and certainly not Python 2.

The reason is that the tarfile module of Python 2 doesn't know how to extract archives which contain sparse files:

rustc-1.17.0-src $ python2 src/bootstrap/bootstrap.py build -v
extracting /tmp/rustc-1.17.0-src/build/cache/2017-03-11/rust-std-1.17.0-x86_64-unknown-freebsd.tar.gz
  ...
  extracting rust-std-1.17.0-x86_64-unknown-freebsd/rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_privacy-a333d73bee0a0921.so
  extracting rust-std-1.17.0-x86_64-unknown-freebsd/rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/GNUSparseFile.0/librustc_llvm-f7419f37be76faf4.so
Traceback (most recent call last):
  File "src/bootstrap/bootstrap.py", line 614, in <module>
    main()
  File "src/bootstrap/bootstrap.py", line 602, in main
    bootstrap()
  File "src/bootstrap/bootstrap.py", line 585, in bootstrap
    rb.download_stage0()
  File "src/bootstrap/bootstrap.py", line 182, in download_stage0
    verbose=self.verbose)
  File "src/bootstrap/bootstrap.py", line 126, in unpack
    shutil.move(tp, fp)
  File "/usr/local/lib/python2.7/shutil.py", line 302, in move
    copy2(src, real_dst)
  File "/usr/local/lib/python2.7/shutil.py", line 130, in copy2
    copyfile(src, dst)
  File "/usr/local/lib/python2.7/shutil.py", line 83, in copyfile
    with open(dst, 'wb') as fdst:
IOError: [Errno 2] No such file or directory: '/tmp/rustc-1.17.0-src/build/x86_64-unknown-freebsd/stage0/lib/rustlib/x86_64-unknown-freebsd/lib/GNUSparseFile.0/librustc_llvm-f7419f37be76faf4.so'

However, Python 3 handles it correctly:

rustc-1.17.0-src $ python3 src/bootstrap/bootstrap.py build -v
extracting /tmp/rustc-1.17.0-src/build/cache/2017-03-11/rust-std-1.17.0-x86_64-unknown-freebsd.tar.gz
  ...
  extracting rust-std-1.17.0-x86_64-unknown-freebsd/rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_privacy-a333d73bee0a0921.so
  extracting rust-std-1.17.0-x86_64-unknown-freebsd/rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/librustc_llvm-f7419f37be76faf4.so
  extracting rust-std-1.17.0-x86_64-unknown-freebsd/rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/libcompiler_builtins-968aaa93f5d6ff89.rlib
  ...
downloading https://static.rust-lang.org/dist/2017-03-11/rustc-1.17.0-x86_64-unknown-freebsd.tar.gz.sha256

Update after the commit of the ino64 project

The same old_fstat.c trick is used with the aarch64 bootstrap, I didn't rebuild a second bootstrap. The variables used by the recipe to patch the bootstrap were changed to use existing variables and have no hard-coded bits.

The port now depends on python27 instead of python2. Also, ${PYTHON_CMD} is passed to the configure script, otherwise it could pick another version.

The port still uses Python 2.7, not 3.x because the configure script enforces this version. However, the bootstrap.py script seems happy with Python 3. I still need to investigate a bit more: it would be nice to switch to 3.x because it handles sparse files in tar archives just fine.

Adapt files/extra-patch-ino64 to aarch64

This change was missing in the previous revision.

The port was built successfully on FreeBSD HEAD/aarch64, both pre-ino64 and post-ino64.

Rebase onto the 1.18.0 update

Also, pass --format=ustar to tar(1) when recreating the rust-std bootstrap to make sure it doesn't use sparse file entries. Those entries are unsupported in Python 2's tarfile module.

dumbbell retitled this revision from lang/rust: Enable on FreeBSD/aarch64 to lang/rust: Enable on FreeBSD/aarch64 + various fixes.Jun 16 2017, 7:42 AM
dumbbell edited the summary of this revision. (Show Details)
This revision was automatically updated to reflect the committed changes.
head/lang/rust/files/extra-patch-ino64
251

Don't you need s/::uint16_t/u16/ etc. under src/vendor/libc/ for consistency with x86*.rs?