diff --git a/ci/buildkite-pipeline.sh b/ci/buildkite-pipeline.sh index 711551805d2de9..2557a098984e73 100755 --- a/ci/buildkite-pipeline.sh +++ b/ci/buildkite-pipeline.sh @@ -181,7 +181,9 @@ wait_step() { all_test_steps() { command_step checks1 "ci/docker-run-default-image.sh ci/test-checks.sh" 20 check - command_step checks2 "ci/docker-run-default-image.sh ci/test-dev-context-only-utils.sh check-bins" 15 check + command_step checks2b "ci/docker-run-default-image.sh ci/test-dev-context-only-utils.sh check-bins" 15 check + command_step checks2l "ci/docker-run-default-image.sh ci/test-dev-context-only-utils.sh check-lib" 15 check + command_step checks2bl "ci/docker-run-default-image.sh ci/test-dev-context-only-utils.sh check-bins-and-lib" 15 check command_step checks3 "ci/docker-run-default-image.sh ci/test-dev-context-only-utils.sh check-all-targets" 15 check command_step miri "ci/docker-run-default-image.sh ci/test-miri.sh" 5 check wait_step diff --git a/scripts/check-dev-context-only-utils.sh b/scripts/check-dev-context-only-utils.sh index 65382d20663e46..efa72883e0026a 100755 --- a/scripts/check-dev-context-only-utils.sh +++ b/scripts/check-dev-context-only-utils.sh @@ -43,7 +43,7 @@ allowed="${allowed%,}" mode=${1:-full} case "$mode" in - tree | check-bins | check-all-targets | full) + tree | check-bins | check-lib | check-bins-and-lib | check-all-targets | full) ;; *) echo "$0: unrecognized mode: $mode"; @@ -156,8 +156,43 @@ fi # consistency with other CI steps and for the possibility of new similar lints. export RUSTFLAGS="-D warnings -Z threads=8 $RUSTFLAGS" -if [[ $mode = "check-bins" || $mode = "full" ]]; then - _ cargo "+${rust_nightly}" hack check --bins +if [[ $mode = "check-bins" || $mode = "check-lib" || $mode = "check-bins-and-lib" || $mode = "full" ]]; then + # Until https://github.com/rust-lang/cargo/pull/14163 is applied for our + # chosen nightly toolchain, dcou needs custom-built cargo to avoid + # false-negatives. + + # This clone will fail every time we update our nightly toolchain because + # ${rust_nightly} is embedded in the branch name. This is intentional to + # force to re-cheery-pick the patch for the new nightly. + # + # Steps: + # 1. Clone the forked cargo repo. + # 2. Check out the commit hash printed by `/solana/cargo nightly --version + # --verbose` _using the new toolchain_. + # 3. Cherry-pick old branch's tip commit titled as "Unify no-library-target + # error into no-target warn". + # 4. Push new branch with its name updated with the new nightly version. + _ git clone --depth 1 --no-tags \ + --branch "no-no-library-target-error-${rust_nightly}" \ + https://github.com/anza-xyz/cargo.git cargo-for-dcou + + # Now build the patched cargo + ( + cd ./cargo-for-dcou/ + _ cargo "+${rust_nightly}" build --release --bin cargo + ) + + # Use `cargo "+${rust_nightly}" hack ..` once we stop using custom-built one. + if [[ $mode = "check-bins" ]]; then + PATH="./cargo-for-dcou/target/release:$PATH" \ + RUSTUP_TOOLCHAIN="${rust_nightly}" _ cargo hack check --bins + elif [[ $mode = "check-lib" ]]; then + PATH="./cargo-for-dcou/target/release:$PATH" \ + RUSTUP_TOOLCHAIN="${rust_nightly}" _ cargo hack check --lib + else + PATH="./cargo-for-dcou/target/release:$PATH" \ + RUSTUP_TOOLCHAIN="${rust_nightly}" _ cargo hack check --bins --lib + fi fi if [[ $mode = "check-all-targets" || $mode = "full" ]]; then _ cargo "+${rust_nightly}" hack check --all-targets