Skip to content

Commit

Permalink
Upgrade to rust 1.24 (#5477)
Browse files Browse the repository at this point in the history
1.24 defaults codegen-units to 16, which parallelises some compilation
stages, which is great for iteration speed, but leads to fewer
optimisations being applied. Force maximum optimisation on this axis,
when building in release mode.
  • Loading branch information
illicitonion authored Feb 20, 2018
1 parent 7788d47 commit c014e8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
15 changes: 8 additions & 7 deletions build-support/bin/native/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ esac
readonly CACHE_ROOT=${XDG_CACHE_HOME:-$HOME/.cache}/pants
readonly NATIVE_ENGINE_CACHE_DIR=${CACHE_ROOT}/bin/native-engine

readonly RUST_TOOLCHAIN="1.24.0"

function calculate_current_hash() {
# Cached and unstaged files, with ignored files excluded.
# NB: We fork a subshell because one or both of `ls-files`/`hash-object` are
# sensitive to the CWD, and the `--work-tree` option doesn't seem to resolve that.
(
cd ${REPO_ROOT}
(echo "${MODE_FLAG}"
echo "${RUST_TOOLCHAIN}"
git ls-files -c -o --exclude-standard \
"${NATIVE_ROOT}" \
"${REPO_ROOT}/src/python/pants/engine/native.py" \
Expand All @@ -70,11 +73,9 @@ function _ensure_cffi_sources() {
function ensure_native_build_prerequisites() {
# Control a pants-specific rust toolchain.

local rust_toolchain_root="${CACHE_ROOT}/rust"
export CARGO_HOME="${rust_toolchain_root}/cargo"
export RUSTUP_HOME="${rust_toolchain_root}/rustup"

local rust_toolchain="1.23.0"
local RUST_TOOLCHAIN_root="${CACHE_ROOT}/rust"
export CARGO_HOME="${RUST_TOOLCHAIN_root}/cargo"
export RUSTUP_HOME="${RUST_TOOLCHAIN_root}/rustup"

# NB: rustup installs itself into CARGO_HOME, but fetches toolchains into RUSTUP_HOME.
if [[ ! -x "${CARGO_HOME}/bin/rustup" ]]
Expand All @@ -83,13 +84,13 @@ function ensure_native_build_prerequisites() {
"https://www.rustup.rs ..."
local readonly rustup=$(mktemp -t pants.rustup.XXXXXX)
curl https://sh.rustup.rs -sSf > ${rustup}
sh ${rustup} -y --no-modify-path --default-toolchain "${rust_toolchain}" 1>&2
sh ${rustup} -y --no-modify-path --default-toolchain "${RUST_TOOLCHAIN}" 1>&2
rm -f ${rustup}
fi

# Make sure rust is pinned at the correct version.
# We sincerely hope that no one ever runs `rustup override set` in a subdirectory of the working directory.
"${CARGO_HOME}/bin/rustup" override set "${rust_toolchain}" >&2
"${CARGO_HOME}/bin/rustup" override set "${RUST_TOOLCHAIN}" >&2

# Sometimes fetching a large git repo dependency can take more than 10 minutes.
# This times out on travis, because nothing is printed to stdout/stderr in that time.
Expand Down
2 changes: 2 additions & 0 deletions src/rust/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ build = "src/cffi_build.rs"
# Enable debug symbols in the `release` profile: doesn't add a noticeable overhead in size/speed,
# but enables profiling of optimized builds.
debug = true
# Optimise for the speed of our binary, rather than the speed of compilation.
codegen-units = 1

[lib]
crate-type = ["dylib"]
Expand Down

0 comments on commit c014e8d

Please sign in to comment.