From 722f543b58837621ba731e10dfbf1a7d2804431a Mon Sep 17 00:00:00 2001 From: Justus Adam Date: Wed, 6 Sep 2023 15:47:36 -0700 Subject: [PATCH] A much simpler way to set the sysroot. (#34) ## What Changed? Reimplements #32 in a simpler manner. Partially reverts those changes but with the same overall outcome. Also added documentation for what is happening. ## Why Does It Need To? The other version to achieve this needed more changes to `rustc_plugin` that were haphazard and would have been annoying to try and get merged eventually. This way is slightly more hacky but with a *significantly* reduced footprint. Everything is now contained in `dfpp` alone. ## Checklist - [x] Above description has been filled out so that upon quash merge we have a good record of what changed. - [x] New functions, methods, types are documented. Old documentation is updated if necessary - [x] Documentation in Notion has been updated - [x] Tests for new behaviors are provided - [x] New test suites (if any) ave been added to the CI tests (in `.github/workflows/rust.yml`) either as compiler test or integration test. *Or* justification for their omission from CI has been provided in this PR description. --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- src/lib.rs | 11 ++++++++++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a699613bb9..cfcf06d9a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -901,12 +901,12 @@ name = "rustc_plugin" version = "0.6.0-nightly-2023-04-12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79b172d929863ef84797b5592af9b58160f954a484938991f5a6b2829e3c163a" -replace = "rustc_plugin 0.6.0-nightly-2023-04-12 (git+https://github.com/JustusAdam/rustc_plugin?rev=a50617487e129623df946c42d554bd8080765096)" +replace = "rustc_plugin 0.6.0-nightly-2023-04-12 (git+https://github.com/JustusAdam/rustc_plugin?rev=344ecb3bc056c641eaf9d06792571b3d81c8eb33)" [[package]] name = "rustc_plugin" version = "0.6.0-nightly-2023-04-12" -source = "git+https://github.com/JustusAdam/rustc_plugin?rev=a50617487e129623df946c42d554bd8080765096#a50617487e129623df946c42d554bd8080765096" +source = "git+https://github.com/JustusAdam/rustc_plugin?rev=344ecb3bc056c641eaf9d06792571b3d81c8eb33#344ecb3bc056c641eaf9d06792571b3d81c8eb33" dependencies = [ "cargo_metadata", "log", @@ -927,12 +927,12 @@ name = "rustc_utils" version = "0.6.0-nightly-2023-04-12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3935b4a82abe6904308c9273afba6160cf36f20044e720c43839a08519eadfd8" -replace = "rustc_utils 0.6.0-nightly-2023-04-12 (git+https://github.com/JustusAdam/rustc_plugin?rev=a50617487e129623df946c42d554bd8080765096)" +replace = "rustc_utils 0.6.0-nightly-2023-04-12 (git+https://github.com/JustusAdam/rustc_plugin?rev=344ecb3bc056c641eaf9d06792571b3d81c8eb33)" [[package]] name = "rustc_utils" version = "0.6.0-nightly-2023-04-12" -source = "git+https://github.com/JustusAdam/rustc_plugin?rev=a50617487e129623df946c42d554bd8080765096#a50617487e129623df946c42d554bd8080765096" +source = "git+https://github.com/JustusAdam/rustc_plugin?rev=344ecb3bc056c641eaf9d06792571b3d81c8eb33#344ecb3bc056c641eaf9d06792571b3d81c8eb33" dependencies = [ "anyhow", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index bb77517368..4c8b3ab2dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -69,5 +69,5 @@ debug = true [replace] -"rustc_utils:0.6.0-nightly-2023-04-12" = { git = "https://github.com/JustusAdam/rustc_plugin", rev = "a50617487e129623df946c42d554bd8080765096" } -"rustc_plugin:0.6.0-nightly-2023-04-12" = { git = "https://github.com/JustusAdam/rustc_plugin", rev = "a50617487e129623df946c42d554bd8080765096" } \ No newline at end of file +"rustc_utils:0.6.0-nightly-2023-04-12" = { git = "https://github.com/JustusAdam/rustc_plugin", rev = "344ecb3bc056c641eaf9d06792571b3d81c8eb33" } +"rustc_plugin:0.6.0-nightly-2023-04-12" = { git = "https://github.com/JustusAdam/rustc_plugin", rev = "344ecb3bc056c641eaf9d06792571b3d81c8eb33" } \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 860b820701..95e2673d52 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -227,10 +227,19 @@ impl rustc_plugin::RustcPlugin for DfppPlugin { ) -> rustc_plugin::RustcPluginArgs { use clap::Parser; let args = ArgWrapper::parse(); + + // Override the SYSROOT so that it points to the version we were + // compiled against. + // + // This is actually not necessary for *this* binary, but it will bne + // inherited by the calls to `cargo` and `rustc` does by `rustc_plugin` + // and thus those will link against the version of `std` that we + // require. + std::env::set_var("SYSROOT", env!("SYSROOT_PATH")); + rustc_plugin::RustcPluginArgs { args: Args::from_parseable(args.args).unwrap(), filter: CrateFilter::OnlyWorkspace, - env: vec![("SYSROOT".into(), env!("SYSROOT_PATH").into())], } }