Skip to content

Commit 4f921d7

Browse files
committed
Auto merge of #54168 - kennytm:rollup, r=kennytm
Rollup of 11 pull requests Successful merges: - #53371 (Do not emit E0277 on incorrect tuple destructured binding) - #53829 (Add rustc SHA to released DWARF debuginfo) - #53950 (Allow for opting out of ThinLTO and clean up LTO related cli flag handling.) - #53976 (Replace unwrap calls in example by expect) - #54070 (Add Error::description soft-deprecation to RELEASES) - #54076 (miri loop detector hashing) - #54119 (Add some unit tests for find_best_match_for_name) - #54147 (Add a test that tries to modify static memory at compile-time) - #54150 (Updated 1.29 release notes with --document-private-items flag) - #54163 (Update stage 0 to latest beta) - #54170 (COMPILER_TESTS.md has been moved)
2 parents 90d36fb + 07dc4b3 commit 4f921d7

38 files changed

+398
-113
lines changed

CONTRIBUTING.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,7 @@ will run all the tests on every platform we support. If it all works out,
368368
[merge-queue]: https://buildbot2.rust-lang.org/homu/queue/rust
369369

370370
Speaking of tests, Rust has a comprehensive test suite. More information about
371-
it can be found
372-
[here](https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md).
371+
it can be found [here][rctd].
373372

374373
### External Dependencies
375374
[external-dependencies]: #external-dependencies
@@ -654,5 +653,5 @@ are:
654653
[rustforge]: https://forge.rust-lang.org/
655654
[tlgba]: http://tomlee.co/2014/04/a-more-detailed-tour-of-the-rust-compiler/
656655
[ro]: http://www.rustaceans.org/
657-
[rctd]: ./src/test/COMPILER_TESTS.md
656+
[rctd]: https://rust-lang-nursery.github.io/rustc-guide/tests/intro.html
658657
[cheatsheet]: https://buildbot2.rust-lang.org/homu/

RELEASES.md

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ Cargo
3131
using `--target`][cargo/5614]
3232
- [Added the `cargo-fix` subcommand to automatically move project code from
3333
2015 edition to 2018.][cargo/5723]
34+
- [`cargo doc` can now optionally document private types using the
35+
`--document-private-items` flag.][cargo/5543]
3436

3537
Misc
3638
----
@@ -68,6 +70,7 @@ Compatibility Notes
6870
[51178]: https://github.com/rust-lang/rust/pull/51178/
6971
[51122]: https://github.com/rust-lang/rust/pull/51122
7072
[50494]: https://github.com/rust-lang/rust/pull/50494/
73+
[cargo/5543]: https://github.com/rust-lang/cargo/pull/5543
7174
[cargo/5614]: https://github.com/rust-lang/cargo/pull/5614/
7275
[cargo/5723]: https://github.com/rust-lang/cargo/pull/5723/
7376
[cargo/5831]: https://github.com/rust-lang/cargo/pull/5831/
@@ -370,6 +373,8 @@ Compatibility Notes
370373
- [The maximum number for `repr(align(N))` is now 2²⁹.][50378] Previously you
371374
could enter higher numbers but they were not supported by LLVM. Up to 512MB
372375
alignment should cover all use cases.
376+
- The `.description()` method on the `std::error::Error` trait
377+
[has been soft-deprecated][50163]. It is no longer required to implement it.
373378

374379
[48553]: https://github.com/rust-lang/rust/pull/48553/
375380
[48851]: https://github.com/rust-lang/rust/pull/48851/
@@ -383,6 +388,7 @@ Compatibility Notes
383388
[49719]: https://github.com/rust-lang/rust/pull/49719/
384389
[49896]: https://github.com/rust-lang/rust/pull/49896/
385390
[49968]: https://github.com/rust-lang/rust/pull/49968/
391+
[50163]: https://github.com/rust-lang/rust/pull/50163
386392
[50177]: https://github.com/rust-lang/rust/pull/50177/
387393
[50378]: https://github.com/rust-lang/rust/pull/50378/
388394
[50398]: https://github.com/rust-lang/rust/pull/50398/

config.toml.example

+4
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,10 @@
377377
# Whether to verify generated LLVM IR
378378
#verify-llvm-ir = false
379379

