Skip to content

Commit 7f60deb

Browse files
alessandrodLucasSte
authored andcommitted
[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 solana-labs/solana#23465.
1 parent ffa9cf9 commit 7f60deb

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

src/cargo/core/compiler/standard_lib.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::core::compiler::{CompileKind, CompileMode, RustcTargetData, Unit};
66
use crate::core::profiles::{Profiles, UnitFor};
77
use crate::core::resolver::features::{CliFeatures, FeaturesFor, ResolvedFeatures};
88
use crate::core::resolver::HasDevUnits;
9-
use crate::core::{Dependency, PackageId, PackageSet, Resolve, SourceId, Workspace};
9+
use crate::core::{Dependency, GitReference, PackageId, PackageSet, Resolve, SourceId, Workspace};
1010
use crate::ops::{self, Packages};
1111
use crate::util::errors::CargoResult;
1212
use crate::GlobalContext;
@@ -79,14 +79,22 @@ pub fn resolve_std<'gctx>(
7979
"rustc-std-workspace-alloc",
8080
"rustc-std-workspace-std",
8181
];
82-
let patches = to_patch
82+
let mut patches = to_patch
8383
.iter()
8484
.map(|&name| {
8585
let source_path = SourceId::for_path(&src_path.join("library").join(name))?;
8686
let dep = Dependency::parse(name, None, source_path)?;
8787
Ok(dep)
8888
})
8989
.collect::<CargoResult<Vec<_>>>()?;
90+
patches.push(Dependency::parse(
91+
"compiler_builtins",
92+
None,
93+
SourceId::for_git(
94+
&("https://github.com/solana-labs/compiler-builtins".parse()).unwrap(),
95+
GitReference::Tag("solana-tools-v1.36".to_string()),
96+
)?,
97+
)?);
9098
let crates_io_url = crate::sources::CRATES_IO_INDEX.parse().unwrap();
9199
let patch = HashMap::from([(crates_io_url, patches)]);
92100
let members = vec![

src/doc/src/reference/semver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ pub enum E {
11301130
fn main() {
11311131
use updated_crate::E;
11321132
let x = E::Variant1;
1133-
match x { // Error: `E::Variant2` not covered
1133+
match x { // Error: non-exhaustive patterns: `E::Variant2` not covered
11341134
E::Variant1 => {}
11351135
}
11361136
}

tests/build-std/main.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,14 @@ fn basic() {
113113
// Importantly, this should not say [UPDATING]
114114
// There have been multiple bugs where every build triggers and update.
115115
.with_stderr(
116-
"[COMPILING] foo v0.0.1 [..]\n\
117-
[FINISHED] `dev` profile [..]",
116+
"[UPDATING] git repository `https://github.com/solana-labs/compiler-builtins`\n\
117+
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\
118+
Check that the patched package version and available features are compatible\n\
119+
with the dependency requirements. If the patch has a different version from\n\
120+
what is locked in the Cargo.lock file, run `cargo update` to use the new\n\
121+
version. This may also occur with an optional dependency that is not enabled.\n\
122+
[COMPILING] foo v0.0.1 [..]\n\
123+
[FINISHED] dev [..]",
118124
)
119125
.run();
120126
p.cargo("run").build_std().target_host().run();

0 commit comments

Comments
 (0)