# rustc/cfg - "Build" settings for package #--------------------------------------------------------------------- [technotes] 1. "rustc" is needed to build itself. To build "rustc", therefore, it's often necessary to download remote tarballs first. Note: The remote tarballs contain prebuilt executables. It might be necessary to leave Internet access on as well and to allow the build procedure to download other files. If the "rustc" package was built previously and is still installed, and the existing copy isn't too old compared to the copy that is go- ing to be built, the new copy can probably be built without Internet access and downloads. This is one of relatively few packages supported by Laclin that has Internet build access issues. In general, Laclin seeks to avoid packages that require remote execu- tables and/or online builds, though there are exceptions. "rustc" was added because Rust might be needed in the future to build Linux kernels. Additionally, there are a number of useful CLI tools that are written in Rust. "uv" is one example. #--------------------------------------------------------------------- 2. "rustc" is presently hidden, to some extent, from the rest of the distro. If a package needs "rustc" to build, the associated "cfg" file should include "rustc" in a "setpaths" line. For example: setpaths = rustc zlib Alternatively, "bash" scripts that need "rustc" for arbitrary opera- tions, not limited to Laclin package builds, can do the following to set things up: . srcpkgpaths rustc zlib #--------------------------------------------------------------------- 3. The steps used to obtain the remote executables previously were as follows. # Assumptions: Internet access is enabled. The main "rustc" source # tarball is located in the current directory. The variable "CBSDIR" # specifies a path for the directory that contains the following file: # config-bootstrap.toml # config-bootstrap.toml is provided with this "cfg" file [in an asso- # ciated subdirectory named "special"]. set -e . srcpkgpaths zlib HERE=`pwd` CBSDIR=$HERE/special RUSTREL=1.87.0 SRCNAME=rustc-$RUSTREL-src rm -fr $SRCNAME tar Jxf $HERE/$SRCNAME.tar.xz cd $SRCNAME sed -e "s@__META_PREFIX__@/tmp/rustc@" \ < $CBSDIR/config-bootstrap.toml \ > config.toml export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi" python3 ./x.py check python3 ./x.py build --exclude src/tools/miri . srcpkgpaths zlib # Press Control-C to abort the build as soon as three ".tar.xz" tar- # balls are downloaded. # The "build/cache/" subdirectory should now contain a subdirectory # with a date name similar to "2023-01-10". "cp -a" the date-name dir- # ectory into the directory "special/cache/" that comes with this # "cfg" file. #--------------------------------------------------------------------- 3. "rustc" updates can be problematic. One issue is that a "rustc" build will only work if a compatible re- lease of "libgit2" is installed and "libgit2" compatibility is unpre- dictable. If either "libgit2" or "rustc" is updated, a "rustc" build should be attempted. If it fails due to a "libgit2" compatibility issue, the up- date should be cancelled. #--------------------------------------------------------------------- 4. It's likely that you'll need to delete the existing copy of the "rustc" package before you can rebuild the package. This is especial- ly true if the existing copy is more than a release or two older than the release that you'll be building. If you leave the existing copy of the package in place, the package will try to use itself to rebuild itself. This approach may be faster than the alternative, which will be a rebuild from scratch that relies on the foreign tarballs. Either way, it's recommended that the existing copy of the "rustc" package be backed up before you proceed. #--------------------------------------------------------------------- [buildtimes] 01.47 hours (or 087.93 minutes) - 2023 dedi Xeon E3-1200 v3 4x2 32GB RAM - rustc 1.87.0 using clang 20.1. 5 in a build from scratch without existing rustc - 250524 01.55 hours (or 092.93 minutes) - 2023 dedi Xeon E3-1200 v3 4x2 32GB RAM - rustc 1.85.0 using existing rustc 1.84.0 - 250112 01.56 hours (or 093.65 minutes) - 2023 dedi Xeon E3-1200 v3 4x2 32GB RAM - rustc 1.84.0 using existing rustc 1.83.0 - 250112 02.03 hours (or 121.62 minutes) - ThinkPad W530 i7 4x2 32GB RAM Obsolete times: 00.89 hours (or 053.42 minutes) - 2021 L.A. dedi box: 6x2 CPU 32GB RAM 00.90 hours (or 054.05 minutes) - 2023 dedi Xeon E3-1200 v3 4x2 32GB RAM 01.62 hours (or 097.50 minutes) - OpenVZ 1x4 CPU 4GB RAM 01.83 hours (or 109.85 minutes) - ThinkPad W530 i7 4x2 32GB RAM #---------------------------------------------------------------------- [settings] altpkg = yes compiler = clang configure = none defer = glibc64 nosyslinks = yes purge = no tmpsize = 9217M setpaths = zlib #--------------------------------------------------------------------- [depends] brotli curl git libgit2 libidn2 libpcap libpsl librtmp libsasl libssh2 libunistring nghttp2 openldap openssl pcre python sqlite3 zlib zstd #--------------------------------------------------------------------- [build] #ifdef NOTDEF # This was needed in the past # sed -e '/MirOpt/d' -i src/bootstrap/src/core/builder.rs #endif # endif NOTDEF if [ -d $PRODTREE/rustc ]; then . srcpkgpaths rustc fi RUSTHOME=/var/tmp/rusthome rm -fr $RUSTHOME export HOME=$RUSTHOME export CARGO_HOME=$RUSTHOME/.cargo mkdir -p $RUSTHOME $CARGO_HOME unset RUSTHOME SPCLIB=$PKGDIR_PROD/spclib mkdir -p $SPCLIB export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SPCLIB mkdir -p build/cache cp -a $PKGDIR_SPECIAL/cache/* build/cache/ sed -e "s@__META_PREFIX__@$PKGDIR_PROD@" \ < $PKGDIR_SPECIAL/config-bootstrap.toml \ > config.toml if [ -f $PKGDIR_PROD/bin/rustc ]; then sed -e 's@^ *# *stage *2 *@@' -i config.toml fi export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi" python3 ./x.py check python3 ./x.py build library --exclude src/tools/miri export LIBSSH2_SYS_USE_PKG_CONFIG=1 DESTDIR=${PWD}/install python3 ./x.py install unset LIBSSH2_SYS_USE_PKG_CONFIG cd install chown -R 0.0 . settreedate . rm -fr $PKGDIR_PROD mkdir -p $PKGDIR_PROD cp -a */pkg/rustc/* $PKGDIR_PROD/ mkdir -p /opt cd /opt rm -fr rustc ln -s $PKGDIR_PROD rustc rm -fr $SPCLIB mkdir -p $SPCLIB cp -a $PRODTREE/libgit2/lib/* $SPCLIB/ #--------------------------------------------------------------------- # Original URLs. These URLs were valid at one point, but may have died # since then. If you download newer versions of tarballs [etc.], don't # delete the original versions, as you may not be able to replace # them. [urls] url_debian = tbd url_home = tbd url_lfs = tbd url_tarball = https://static.rust-lang.org/dist/\ rustc-1.87.0-src.tar.xz #--------------------------------------------------------------------- [history] 220902 Added package. Started with 1.60.0. 220906 Updated to 1.62.1 230218 Updated to 1.66.1 240331 Updated to 1.76.0 240727 Updated to 1.80.0 241124 Updated to 1.82.0 250111 Updated to 1.83.0 250512 Updated to 1.84.0 250512 Updated to 1.85.0 250524 Updated to 1.87.0