Skip to content

Commit 449328a

Browse files
committed
Auto merge of #53829 - alexcrichton:release-debuginfo, r=<try>
Add rustc SHA to released DWARF debuginfo This commit updates the debuginfo that is encoded in all of our released artifacts by default. Currently it has paths like `/checkout/src/...` but these are a little inconsistent and have changed over time. This commit instead attempts to actually define the file paths in our debuginfo to be consistent between releases. All debuginfo paths are now intended to be `/rustc/$sha` where `$sha` is the git sha of the released compiler. Sub-paths are all paths into the git repo at that `$sha`.
2 parents f8d3459 + cc4c606 commit 449328a

File tree

8 files changed

+36
-1
lines changed

8 files changed

+36
-1
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ matrix:
4040
CI_JOB_NAME=dist-x86_64-apple-alt
4141
os: osx
4242
osx_image: xcode9.3-moar
43-
if: branch = auto
43+
if: branch = auto OR branch = try
4444
4545
# macOS builders. These are placed near the beginning because they are very
4646
# slow to run.

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,10 @@
373373
# Whether to verify generated LLVM IR
374374
#verify-llvm-ir = false
375375

376+
# Map all debuginfo paths for libstd and crates to `/rust/$sha/$crate/...`,
377+
# generally only set for releases
378+
#remap-debuginfo = false
379+
376380
# =============================================================================
377381
# Options for specific targets
378382
#

src/bootstrap/bin/rustc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,10 @@ fn main() {
263263
if env::var_os("RUSTC_FORCE_UNSTABLE").is_some() {
264264
cmd.arg("-Z").arg("force-unstable-if-unmarked");
265265
}
266+
267+
if let Ok(map) = env::var("RUSTC_DEBUGINFO_MAP") {
268+
cmd.arg("--remap-path-prefix").arg(&map);
269+
}
266270
} else {
267271
// Override linker if necessary.
268272
if let Ok(host_linker) = env::var("RUSTC_HOST_LINKER") {

src/bootstrap/builder.rs

+4
Original file line numberDiff line numberDiff line change
@@ -876,6 +876,10 @@ impl<'a> Builder<'a> {
876876
cargo.env("RUSTC_HOST_CRT_STATIC", x.to_string());
877877
}
878878

879+
if let Some(map) = self.build.debuginfo_map() {
880+
cargo.env("RUSTC_DEBUGINFO_MAP", map);
881+
}
882+
879883
// Enable usage of unstable features
880884
cargo.env("RUSTC_BOOTSTRAP", "1");
881885
self.add_rust_test_threads(&mut cargo);

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ pub struct Config {
108108
pub rust_codegen_backends: Vec<Interned<String>>,
109109
pub rust_codegen_backends_dir: String,
110110
pub rust_verify_llvm_ir: bool,
111+
pub rust_remap_debuginfo: bool,
111112

112113
pub build: Interned<String>,
113114
pub hosts: Vec<Interned<String>>,
@@ -319,6 +320,7 @@ struct Rust {
319320
deny_warnings: Option<bool>,
320321
backtrace_on_ice: Option<bool>,
321322
verify_llvm_ir: Option<bool>,
323+
remap_debuginfo: Option<bool>,
322324
}
323325

324326
/// TOML representation of how each build target is configured.
@@ -554,6 +556,7 @@ impl Config {
554556
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
555557
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
556558
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
559+
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
557560

558561
if let Some(ref backends) = rust.codegen_backends {
559562
config.rust_codegen_backends = backends.iter()

src/bootstrap/lib.rs

+15
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,15 @@ impl Build {
737737
self.config.jobs.unwrap_or_else(|| num_cpus::get() as u32)
738738
}
739739

740+
fn debuginfo_map(&self) -> Option<String> {
741+
if !self.config.rust_remap_debuginfo {
742+
return None
743+
}
744+
745+
let sha = self.rust_sha().expect("failed to find rust sha");
746+
Some(format!("{}=/rustc/{}", self.src.display(), sha))
747+
}
748+
740749
/// Returns the path to the C compiler for the target specified.
741750
fn cc(&self, target: Interned<String>) -> &Path {
742751
self.cc[&target].path()
@@ -766,6 +775,12 @@ impl Build {
766775
if &*target == "i686-pc-windows-gnu" {
767776
base.push("-fno-omit-frame-pointer".into());
768777
}
778+
779+
if self.cc(target).ends_with("clang") {
780+
if let Some(map) = self.debuginfo_map() {
781+
base.push(format!("-fdebug-prefix-map={}", map).into());
782+
}
783+
}
769784
base
770785
}
771786

src/ci/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-sccache"
4040
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-manage-submodules"
4141
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-locked-deps"
4242
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-cargo-openssl-static"
43+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
4344

4445
if [ "$DIST_SRC" = "" ]; then
4546
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-dist-src"

src/libstd/build.rs

+4
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ fn build_libbacktrace(target: &str) -> Result<(), ()> {
9797
.file("../libbacktrace/sort.c")
9898
.file("../libbacktrace/state.c");
9999

100+
let any_debug = env::var("RUSTC_DEBUGINFO").unwrap_or(String::new()) == "true" ||
101+
env::var("RUSTC_DEBUGINFO_LINES").unwrap_or(String::new()) == "true";
102+
build.debug(any_debug);
103+
100104
if target.contains("darwin") {
101105
build.file("../libbacktrace/macho.c");
102106
} else if target.contains("windows") {

0 commit comments

Comments
 (0)