-
-
Notifications
You must be signed in to change notification settings - Fork 15.6k
bootstrap: leverage cargo trim-paths #161049
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
9636f9c
6085af6
a82d5a6
e751b8d
4e1f3c7
8d43ad3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| Change this file to make users of the `download-ci-llvm` configuration download | ||
| a new version of LLVM from CI, even if the LLVM submodule hasn鈥檛 changed. | ||
|
|
||
| Last change is for: https://github.com/rust-lang/rust/pull/161603 | ||
| Last change is for: https://github.com/rust-lang/rust/pull/161049 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,7 @@ use crate::core::config::toml::pgo::PgoConfig; | |
| use crate::core::config::{ | ||
| CompressDebuginfo, Config, DryRun, RustcLto, SplitDebuginfo, TargetSelection, | ||
| }; | ||
| use crate::core::session::{CLang, GitRepo, Mode, RemapScheme}; | ||
| use crate::core::session::{CLang, Mode, RemapScheme}; | ||
| use crate::utils::build_stamp; | ||
| use crate::utils::exec::{BootstrapCommand, command}; | ||
| use crate::utils::helpers::{self, LldThreads, check_cfg_arg, envify, linker_flags, t}; | ||
|
|
@@ -484,8 +484,7 @@ impl Cargo { | |
|
|
||
| // Extend `CFLAGS_$TARGET` with our extra flags. | ||
| let env = format!("CFLAGS_{triple_underscored}"); | ||
| let mut cflags = | ||
| builder.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::C).join(" "); | ||
| let mut cflags = builder.cc_unhandled_cflags(target, CLang::C).join(" "); | ||
| if let Some(lto_cflag) = lto_cflag { | ||
| cflags.push(' '); | ||
| cflags.push_str(lto_cflag); | ||
|
|
@@ -509,8 +508,7 @@ impl Cargo { | |
|
|
||
| // Extend `CXXFLAGS_$TARGET` with our extra flags. | ||
| let env = format!("CXXFLAGS_{triple_underscored}"); | ||
| let mut cxxflags = | ||
| builder.cc_unhandled_cflags(target, GitRepo::Rustc, CLang::Cxx).join(" "); | ||
| let mut cxxflags = builder.cc_unhandled_cflags(target, CLang::Cxx).join(" "); | ||
| if let Some(lto_cflag) = lto_cflag { | ||
| cxxflags.push(' '); | ||
| cxxflags.push_str(lto_cflag); | ||
|
|
@@ -1158,90 +1156,39 @@ impl Builder<'_> { | |
| // | ||
| // Keep this scheme in sync with `rustc_metadata::rmeta::decoder`'s | ||
| // `try_to_translate_virtual_to_real`. | ||
| // | ||
| // `RUSTC_DEBUGINFO_MAP` is used to pass through to the underlying rustc | ||
| // `--remap-path-prefix`. | ||
| let trim_paths = |cargo: &mut BootstrapCommand, ws_remap: &str| { | ||
| cargo.arg("-Ztrim-paths"); | ||
| cargo.arg("--config").arg("profile.release.trim-paths='all'"); | ||
| cargo.arg("--config").arg("profile.dev.trim-paths='all'"); | ||
| // This is an internal contract with cargo. | ||
| // bootstrap needs workspace sources remapped to `/rust{c,-dev}/<sha>` instead of `.` | ||
| // See <https://github.com/rust-lang/cargo/issues/17309>. | ||
| cargo.env("__CARGO_RUSTC_BOOTSTRAP_WS_REMAP", ws_remap); | ||
|
Kobzol marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| match mode { | ||
| Mode::Rustc | Mode::Codegen => { | ||
| if let Some(ref map_to) = | ||
| self.sess.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler) | ||
| { | ||
| if let Some(ref map_to) = self.sess.debuginfo_map_to(RemapScheme::NonCompiler) { | ||
| // Tell the compiler which prefix was used for remapping the standard library | ||
| cargo.env("CFG_VIRTUAL_RUST_SOURCE_BASE_DIR", map_to); | ||
| } | ||
|
|
||
| if let Some(ref map_to) = | ||
| self.sess.debuginfo_map_to(GitRepo::Rustc, RemapScheme::Compiler) | ||
| { | ||
| if let Some(ref map_to) = self.sess.debuginfo_map_to(RemapScheme::Compiler) { | ||
| // Tell the compiler which prefix was used for remapping the compiler it-self | ||
| cargo.env("CFG_VIRTUAL_RUSTC_DEV_SOURCE_BASE_DIR", map_to); | ||
|
|
||
| // When building compiler sources, we want to apply the compiler remap scheme. | ||
| let map = [ | ||
| // Cargo use relative paths for workspace members, so let's remap those. | ||
| format!("compiler/={map_to}/compiler"), | ||
| // rustc creates absolute paths (in part bc of the `rust-src` unremap | ||
| // and for working directory) so let's remap the build directory as well. | ||
| format!("{}={map_to}", self.sess.src.display()), | ||
| // remap OUT_DIR so they don't leak into artifacts. | ||
| format!("{}={map_to}/out", self.sess.out.display()), | ||
| // on windows, rustc may use forward slashes internally | ||
| #[cfg(windows)] | ||
| format!( | ||
| "{}={map_to}\\out", | ||
| self.sess.out.display().to_string().replace('/', "\\") | ||
| ), | ||
| ] | ||
| .join("\t"); | ||
| cargo.env("RUSTC_DEBUGINFO_MAP", map); | ||
| trim_paths(&mut cargo, map_to); | ||
| } | ||
| } | ||
| Mode::Std | ||
| | Mode::ToolBootstrap | ||
| | Mode::ToolRustcPrivate | ||
| | Mode::ToolStd | ||
| | Mode::ToolTarget => { | ||
| if let Some(ref map_to) = | ||
| self.sess.debuginfo_map_to(GitRepo::Rustc, RemapScheme::NonCompiler) | ||
| { | ||
| // When building the standard library sources, we want to apply the std remap scheme. | ||
| let map = [ | ||
| // Cargo use relative paths for workspace members, so let's remap those. | ||
| format!("library/={map_to}/library"), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like this remapping isn't done anymore.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, we forgot
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the same is probably also not done for
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Posted rust-lang/cargo#17366
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should be fixed. See the latest try build. |
||
| // rustc creates absolute paths (in part bc of the `rust-src` unremap | ||
| // and for working directory) so let's remap the build directory as well. | ||
| format!("{}={map_to}", self.sess.src.display()), | ||
| // remap OUT_DIR so they don't leak into artifacts. | ||
| format!("{}={map_to}/out", self.sess.out.display()), | ||
| // on windows, rustc may use forward slashes internally | ||
| #[cfg(windows)] | ||
| format!( | ||
| "{}={map_to}\\out", | ||
| self.sess.out.display().to_string().replace('/', "\\") | ||
| ), | ||
| ] | ||
| .join("\t"); | ||
| cargo.env("RUSTC_DEBUGINFO_MAP", map); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if self.config.rust_remap_debuginfo { | ||
| let mut env_var = OsString::new(); | ||
| if let Some(vendor) = self.sess.vendored_crates_path() { | ||
| env_var.push(vendor); | ||
| env_var.push("=/rust/deps"); | ||
| } else { | ||
| let registry_src = t!(home::cargo_home()).join("registry").join("src"); | ||
| for entry in t!(std::fs::read_dir(registry_src)) { | ||
| if !env_var.is_empty() { | ||
| env_var.push("\t"); | ||
| } | ||
| env_var.push(t!(entry).path()); | ||
| env_var.push("=/rust/deps"); | ||
| if let Some(ref map_to) = self.sess.debuginfo_map_to(RemapScheme::NonCompiler) { | ||
| trim_paths(&mut cargo, map_to); | ||
| } | ||
| } | ||
| cargo.env("RUSTC_CARGO_REGISTRY_SRC_TO_REMAP", env_var); | ||
| } | ||
|
|
||
| // Enable usage of unstable features | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should have a test at some point for this as well. Not sure if we even have a CI builder that sets it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is also a future item?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW I hope this doesn't regress.
(it is seen as a pure refactor for LLVM I believe)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, let's not try to fix the world with this PR.