Skip to content

Commit 092bed3

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 1d8b05c commit 092bed3

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
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::Config;
@@ -78,14 +78,22 @@ pub fn resolve_std<'cfg>(
7878
"rustc-std-workspace-alloc",
7979
"rustc-std-workspace-std",
8080
];
81-
let patches = to_patch
81+
let mut patches = to_patch
8282
.iter()
8383
.map(|&name| {
8484
let source_path = SourceId::for_path(&src_path.join("library").join(name))?;
8585
let dep = Dependency::parse(name, None, source_path)?;
8686
Ok(dep)
8787
})
8888
.collect::<CargoResult<Vec<_>>>()?;
89+
patches.push(Dependency::parse(
90+
"compiler_builtins",
91+
None,
92+
SourceId::for_git(
93+
&("https://github.com/solana-labs/compiler-builtins".parse()).unwrap(),
94+
GitReference::Tag("solana-tools-v1.36".to_string()),
95+
)?,
96+
)?);
8997
let crates_io_url = crate::sources::CRATES_IO_INDEX.parse().unwrap();
9098
let patch = HashMap::from([(crates_io_url, patches)]);
9199
let members = vec![

src/doc/src/reference/semver.md

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

tests/build-std/main.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ fn basic() {
111111
// Importantly, this should not say [UPDATING]
112112
// There have been multiple bugs where every build triggers and update.
113113
.with_stderr(
114-
"[COMPILING] foo v0.0.1 [..]\n\
114+
"[UPDATING] git repository `https://github.com/solana-labs/compiler-builtins`\n\
115+
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\
116+
Check that the patched package version and available features are compatible\n\
117+
with the dependency requirements. If the patch has a different version from\n\
118+
what is locked in the Cargo.lock file, run `cargo update` to use the new\n\
119+
version. This may also occur with an optional dependency that is not enabled.\n\
120+
[COMPILING] foo v0.0.1 [..]\n\
115121
[FINISHED] dev [..]",
116122
)
117123
.run();

0 commit comments

Comments
 (0)