Page MenuHomeFreeBSD

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

Authored by dumbbell on May 22 2017, 3:30 PM.
Referenced Files
F72591528: D10857.diff
Sun, Dec 10, 6:38 PM
Unknown Object (File)
Sat, Nov 18, 8:20 AM
Unknown Object (File)
Sat, Nov 18, 6:15 AM
Unknown Object (File)
Nov 8 2023, 5:27 AM
Unknown Object (File)
Nov 3 2023, 1:35 PM
Unknown Object (File)
Oct 10 2023, 6:39 PM
Unknown Object (File)
Sep 28 2023, 4:50 PM
Unknown Object (File)
Sep 23 2023, 7:39 AM



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:

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 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

rP FreeBSD ports repository
Lint Not Applicable
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/ 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/
  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/
Traceback (most recent call last):
  File "src/bootstrap/", line 614, in <module>
  File "src/bootstrap/", line 602, in main
  File "src/bootstrap/", line 585, in bootstrap
  File "src/bootstrap/", line 182, in download_stage0
  File "src/bootstrap/", line 126, in unpack
    shutil.move(tp, fp)
  File "/usr/local/lib/python2.7/", line 302, in move
    copy2(src, real_dst)
  File "/usr/local/lib/python2.7/", line 130, in copy2
    copyfile(src, dst)
  File "/usr/local/lib/python2.7/", 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/'

However, Python 3 handles it correctly:

rustc-1.17.0-src $ python3 src/bootstrap/ 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/
  extracting rust-std-1.17.0-x86_64-unknown-freebsd/rust-std-x86_64-unknown-freebsd/lib/rustlib/x86_64-unknown-freebsd/lib/
  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

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 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.

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