From e44d7e280ea29f2a06b607d1e21c75ce7f9fd106 Mon Sep 17 00:00:00 2001 From: Alessandro Decina Date: Fri, 3 Jun 2022 16:16:32 +0100 Subject: [PATCH 1/7] [SOL] build-std: pull in our compiler-builtins When -Z build-std is used, patch compiler-builtins so that our own fork is downloaded. Needed for https://github.com/solana-labs/solana/pull/23465. --- src/cargo/core/compiler/standard_lib.rs | 12 ++++++++++-- src/doc/src/reference/semver.md | 2 +- tests/build-std/main.rs | 10 ++++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/cargo/core/compiler/standard_lib.rs b/src/cargo/core/compiler/standard_lib.rs index 684e4426c04..ce99aa13688 100644 --- a/src/cargo/core/compiler/standard_lib.rs +++ b/src/cargo/core/compiler/standard_lib.rs @@ -6,7 +6,7 @@ use crate::core::compiler::{CompileKind, CompileMode, RustcTargetData, Unit}; use crate::core::profiles::{Profiles, UnitFor}; use crate::core::resolver::features::{CliFeatures, FeaturesFor, ResolvedFeatures}; use crate::core::resolver::HasDevUnits; -use crate::core::{Dependency, PackageId, PackageSet, Resolve, SourceId, Workspace}; +use crate::core::{Dependency, GitReference, PackageId, PackageSet, Resolve, SourceId, Workspace}; use crate::ops::{self, Packages}; use crate::util::errors::CargoResult; use crate::GlobalContext; @@ -79,7 +79,7 @@ pub fn resolve_std<'gctx>( "rustc-std-workspace-alloc", "rustc-std-workspace-std", ]; - let patches = to_patch + let mut patches = to_patch .iter() .map(|&name| { let source_path = SourceId::for_path(&src_path.join("library").join(name))?; @@ -87,6 +87,14 @@ pub fn resolve_std<'gctx>( Ok(dep) }) .collect::>>()?; + patches.push(Dependency::parse( + "compiler_builtins", + None, + SourceId::for_git( + &("https://github.com/solana-labs/compiler-builtins".parse()).unwrap(), + GitReference::Tag("solana-tools-v1.36".to_string()), + )?, + )?); let crates_io_url = crate::sources::CRATES_IO_INDEX.parse().unwrap(); let patch = HashMap::from([(crates_io_url, patches)]); let members = vec![ diff --git a/src/doc/src/reference/semver.md b/src/doc/src/reference/semver.md index 795442c00b8..565f455b6bc 100644 --- a/src/doc/src/reference/semver.md +++ b/src/doc/src/reference/semver.md @@ -1130,7 +1130,7 @@ pub enum E { fn main() { use updated_crate::E; let x = E::Variant1; - match x { // Error: `E::Variant2` not covered + match x { // Error: non-exhaustive patterns: `E::Variant2` not covered E::Variant1 => {} } } diff --git a/tests/build-std/main.rs b/tests/build-std/main.rs index 84915790851..5ecae18d330 100644 --- a/tests/build-std/main.rs +++ b/tests/build-std/main.rs @@ -113,8 +113,14 @@ fn basic() { // Importantly, this should not say [UPDATING] // There have been multiple bugs where every build triggers and update. .with_stderr( - "[COMPILING] foo v0.0.1 [..]\n\ - [FINISHED] `dev` profile [..]", + "[UPDATING] git repository `https://github.com/solana-labs/compiler-builtins`\n\ + warning: Patch `compiler_builtins v0.1.88 (https://github.com/solana-labs/compiler-builtins?tag=solana-tools-v1.36#e6395414)` was not used in the crate graph.\n\ + Check that the patched package version and available features are compatible\n\ + with the dependency requirements. If the patch has a different version from\n\ + what is locked in the Cargo.lock file, run `cargo update` to use the new\n\ + version. This may also occur with an optional dependency that is not enabled.\n\ + [COMPILING] foo v0.0.1 [..]\n\ + [FINISHED] dev [..]", ) .run(); p.cargo("run").build_std().target_host().run(); From 4f0b26d0a99e4d6bb724f6c51becebb573993a0d Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel Date: Tue, 6 Feb 2024 09:52:43 -0300 Subject: [PATCH 2/7] [SOL] Update compiler builtins to v1.40 --- src/cargo/core/compiler/standard_lib.rs | 2 +- tests/build-std/main.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cargo/core/compiler/standard_lib.rs b/src/cargo/core/compiler/standard_lib.rs index ce99aa13688..113b33e4bed 100644 --- a/src/cargo/core/compiler/standard_lib.rs +++ b/src/cargo/core/compiler/standard_lib.rs @@ -92,7 +92,7 @@ pub fn resolve_std<'gctx>( None, SourceId::for_git( &("https://github.com/solana-labs/compiler-builtins".parse()).unwrap(), - GitReference::Tag("solana-tools-v1.36".to_string()), + GitReference::Tag("solana-tools-v1.40".to_string()), )?, )?); let crates_io_url = crate::sources::CRATES_IO_INDEX.parse().unwrap(); diff --git a/tests/build-std/main.rs b/tests/build-std/main.rs index 5ecae18d330..2fdb5834cfa 100644 --- a/tests/build-std/main.rs +++ b/tests/build-std/main.rs @@ -114,7 +114,7 @@ fn basic() { // There have been multiple bugs where every build triggers and update. .with_stderr( "[UPDATING] git repository `https://github.com/solana-labs/compiler-builtins`\n\ - warning: Patch `compiler_builtins v0.1.88 (https://github.com/solana-labs/compiler-builtins?tag=solana-tools-v1.36#e6395414)` was not used in the crate graph.\n\ + warning: Patch `compiler_builtins v0.1.103 (https://github.com/solana-labs/compiler-builtins?tag=solana-tools-v1.40#81ef46f3)` was not used in the crate graph.\n\ Check that the patched package version and available features are compatible\n\ with the dependency requirements. If the patch has a different version from\n\ what is locked in the Cargo.lock file, run `cargo update` to use the new\n\ From a98d42a40561a2c6ae18091a3fd243332d9f81aa Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel Date: Thu, 8 Feb 2024 14:02:55 -0300 Subject: [PATCH 3/7] [SOL] Remove nightly and beta tests --- .github/workflows/main.yml | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 997911292c5..b9375344470 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -125,22 +125,14 @@ jobs: os: ubuntu-latest rust: stable other: i686-unknown-linux-gnu - - name: Linux x86_64 beta - os: ubuntu-latest - rust: beta - other: i686-unknown-linux-gnu - - name: Linux x86_64 nightly - os: ubuntu-latest - rust: nightly - other: i686-unknown-linux-gnu - - name: macOS x86_64 stable - os: macos-13 - rust: stable - other: x86_64-apple-ios - - name: macOS x86_64 nightly - os: macos-13 - rust: nightly - other: x86_64-apple-ios +# - name: Linux x86_64 beta +# os: ubuntu-latest +# rust: beta +# other: i686-unknown-linux-gnu +# - name: Linux x86_64 nightly +# os: ubuntu-latest +# rust: nightly +# other: i686-unknown-linux-gnu - name: macOS aarch64 stable os: macos-14 rust: stable @@ -149,10 +141,10 @@ jobs: os: windows-latest rust: stable-msvc other: i686-pc-windows-msvc - - name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite - os: windows-latest - rust: nightly-gnu - other: i686-pc-windows-gnu +# - name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite +# os: windows-latest +# rust: nightly-gnu +# other: i686-pc-windows-gnu name: Tests ${{ matrix.name }} steps: - uses: actions/checkout@v4 @@ -229,7 +221,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: rustup update nightly && rustup default nightly + - run: rustup update stable && rustup default stable - run: rustup component add rust-src - run: cargo build - run: cargo test -p cargo --test build-std From 1557904e62fbe0235e54d89623aff4fe96e4dbf8 Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel <38472950+LucasSte@users.noreply.github.com> Date: Thu, 8 Feb 2024 19:59:10 -0300 Subject: [PATCH 4/7] [SOL] Test only with the release version --- .github/workflows/main.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b9375344470..d52d173b895 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -100,7 +100,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - run: rustup update stable && rustup default stable + - run: rustup toolchain install 1.75.0 && rustup default 1.75.0 - name: Install cargo-semver-checks run: | mkdir installed-bins @@ -123,7 +123,7 @@ jobs: include: - name: Linux x86_64 stable os: ubuntu-latest - rust: stable + rust: 1.75.0 other: i686-unknown-linux-gnu # - name: Linux x86_64 beta # os: ubuntu-latest @@ -135,11 +135,15 @@ jobs: # other: i686-unknown-linux-gnu - name: macOS aarch64 stable os: macos-14 - rust: stable + rust: 1.79.0 other: x86_64-apple-darwin +# - name: macOS x86_64 nightly +# os: macos-latest +# rust: nightly +# other: x86_64-apple-ios - name: Windows x86_64 MSVC stable os: windows-latest - rust: stable-msvc + rust: 1.75.0-msvc other: i686-pc-windows-msvc # - name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite # os: windows-latest @@ -209,7 +213,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: rustup update --no-self-update stable && rustup default stable + - run: rustup toolchain install 1.75.0 && rustup default 1.75.0 - run: rustup target add i686-unknown-linux-gnu - run: sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y - run: rustup component add rustfmt || echo "rustfmt not available" @@ -259,4 +263,4 @@ jobs: steps: - uses: actions/checkout@v4 - uses: taiki-e/install-action@cargo-hack - - run: cargo hack check --all-targets --rust-version --workspace --ignore-private --locked + - run: cargo hack check --all-targets --workspace --ignore-private --locked From b09fa91373698bcfa902923b944bcda430f843f6 Mon Sep 17 00:00:00 2001 From: Lucas Date: Mon, 12 Feb 2024 15:34:23 -0700 Subject: [PATCH 5/7] [SOL] Check release bump against the Solana release --- crates/xtask-bump-check/src/xtask.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/xtask-bump-check/src/xtask.rs b/crates/xtask-bump-check/src/xtask.rs index a53a0a8bcfb..e60805db640 100644 --- a/crates/xtask-bump-check/src/xtask.rs +++ b/crates/xtask-bump-check/src/xtask.rs @@ -174,6 +174,9 @@ fn bump_check(args: &clap::ArgMatches, gctx: &cargo::util::GlobalContext) -> Car gctx.shell().status("Running", &cmd)?; cmd.exec()?; + // This test does not work for Solana because we are running + // it against a too old version of cargo. + #[cfg(target_os = "solana")] if let Some(referenced_commit) = referenced_commit.as_ref() { let mut cmd = ProcessBuilder::new("cargo"); cmd.arg("semver-checks") @@ -293,8 +296,8 @@ fn beta_and_stable_branch(repo: &git2::Repository) -> CargoResult<[git2::Branch< for branch in repo.branches(Some(git2::BranchType::Remote))? { let (branch, _) = branch?; let name = branch.name()?.unwrap(); - let Some((_, version)) = name.split_once("/rust-") else { - tracing::trace!("branch `{name}` is not in the format of `/rust-`"); + let Some((_, version)) = name.split_once("/solana-") else { + tracing::trace!("branch `{name}` is not in the format of `/solana-`"); continue; }; let Ok(version) = version.parse::() else { From ab11ba6c5754806a8dbd2ae1469d8d57008a8093 Mon Sep 17 00:00:00 2001 From: acheron Date: Thu, 28 Mar 2024 03:45:58 +0100 Subject: [PATCH 6/7] [SOL] Improve error message for MSRV --- src/cargo/ops/cargo_compile/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_compile/mod.rs b/src/cargo/ops/cargo_compile/mod.rs index 68f1df76ba6..49a053f4961 100644 --- a/src/cargo/ops/cargo_compile/mod.rs +++ b/src/cargo/ops/cargo_compile/mod.rs @@ -496,7 +496,10 @@ pub fn create_bcx<'a, 'gctx>( let plural = if incompatible.len() == 1 { "" } else { "s" }; let mut message = format!( - "rustc {rustc_version} is not supported by the following package{plural}:\n" + "rustc {rustc_version} is not supported by the following package{plural}:\n + Note that this is the rustc version that ships with Solana tools and \ + not your system's rustc version. Use `solana-install update` or head \ + over to https://docs.solanalabs.com/cli/install to install a newer version.\n", ); incompatible.sort_by_key(|(unit, _)| (unit.pkg.name(), unit.pkg.version())); for (unit, msrv) in incompatible { From 1c7e140667bc0ed9adaf7ead379bc97038e172fa Mon Sep 17 00:00:00 2001 From: Lucas Steuernagel Date: Mon, 22 Jul 2024 19:44:05 -0300 Subject: [PATCH 7/7] [SOL] Adjustments for Rust 1.79 upgrade --- .github/workflows/main.yml | 56 ++++++++++++------------- src/cargo/core/compiler/standard_lib.rs | 4 +- tests/testsuite/rust_version.rs | 9 ++++ 3 files changed, 39 insertions(+), 30 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d52d173b895..114e2c279db 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,7 +29,7 @@ jobs: - build_std - clippy - msrv - - docs +# - docs - lockfile - resolver - rustfmt @@ -47,7 +47,7 @@ jobs: - build_std - clippy - msrv - - docs +# - docs - lockfile - resolver - rustfmt @@ -72,7 +72,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: rustup update stable && rustup default stable + - run: rustup toolchain install 1.79.0 && rustup default 1.79.0 - run: rustup component add clippy - run: cargo clippy --workspace --all-targets --no-deps -- -D warnings @@ -100,7 +100,7 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - run: rustup toolchain install 1.75.0 && rustup default 1.75.0 + - run: rustup toolchain install 1.78.0 && rustup default 1.78.0 - name: Install cargo-semver-checks run: | mkdir installed-bins @@ -123,7 +123,7 @@ jobs: include: - name: Linux x86_64 stable os: ubuntu-latest - rust: 1.75.0 + rust: 1.79.0 other: i686-unknown-linux-gnu # - name: Linux x86_64 beta # os: ubuntu-latest @@ -143,7 +143,7 @@ jobs: # other: x86_64-apple-ios - name: Windows x86_64 MSVC stable os: windows-latest - rust: 1.75.0-msvc + rust: 1.79.0-msvc other: i686-pc-windows-msvc # - name: Windows x86_64 gnu nightly # runs out of space while trying to link the test suite # os: windows-latest @@ -213,7 +213,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - run: rustup toolchain install 1.75.0 && rustup default 1.75.0 + - run: rustup toolchain install 1.79.0 && rustup default 1.79.0 - run: rustup target add i686-unknown-linux-gnu - run: sudo apt update -y && sudo apt install gcc-multilib libsecret-1-0 libsecret-1-dev -y - run: rustup component add rustfmt || echo "rustfmt not available" @@ -231,27 +231,27 @@ jobs: - run: cargo test -p cargo --test build-std env: CARGO_RUN_BUILD_STD_TESTS: 1 - docs: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: rustup update nightly && rustup default nightly - - run: rustup update stable - - run: rustup component add rust-docs - - run: ci/validate-man.sh - # This requires rustfmt, use stable. - - name: Run semver-check - run: cargo +stable run -p semver-check - - name: Ensure intradoc links are valid - run: cargo doc --workspace --document-private-items --no-deps - env: - RUSTDOCFLAGS: -D warnings - - name: Install mdbook - run: | - mkdir mdbook - curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook - echo `pwd`/mdbook >> $GITHUB_PATH - - run: cd src/doc && mdbook build --dest-dir ../../target/doc +# docs: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v4 +# - run: rustup update nightly && rustup default nightly +# - run: rustup update stable +# - run: rustup component add rust-docs +# - run: ci/validate-man.sh +# # This requires rustfmt, use stable. +# - name: Run semver-check +# run: cargo +stable run -p semver-check +# - name: Ensure intradoc links are valid +# run: cargo doc --workspace --document-private-items --no-deps +# env: +# RUSTDOCFLAGS: -D warnings +# - name: Install mdbook +# run: | +# mkdir mdbook +# curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook +# echo `pwd`/mdbook >> $GITHUB_PATH +# - run: cd src/doc && mdbook build --dest-dir ../../target/doc # - name: Run linkchecker.sh # run: | # cd target diff --git a/src/cargo/core/compiler/standard_lib.rs b/src/cargo/core/compiler/standard_lib.rs index 113b33e4bed..d09a02bd697 100644 --- a/src/cargo/core/compiler/standard_lib.rs +++ b/src/cargo/core/compiler/standard_lib.rs @@ -91,8 +91,8 @@ pub fn resolve_std<'gctx>( "compiler_builtins", None, SourceId::for_git( - &("https://github.com/solana-labs/compiler-builtins".parse()).unwrap(), - GitReference::Tag("solana-tools-v1.40".to_string()), + &("https://github.com/anza-xyz/compiler-builtins".parse()).unwrap(), + GitReference::Tag("solana-tools-v1.43".to_string()), )?, )?); let crates_io_url = crate::sources::CRATES_IO_INDEX.parse().unwrap(); diff --git a/tests/testsuite/rust_version.rs b/tests/testsuite/rust_version.rs index 399779b19fe..646c21a9357 100644 --- a/tests/testsuite/rust_version.rs +++ b/tests/testsuite/rust_version.rs @@ -107,6 +107,10 @@ fn lint_self_incompatible_with_rust_version() { .with_stderr( "\ [ERROR] rustc [..] is not supported by the following package: + + Note that this is the rustc version that ships with Solana tools and \ + not your system's rustc version. Use `solana-install update` or head \ + over to https://docs.solanalabs.com/cli/install to install a newer version. foo@0.0.1 requires rustc 1.9876.0 ", @@ -166,6 +170,11 @@ fn lint_dep_incompatible_with_rust_version() { [DOWNLOADED] too_new_child v0.0.1 (registry `[..]`) [DOWNLOADED] rustc_compatible v0.0.1 (registry `[..]`) [ERROR] rustc [..] is not supported by the following packages: + + Note that this is the rustc version that ships with Solana \ + tools and not your system's rustc version. Use `solana-install \ + update` or head over to https://docs.solanalabs.com/cli/install \ + to install a newer version. too_new_child@0.0.1 requires rustc 1.2345.0 too_new_parent@0.0.1 requires rustc 1.2345.0 Either upgrade rustc or select compatible dependency versions with