Skip to content

Commit

Permalink
rust: drop docs from bootstrap kit and speed up install.sh.
Browse files Browse the repository at this point in the history
When building the bootstrap kit, drop "docs" and "compiler-docs"
from the build.  This will make the install of the bootstrap kit
a lot faster, since it drops 5-6.000 files from the kit, which would
need to be processed by the install.sh script.  Note that this will
also impact the rust-bin package, since we also use the bootstrap
kits for installation there for the ports we maintain locally.  To
get these "docs" sub-sets installed, use the full "lang/rust" normal
build and/or a corresponding binary package.

Also, speed up the install.sh script (via install-template.sh) by
significantly reducing the number of forks in the inner loop.
Instead of relying on "grep", "sed" and "cut" for pattern matching,
substitution and field extraction, use case/esac and parameter
expansion modification to do the same, i.e. using in-shell mechanisms.
Submitted upstream, ref.

rust-lang/rust-installer#111

On an emulated (and loaded...) armv7 system, this reduced the time
(as shown with csh "time") for a test rig of install.sh (which
doesn't even actually do the file copying etc.) from

13000.143u 48616.601s 14:21:27.13 119.2%   57+151k 598+7367io 0pf+0w
to
3247.518u 9754.898s 3:45:48.70 95.9%   31+75k 927+4952io 14pf+0w

(This is with the "docs" and "compiler-docs" still in the bootstrap kit.)

Bump PKGREVISION.
  • Loading branch information
he32 committed May 25, 2021
1 parent c61e2c2 commit e3b1a7d
Show file tree
Hide file tree
Showing 3 changed files with 157 additions and 4 deletions.
11 changes: 10 additions & 1 deletion rust/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

DISTNAME= rustc-1.52.1-src
PKGNAME= ${DISTNAME:S/rustc/rust/:S/-src//}
PKGREVISION= 1
CATEGORIES= lang
MASTER_SITES= https://static.rust-lang.org/dist/

Expand Down Expand Up @@ -76,7 +77,9 @@ CHECK_SSP_SUPPORTED= no
# some may chose to mostly build faster,
# and deal with any failures due to deadlocks
.if !empty(rust.MAKE_JOBS_SAFE)
MAKE_JOBS_SAFE= ${rust.MAKE_JOBS_SAFE}
. if ${rust.MAKE_JOBS_SAFE:tl} == "yes"
MAKE_JOBS_SAFE= yes
. endif
.endif

.if !empty(rust.BUILD_TARGET)
Expand All @@ -90,6 +93,12 @@ BUILD_TARGET?= dist
BUILD_TARGET?= build
.endif

.if ${BUILD_TARGET} == "dist"
# Reduce size of bootstrap:
CONFIGURE_ARGS+= --disable-docs
CONFIGURE_ARGS+= --disable-compiler-docs
.endif

.if !empty(MACHINE_PLATFORM:MNetBSD-*-powerpc) || \
!empty(MACHINE_PLATFORM:MNetBSD-*-earmv7hf) || \
!empty(TARGET:Marmv7-unknown-netbsd-eabihf)
Expand Down
2 changes: 1 addition & 1 deletion rust/distinfo
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ SHA1 (patch-src_tools_cargo_src_cargo_core_profiles.rs) = 3aac5d54a6fe96b9559552
SHA1 (patch-src_tools_cargo_tests_testsuite_build.rs) = 10e6c1253adac0262b000aec7636fa0d2ebb666c
SHA1 (patch-src_tools_rls_rls_src_cmd.rs) = fade3e60fecac5c4e4d4ee5bee82659b4eb385b7
SHA1 (patch-src_tools_rls_rls_src_server_io.rs) = 51af64526db55abcf6b4b3165df314a16cf62e34
SHA1 (patch-src_tools_rust-installer_install-template.sh) = f2ec6dced2be1fa23773d5827503ad07d0913dc2
SHA1 (patch-src_tools_rust-installer_install-template.sh) = 9f93da54d9a126390d1ec9d1430241f876c8ba3f
SHA1 (patch-vendor_cc-1.0.60_src_lib.rs) = 42ddba7dfbec922e5ef948b97ff8c70bae1b0113
SHA1 (patch-vendor_cc_src_lib.rs) = 27d8b8b6d9a607362152069a206298854f517460
SHA1 (patch-vendor_libc_src_unix_solarish_mod.rs) = 804ea03be546fef0d2bd37d7f8abb26d38a7892b
Expand Down
148 changes: 146 additions & 2 deletions rust/patches/patch-src_tools_rust-installer_install-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ $NetBSD: patch-src_tools_rust-installer_install-template.sh,v 1.3 2018/11/27 15:
No logging to 'install.log'.
Do not create 'uninstall.sh'.

--- src/tools/rust-installer/install-template.sh.orig 2018-11-07 03:23:50.000000000 +0000
Rewrite to not use a whole lot of subprocesses just for doing
pattern matching and substitution in the install phase using "grep"
and "sed" when shell builtin "case" and "omit shortest match" ops
should do just fine.

--- src/tools/rust-installer/install-template.sh.orig 2021-03-23 16:15:29.000000000 +0000
+++ src/tools/rust-installer/install-template.sh
@@ -15,20 +15,12 @@ set -u
init_logging() {
Expand All @@ -26,7 +31,146 @@ Do not create 'uninstall.sh'.
}

msg() {
@@ -972,7 +964,6 @@ write_to_file "$TEMPLATE_RUST_INSTALLER_
@@ -442,8 +434,8 @@ uninstall_components() {
local _directive
while read _directive; do

- local _command=`echo $_directive | cut -f1 -d:`
- local _file=`echo $_directive | cut -f2 -d:`
+ local _command=${_directive%%:*}
+ local _file=${_directive#*:}

# Sanity checks
if [ ! -n "$_command" ]; then critical_err "malformed installation directive"; fi
@@ -549,8 +541,8 @@ install_components() {
local _directive
while read _directive; do

- local _command=`echo $_directive | cut -f1 -d:`
- local _file=`echo $_directive | cut -f2 -d:`
+ local _command=${_directive%%:*}
+ local _file=${_directive#*:}

# Sanity checks
if [ ! -n "$_command" ]; then critical_err "malformed installation directive"; fi
@@ -559,54 +551,45 @@ install_components() {
# Decide the destination of the file
local _file_install_path="$_dest_prefix/$_file"

- if echo "$_file" | grep "^etc/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^etc\///')"
- _file_install_path="$CFG_SYSCONFDIR/$_f"
- fi
-
- if echo "$_file" | grep "^bin/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^bin\///')"
- _file_install_path="$CFG_BINDIR/$_f"
- fi
-
- if echo "$_file" | grep "^lib/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^lib\///')"
- _file_install_path="$CFG_LIBDIR/$_f"
- fi
-
- if echo "$_file" | grep "^share" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^share\///')"
- _file_install_path="$CFG_DATADIR/$_f"
- fi
-
- if echo "$_file" | grep "^share/man/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^share\/man\///')"
- _file_install_path="$CFG_MANDIR/$_f"
- fi
+ case "$_file" in
+ etc/*)
+ local _f=${_file#"etc/"}
+ _file_install_path="$CFG_SYSCONFDIR/$_f"
+ ;;
+ bin/*)
+ local _f=${_file#"bin/"}
+ _file_install_path="$CFG_BINDIR/$_f"
+ ;;
+ lib/*)
+ local _f=${_file#"lib/"}
+ _file_install_path="$CFG_LIBDIR/$_f"
+ ;;
+ share/man/*)
+ local _f=${_file#"share/man/"}
+ _file_install_path="$CFG_MANDIR/$_f"
+ ;;
+ share/doc/*)
+ # HACK: Try to support overriding --docdir. Paths with the form
+ # "share/doc/$product/" can be redirected to a single --docdir
+ # path. If the following detects that --docdir has been specified
+ # then it will replace everything preceeding the "$product" path
+ # component. The problem here is that the combined rust installer
+ # contains two "products": rust and cargo; so the contents of those
+ # directories will both be dumped into the same directory; and the
+ # contents of those directories are _not_ disjoint. Since this feature
+ # is almost entirely to support 'make install' anyway I don't expect
+ # this problem to be a big deal in practice.
+ if [ "$CFG_DOCDIR" != "<default>" ]; then
+ local _f=${_file#"share/doc/"}
+ _file_install_path="$CFG_DOCDIR/$_f"
+ fi
+ ;;
+ share/*)
+ local _f=${_file#"share/"}
+ _file_install_path="$CFG_DATADIR/$_f"
+ ;;
+ esac

- # HACK: Try to support overriding --docdir. Paths with the form
- # "share/doc/$product/" can be redirected to a single --docdir
- # path. If the following detects that --docdir has been specified
- # then it will replace everything preceeding the "$product" path
- # component. The problem here is that the combined rust installer
- # contains two "products": rust and cargo; so the contents of those
- # directories will both be dumped into the same directory; and the
- # contents of those directories are _not_ disjoint. Since this feature
- # is almost entirely to support 'make install' anyway I don't expect
- # this problem to be a big deal in practice.
- if [ "$CFG_DOCDIR" != "<default>" ]
- then
- if echo "$_file" | grep "^share/doc/" > /dev/null
- then
- local _f="$(echo "$_file" | sed 's/^share\/doc\/[^/]*\///')"
- _file_install_path="$CFG_DOCDIR/$_f"
- fi
- fi
# Make sure there's a directory for it
make_dir_recursive "$(dirname "$_file_install_path")"
@@ -625,14 +608,16 @@ install_components() {

maybe_backup_path "$_file_install_path"

- if echo "$_file" | grep "^bin/" > /dev/null || test -x "$_src_dir/$_component/$_file"
- then
- run cp "$_src_dir/$_component/$_file" "$_file_install_path"
- run chmod 755 "$_file_install_path"
- else
- run cp "$_src_dir/$_component/$_file" "$_file_install_path"
- run chmod 644 "$_file_install_path"
+ local mode=644
+ if test -x "$_src_dir/$_component/$_file"; then
+ mode=755
fi
+ case "$_file" in
+ bin/*) mode=755
+ ;;
+ esac
+ run cp "$_src_dir/$_component/$_file" "$_file_install_path"
+ run chmod $mode "$_file_install_path"
critical_need_ok "file creation failed"

# Update the manifest
@@ -972,7 +957,6 @@ write_to_file "$TEMPLATE_RUST_INSTALLER_
critical_need_ok "failed to write installer version"
# Install the uninstaller
Expand Down

0 comments on commit e3b1a7d

Please sign in to comment.