Skip to content

Commit

Permalink
[SOL] build-std: pull in our compiler-builtins
Browse files Browse the repository at this point in the history
When -Z build-std is used, patch compiler-builtins so that our own fork is
downloaded.

Needed for solana-labs/solana#23465.
  • Loading branch information
alessandrod authored and LucasSte committed Aug 15, 2024
1 parent ffa9cf9 commit 7f60deb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/cargo/core/compiler/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -79,14 +79,22 @@ 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))?;
let dep = Dependency::parse(name, None, source_path)?;
Ok(dep)
})
.collect::<CargoResult<Vec<_>>>()?;
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![
Expand Down
2 changes: 1 addition & 1 deletion src/doc/src/reference/semver.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {}
}
}
Expand Down
10 changes: 8 additions & 2 deletions tests/build-std/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 7f60deb

Please sign in to comment.