Skip to content

Commit

Permalink
Add fake dependency roots for all transitive proc-macros (#2749)
Browse files Browse the repository at this point in the history
See the extensive comment for details, but tl;dr: when cross-compiling,
just doing top-level resolves of direct dependencies can miss resolving
platform-specific features for proc-macros which are only used on
certain platforms.
  • Loading branch information
illicitonion authored Aug 1, 2024
1 parent 9510ab4 commit 3b65db8
Show file tree
Hide file tree
Showing 35 changed files with 12,861 additions and 612 deletions.
1 change: 1 addition & 0 deletions crate_universe/private/srcs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,6 @@ CARGO_BAZEL_SRCS = [
Label("//crate_universe:src/utils/starlark/select_set.rs"),
Label("//crate_universe:src/utils/starlark/serialize.rs"),
Label("//crate_universe:src/utils/starlark/target_compatible_with.rs"),
Label("//crate_universe:src/utils/symlink.rs"),
Label("//crate_universe:src/utils/target_triple.rs"),
]
12 changes: 8 additions & 4 deletions crate_universe/src/cli/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,19 @@ pub fn generate(opt: GenerateOptions) -> Result<()> {
}

// Ensure Cargo and Rustc are available for use during generation.
let cargo_bin = Cargo::new(match opt.cargo {
Some(bin) => bin,
None => bail!("The `--cargo` argument is required when generating unpinned content"),
});
let rustc_bin = match &opt.rustc {
Some(bin) => bin,
None => bail!("The `--rustc` argument is required when generating unpinned content"),
};

let cargo_bin = Cargo::new(
match opt.cargo {
Some(bin) => bin,
None => bail!("The `--cargo` argument is required when generating unpinned content"),
},
rustc_bin.clone(),
);

// Ensure a path to a metadata file was provided
let metadata_path = match &opt.metadata {
Some(path) => path,
Expand Down
2 changes: 1 addition & 1 deletion crate_universe/src/cli/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pub fn query(opt: QueryOptions) -> Result<()> {
&lockfile,
&config,
&splicing_manifest,
&Cargo::new(opt.cargo),
&Cargo::new(opt.cargo, opt.rustc.clone()),
&opt.rustc,
)?;

Expand Down
9 changes: 4 additions & 5 deletions crate_universe/src/cli/splice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,25 @@ pub fn splice(opt: SpliceOptions) -> Result<()> {
// Generate a splicer for creating a Cargo workspace manifest
let splicer = Splicer::new(splicing_dir, splicing_manifest)?;

let cargo = Cargo::new(opt.cargo, opt.rustc.clone());

// Splice together the manifest
let manifest_path = splicer
.splice_workspace(&opt.cargo)
.splice_workspace(&cargo)
.context("Failed to splice workspace")?;

let cargo = Cargo::new(opt.cargo);

// Generate a lockfile
let cargo_lockfile = generate_lockfile(
&manifest_path,
&opt.cargo_lockfile,
cargo.clone(),
&opt.rustc,
&opt.repin,
)
.context("Failed to generate lockfile")?;

let config = Config::try_from_path(&opt.config).context("Failed to parse config")?;

let resolver_data = TreeResolver::new(cargo.clone(), opt.rustc.clone())
let resolver_data = TreeResolver::new(cargo.clone())
.generate(
manifest_path.as_path_buf(),
&config.supported_platform_triples,
Expand Down
9 changes: 4 additions & 5 deletions crate_universe/src/cli/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,26 +126,25 @@ pub fn vendor(opt: VendorOptions) -> Result<()> {
let splicer = Splicer::new(PathBuf::from(temp_dir.as_ref()), splicing_manifest)
.context("Failed to create splicer")?;

let cargo = Cargo::new(opt.cargo, opt.rustc.clone());

// Splice together the manifest
let manifest_path = splicer
.splice_workspace(&opt.cargo)
.splice_workspace(&cargo)
.context("Failed to splice workspace")?;

let cargo = Cargo::new(opt.cargo);

// Gather a cargo lockfile
let cargo_lockfile = generate_lockfile(
&manifest_path,
&opt.cargo_lockfile,
cargo.clone(),
&opt.rustc,
&opt.repin,
)?;

// Load the config from disk
let config = Config::try_from_path(&opt.config)?;

let resolver_data = TreeResolver::new(cargo.clone(), opt.rustc.clone()).generate(
let resolver_data = TreeResolver::new(cargo.clone()).generate(
manifest_path.as_path_buf(),
&config.supported_platform_triples,
)?;
Expand Down
Loading

0 comments on commit 3b65db8

Please sign in to comment.