diff --git a/scripts/cargo-install-all.sh b/scripts/cargo-install-all.sh index 2c1a8dd883801a..645e57dcb4f429 100755 --- a/scripts/cargo-install-all.sh +++ b/scripts/cargo-install-all.sh @@ -96,36 +96,41 @@ if [[ $CI_OS_NAME = windows ]]; then solana-test-validator solana-tokens ) + DCOU_BINS=() else ./fetch-perf-libs.sh BINS=( solana - solana-bench-tps solana-faucet solana-genesis solana-gossip agave-install solana-keygen - agave-ledger-tool solana-log-analyzer solana-net-shaper agave-validator rbpf-cli ) + DCOU_BINS=( + agave-ledger-tool + solana-bench-tps + ) # Speed up net.sh deploys by excluding unused binaries if [[ -z "$validatorOnly" ]]; then BINS+=( cargo-build-sbf cargo-test-sbf - solana-dos agave-install-init solana-stake-accounts solana-test-validator solana-tokens agave-watchtower ) + DCOU_BINS+=( + solana-dos + ) fi fi @@ -134,12 +139,52 @@ for bin in "${BINS[@]}"; do binArgs+=(--bin "$bin") done +dcouBinArgs=() +for bin in "${DCOU_BINS[@]}"; do + dcouBinArgs+=(--bin "$bin") +done + +source "$SOLANA_ROOT"/scripts/dcou-tainted-packages.sh + +excludeArgs=() +for package in "${dcou_tainted_packages[@]}"; do + excludeArgs+=(--exclude "$package") +done + mkdir -p "$installDir/bin" +# Some binaries (like the notable agave-ledger-tool) need to acitivate +# the dev-context-only-utils feature flag to build. +# Build those binaries separately to avoid the unwanted feature unification. +# Note that `--workspace --exclude ` is needed to really +# inhibit the feature unification due to a cargo bug. Otherwise, feature +# unification happens even if cargo build is run only with `--bin` targets +# which don't depend on dcou as part of dependencies at all. ( set -x - # shellcheck disable=SC2086 # Don't want to double quote $rust_version - "$cargo" $maybeRustVersion build $buildProfileArg "${binArgs[@]}" + # Make sure dcou is really disabled by peeking the (unstable) build plan + # output after turning rustc into the nightly mode with RUSTC_BOOTSTRAP=1. + # In this way, additional requirement of nightly rustc toolchian is avoided. + # Note that `cargo tree` can't be used, because it doesn't support `--bin`. + # shellcheck disable=SC2086 # Don't want to double quote $maybeRustVersion + if (RUSTC_BOOTSTRAP=1 \ + "$cargo" $maybeRustVersion build \ + -Z unstable-options --build-plan \ + $buildProfileArg "${binArgs[@]}" --workspace "${excludeArgs[@]}" | \ + grep -q -F '"feature=\"dev-context-only-utils\""'); then + echo 'dcou feature activation is incorrctly activated!' && \ + exit 1 + fi + + # Build our production binaries without dcou. + # shellcheck disable=SC2086 # Don't want to double quote $maybeRustVersion + "$cargo" $maybeRustVersion build \ + $buildProfileArg "${binArgs[@]}" --workspace "${excludeArgs[@]}" + + # Finally, build the remaining dev tools with dcou. + # shellcheck disable=SC2086 # Don't want to double quote $maybeRustVersion + "$cargo" $maybeRustVersion build \ + $buildProfileArg "${dcouBinArgs[@]}" # Exclude `spl-token` binary for net.sh builds if [[ -z "$validatorOnly" ]]; then @@ -155,7 +200,7 @@ mkdir -p "$installDir/bin" fi ) -for bin in "${BINS[@]}"; do +for bin in "${BINS[@]}" "${DCOU_BINS[@]}"; do cp -fv "target/$buildProfile/$bin" "$installDir"/bin done diff --git a/scripts/check-dev-context-only-utils.sh b/scripts/check-dev-context-only-utils.sh index c1b12eb9cd8931..e64e0691b80a6c 100755 --- a/scripts/check-dev-context-only-utils.sh +++ b/scripts/check-dev-context-only-utils.sh @@ -28,18 +28,10 @@ source ci/rust-version.sh nightly # as normal (not dev) dependencies, only if you're sure that there's good # reason to bend dev-context-only-utils's original intention and that listed # package isn't part of released binaries. -declare tainted_packages=( - solana-accounts-bench - solana-banking-bench - agave-ledger-tool - solana-bench-tps - agave-store-tool - agave-store-histogram - agave-accounts-hash-cache-tool -) +source scripts/dcou-tainted-packages.sh # convert to comma separeted (ref: https://stackoverflow.com/a/53839433) -printf -v allowed '"%s",' "${tainted_packages[@]}" +printf -v allowed '"%s",' "${dcou_tainted_packages[@]}" allowed="${allowed%,}" mode=${1:-full} diff --git a/scripts/dcou-tainted-packages.sh b/scripts/dcou-tainted-packages.sh new file mode 100644 index 00000000000000..72e578bf2d1bfe --- /dev/null +++ b/scripts/dcou-tainted-packages.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# shellcheck disable=SC2034 # This file is intended to be `source`d +declare dcou_tainted_packages=( + solana-accounts-bench + solana-banking-bench + agave-ledger-tool + solana-bench-tps + agave-store-tool + agave-store-histogram + agave-accounts-hash-cache-tool + solana-dos +)