380+
# Map all debuginfo paths for libstd and crates to `/rust/$sha/$crate/...`,
381+
# generally only set for releases
382+
#remap-debuginfo = false
383+
380384
# =============================================================================
381385
# Options for specific targets
382386
#

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use native;
3232
use test;
3333
use tool;
3434
use util::{add_lib_path, exe, libdir};
35-
use {Build, DocTests, Mode};
35+
use {Build, DocTests, Mode, GitRepo};
3636

3737
pub use Compiler;
3838

@@ -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(GitRepo::Rustc) {
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);
@@ -964,7 +968,7 @@ impl<'a> Builder<'a> {
964968
let cc = ccacheify(&self.cc(target));
965969
cargo.env(format!("CC_{}", target), &cc).env("CC", &cc);
966970

967-
let cflags = self.cflags(target).join(" ");
971+
let cflags = self.cflags(target, GitRepo::Rustc).join(" ");
968972
cargo
969973
.env(format!("CFLAGS_{}", target), cflags.clone())
970974
.env("CFLAGS", cflags.clone());

src/bootstrap/cc_detect.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ use std::process::Command;
3939
use build_helper::output;
4040
use cc;
4141

42-
use Build;
42+
use {Build, GitRepo};
4343
use config::Target;
4444
use cache::Interned;
4545

@@ -107,7 +107,7 @@ pub fn find(build: &mut Build) {
107107

108108
build.cc.insert(target, compiler);
109109
build.verbose(&format!("CC_{} = {:?}", &target, build.cc(target)));
110-
build.verbose(&format!("CFLAGS_{} = {:?}", &target, build.cflags(target)));
110+
build.verbose(&format!("CFLAGS_{} = {:?}", &target, build.cflags(target, GitRepo::Rustc)));
111111
if let Some(ar) = ar {
112112
build.verbose(&format!("AR_{} = {:?}", &target, ar));
113113
build.ar.insert(target, ar);

src/bootstrap/compile.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use filetime::FileTime;
3030
use serde_json;
3131

3232
use util::{exe, libdir, is_dylib, CiEnv};
33-
use {Compiler, Mode};
33+
use {Compiler, Mode, GitRepo};
3434
use native;
3535
use tool;
3636

@@ -895,7 +895,7 @@ pub fn compiler_file(builder: &Builder,
895895
target: Interned<String>,
896896
file: &str) -> PathBuf {
897897
let mut cmd = Command::new(compiler);
898-
cmd.args(builder.cflags(target));
898+
cmd.args(builder.cflags(target, GitRepo::Rustc));
899899
cmd.arg(format!("-print-file-name={}", file));
900900
let out = output(&mut cmd);
901901
PathBuf::from(out.trim())

src/bootstrap/config.rs

+3
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ pub struct Config {
109109
pub rust_codegen_backends: Vec<Interned<String>>,
110110
pub rust_codegen_backends_dir: String,
111111
pub rust_verify_llvm_ir: bool,
112+
pub rust_remap_debuginfo: bool,
112113

113114
pub build: Interned<String>,
114115
pub hosts: Vec<Interned<String>>,
@@ -321,6 +322,7 @@ struct Rust {
321322
deny_warnings: Option<bool>,
322323
backtrace_on_ice: Option<bool>,
323324
verify_llvm_ir: Option<bool>,
325+
remap_debuginfo: Option<bool>,
324326
}
325327

326328
/// TOML representation of how each build target is configured.
@@ -557,6 +559,7 @@ impl Config {
557559
set(&mut config.deny_warnings, rust.deny_warnings.or(flags.warnings));
558560
set(&mut config.backtrace_on_ice, rust.backtrace_on_ice);
559561
set(&mut config.rust_verify_llvm_ir, rust.verify_llvm_ir);
562+
set(&mut config.rust_remap_debuginfo, rust.remap_debuginfo);
560563

561564
if let Some(ref backends) = rust.codegen_backends {
562565
config.rust_codegen_backends = backends.iter()

src/bootstrap/lib.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ pub enum DocTests {
237237
Only,
238238
}
239239

240+
pub enum GitRepo {
241+
Rustc,
242+
Llvm,
243+
}
244+
240245
/// Global configuration for the build system.
241246
///
242247
/// This structure transitively contains all configuration for the build system.
@@ -738,14 +743,29 @@ impl Build {
738743
self.config.jobs.unwrap_or_else(|| num_cpus::get() as u32)
739744
}
740745

746+
fn debuginfo_map(&self, which: GitRepo) -> Option<String> {
747+
if !self.config.rust_remap_debuginfo {
748+
return None
749+
}
750+
751+
let path = match which {
752+
GitRepo::Rustc => {
753+
let sha = self.rust_info.sha().expect("failed to find sha");
754+
format!("/rustc/{}", sha)
755+
}
756+
GitRepo::Llvm => format!("/rustc/llvm"),
757+
};
758+
Some(format!("{}={}", self.src.display(), path))
759+
}
760+
741761
/// Returns the path to the C compiler for the target specified.
742762
fn cc(&self, target: Interned<String>) -> &Path {
743763
self.cc[&target].path()
744764
}
745765

746766
/// Returns a list of flags to pass to the C compiler for the target
747767
/// specified.
748-
fn cflags(&self, target: Interned<String>) -> Vec<String> {
768+
fn cflags(&self, target: Interned<String>, which: GitRepo) -> Vec<String> {
749769
// Filter out -O and /O (the optimization flags) that we picked up from
750770
// cc-rs because the build scripts will determine that for themselves.
751771
let mut base = self.cc[&target].args().iter()
@@ -767,6 +787,16 @@ impl Build {
767787
if &*target == "i686-pc-windows-gnu" {
768788
base.push("-fno-omit-frame-pointer".into());
769789
}
790+
791+
if let Some(map) = self.debuginfo_map(which) {
792+
let cc = self.cc(target);
793+
if cc.ends_with("clang") || cc.ends_with("gcc") {
794+
base.push(format!("-fdebug-prefix-map={}", map).into());
795+
} else if cc.ends_with("clang-cl.exe") {
796+
base.push("-Xclang".into());
797+
base.push(format!("-fdebug-prefix-map={}", map).into());
798+
}
799+
}
770800
base
771801
}
772802

src/bootstrap/native.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ use util::{self, exe};
3333
use build_helper::up_to_date;
3434
use builder::{Builder, RunConfig, ShouldRun, Step};
3535
use cache::Interned;
36+
use GitRepo;
3637

3738
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
3839
pub struct Llvm {
@@ -373,8 +374,8 @@ fn configure_cmake(builder: &Builder,
373374
}
374375

375376
cfg.build_arg("-j").build_arg(builder.jobs().to_string());
376-
cfg.define("CMAKE_C_FLAGS", builder.cflags(target).join(" "));
377-
let mut cxxflags = builder.cflags(target).join(" ");
377+
cfg.define("CMAKE_C_FLAGS", builder.cflags(target, GitRepo::Llvm).join(" "));
378+
let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" ");
378379
if building_dist_binaries {
379380
if builder.config.llvm_static_stdcpp && !target.contains("windows") {
380381
cxxflags.push_str(" -static-libstdc++");
@@ -680,7 +681,7 @@ impl Step for Openssl {
680681
};
681682
configure.arg(os);
682683
configure.env("CC", builder.cc(target));
683-
for flag in builder.cflags(target) {
684+
for flag in builder.cflags(target, GitRepo::Rustc) {
684685
configure.arg(flag);
685686
}
686687
// There is no specific os target for android aarch64 or x86_64,

src/bootstrap/test.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ use tool::{self, Tool, SourceType};
3434
use toolstate::ToolState;
3535
use util::{self, dylib_path, dylib_path_var};
3636
use Crate as CargoCrate;
37-
use {DocTests, Mode};
37+
use {DocTests, Mode, GitRepo};
3838

3939
const ADB_TEST_DIR: &str = "/data/tmp/work";
4040

@@ -1142,7 +1142,7 @@ impl Step for Compiletest {
11421142
.arg("--cxx")
11431143
.arg(builder.cxx(target).unwrap())
11441144
.arg("--cflags")
1145-
.arg(builder.cflags(target).join(" "))
1145+
.arg(builder.cflags(target, GitRepo::Rustc).join(" "))
11461146
.arg("--llvm-components")
11471147
.arg(llvm_components.trim())
11481148
.arg("--llvm-cxxflags")

src/ci/run.sh

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export RUST_RELEASE_CHANNEL=nightly
5555
if [ "$DEPLOY$DEPLOY_ALT" != "" ]; then
5656
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --release-channel=$RUST_RELEASE_CHANNEL"
5757
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --enable-llvm-static-stdcpp"
58+
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set rust.remap-debuginfo"
5859

5960
if [ "$NO_LLVM_ASSERTIONS" = "1" ]; then
6061
RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --disable-llvm-assertions"

0 commit comments

Comments
 (0)