diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-05-05 22:15:42 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2019-05-24 11:49:30 +0300 |
| commit | 28405cabd50181afa6eccfd7f2ee8eb363d35594 (patch) | |
| tree | 16d1e6c2276d4749946e6c83cca74ed5ac0a31ee /src/bootstrap | |
| parent | 46805805abe58c287fa16963f897fd09d5d97467 (diff) | |
| download | rust-28405cabd50181afa6eccfd7f2ee8eb363d35594.tar.gz rust-28405cabd50181afa6eccfd7f2ee8eb363d35594.zip | |
rustbuild: Simplify debuginfo configuration
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/bin/rustc.rs | 9 | ||||
| -rw-r--r-- | src/bootstrap/builder.rs | 25 | ||||
| -rw-r--r-- | src/bootstrap/compile.rs | 7 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 57 | ||||
| -rwxr-xr-x | src/bootstrap/configure.py | 10 | ||||
| -rw-r--r-- | src/bootstrap/test.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/tool.rs | 4 |
7 files changed, 48 insertions, 68 deletions
diff --git a/src/bootstrap/bin/rustc.rs b/src/bootstrap/bin/rustc.rs index 821c37dc235..d51961c65b7 100644 --- a/src/bootstrap/bin/rustc.rs +++ b/src/bootstrap/bin/rustc.rs @@ -102,6 +102,10 @@ fn main() { cmd.env("RUSTC_BREAK_ON_ICE", "1"); + if let Ok(debuginfo_level) = env::var("RUSTC_DEBUGINFO_LEVEL") { + cmd.arg(format!("-Cdebuginfo={}", debuginfo_level)); + } + if let Some(target) = target { // The stage0 compiler has a special sysroot distinct from what we // actually downloaded, so we just always pass the `--sysroot` option. @@ -169,11 +173,6 @@ fn main() { // Set various options from config.toml to configure how we're building // code. - if env::var("RUSTC_DEBUGINFO") == Ok("true".to_string()) { - cmd.arg("-g"); - } else if env::var("RUSTC_DEBUGINFO_LINES") == Ok("true".to_string()) { - cmd.arg("-Cdebuginfo=1"); - } let debug_assertions = match env::var("RUSTC_DEBUG_ASSERTIONS") { Ok(s) => if s == "true" { "y" } else { "n" }, Err(..) => "n", diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 51663e93169..e616b2647a9 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -970,22 +970,15 @@ impl<'a> Builder<'a> { cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler)); } - if mode.is_tool() { - // Tools like cargo and rls don't get debuginfo by default right now, but this can be - // enabled in the config. Adding debuginfo makes them several times larger. - if self.config.rust_debuginfo_tools { - cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()); - cargo.env( - "RUSTC_DEBUGINFO_LINES", - self.config.rust_debuginfo_lines.to_string(), - ); - } - } else { - cargo.env("RUSTC_DEBUGINFO", self.config.rust_debuginfo.to_string()); - cargo.env( - "RUSTC_DEBUGINFO_LINES", - self.config.rust_debuginfo_lines.to_string(), - ); + let debuginfo_level = match mode { + Mode::Rustc | Mode::Codegen => self.config.rust_debuginfo_level_rustc, + Mode::Std | Mode::Test => self.config.rust_debuginfo_level_std, + Mode::ToolBootstrap | Mode::ToolStd | + Mode::ToolTest | Mode::ToolRustc => self.config.rust_debuginfo_level_tools, + }; + cargo.env("RUSTC_DEBUGINFO_LEVEL", debuginfo_level.to_string()); + + if !mode.is_tool() { cargo.env("RUSTC_FORCE_UNSTABLE", "1"); // Currently the compiler depends on crates from crates.io, and diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs index 2da5e1c5902..6c81b6ada2b 100644 --- a/src/bootstrap/compile.rs +++ b/src/bootstrap/compile.rs @@ -586,13 +586,6 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Command) { let libdir_relative = builder.config.libdir_relative().unwrap_or(Path::new("lib")); cargo.env("CFG_LIBDIR_RELATIVE", libdir_relative); - // If we're not building a compiler with debugging information then remove - // these two env vars which would be set otherwise. - if builder.config.rust_debuginfo_only_std { - cargo.env_remove("RUSTC_DEBUGINFO"); - cargo.env_remove("RUSTC_DEBUGINFO_LINES"); - } - if let Some(ref ver_date) = builder.rust_info.commit_date() { cargo.env("CFG_VER_DATE", ver_date); } diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index b1d009a6740..836a1d13c30 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -96,15 +96,14 @@ pub struct Config { pub rust_codegen_units: Option<u32>, pub rust_codegen_units_std: Option<u32>, pub rust_debug_assertions: bool, - pub rust_debuginfo: bool, - pub rust_debuginfo_lines: bool, - pub rust_debuginfo_only_std: bool, - pub rust_debuginfo_tools: bool, + pub rust_debuginfo_level_rustc: u32, + pub rust_debuginfo_level_std: u32, + pub rust_debuginfo_level_tools: u32, + pub rust_debuginfo_level_tests: u32, pub rust_rpath: bool, pub rustc_parallel: bool, pub rustc_default_linker: Option<String>, pub rust_optimize_tests: bool, - pub rust_debuginfo_tests: bool, pub rust_dist_src: bool, pub rust_codegen_backends: Vec<Interned<String>>, pub rust_codegen_backends_dir: String, @@ -300,10 +299,11 @@ struct Rust { codegen_units: Option<u32>, codegen_units_std: Option<u32>, debug_assertions: Option<bool>, - debuginfo: Option<bool>, - debuginfo_lines: Option<bool>, - debuginfo_only_std: Option<bool>, - debuginfo_tools: Option<bool>, + debuginfo_level: Option<u32>, + debuginfo_level_rustc: Option<u32>, + debuginfo_level_std: Option<u32>, + debuginfo_level_tools: Option<u32>, + debuginfo_level_tests: Option<u32>, parallel_compiler: Option<bool>, backtrace: Option<bool>, default_linker: Option<String>, @@ -311,7 +311,6 @@ struct Rust { musl_root: Option<String>, rpath: Option<bool>, optimize_tests: Option<bool>, - debuginfo_tests: Option<bool>, codegen_tests: Option<bool>, ignore_git: Option<bool>, debug: Option<bool>, @@ -495,12 +494,13 @@ impl Config { // Store off these values as options because if they're not provided // we'll infer default values for them later let mut llvm_assertions = None; - let mut debuginfo_lines = None; - let mut debuginfo_only_std = None; - let mut debuginfo_tools = None; let mut debug = None; - let mut debuginfo = None; let mut debug_assertions = None; + let mut debuginfo_level = None; + let mut debuginfo_level_rustc = None; + let mut debuginfo_level_std = None; + let mut debuginfo_level_tools = None; + let mut debuginfo_level_tests = None; let mut optimize = None; let mut ignore_git = None; @@ -540,14 +540,14 @@ impl Config { if let Some(ref rust) = toml.rust { debug = rust.debug; debug_assertions = rust.debug_assertions; - debuginfo = rust.debuginfo; - debuginfo_lines = rust.debuginfo_lines; - debuginfo_only_std = rust.debuginfo_only_std; - debuginfo_tools = rust.debuginfo_tools; + debuginfo_level = rust.debuginfo_level; + debuginfo_level_rustc = rust.debuginfo_level_rustc; + debuginfo_level_std = rust.debuginfo_level_std; + debuginfo_level_tools = rust.debuginfo_level_tools; + debuginfo_level_tests = rust.debuginfo_level_tests; optimize = rust.optimize; ignore_git = rust.ignore_git; set(&mut config.rust_optimize_tests, rust.optimize_tests); - set(&mut config.rust_debuginfo_tests, rust.debuginfo_tests); set(&mut config.codegen_tests, rust.codegen_tests); set(&mut config.rust_rpath, rust.rpath); set(&mut config.jemalloc, rust.jemalloc); @@ -639,18 +639,19 @@ impl Config { let default = true; config.rust_optimize = optimize.unwrap_or(default); - let default = match &config.channel[..] { - "stable" | "beta" | "nightly" => true, - _ => false, - }; - config.rust_debuginfo_lines = debuginfo_lines.unwrap_or(default); - config.rust_debuginfo_only_std = debuginfo_only_std.unwrap_or(default); - config.rust_debuginfo_tools = debuginfo_tools.unwrap_or(false); - let default = debug == Some(true); - config.rust_debuginfo = debuginfo.unwrap_or(default); config.rust_debug_assertions = debug_assertions.unwrap_or(default); + let with_defaults = |debuginfo_level_specific: Option<u32>| { + debuginfo_level_specific + .or(debuginfo_level) + .unwrap_or(if debug == Some(true) { 2 } else { 0 }) + }; + config.rust_debuginfo_level_rustc = with_defaults(debuginfo_level_rustc); + config.rust_debuginfo_level_std = with_defaults(debuginfo_level_std); + config.rust_debuginfo_level_tools = with_defaults(debuginfo_level_tools); + config.rust_debuginfo_level_tests = with_defaults(debuginfo_level_tests); + let default = config.channel == "dev"; config.ignore_git = ignore_git.unwrap_or(default); diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py index ade8afee7c1..53d3dbf60d1 100755 --- a/src/bootstrap/configure.py +++ b/src/bootstrap/configure.py @@ -37,7 +37,6 @@ o("compiler-docs", "build.compiler-docs", "build compiler documentation") o("optimize-tests", "rust.optimize-tests", "build tests with optimizations") o("parallel-compiler", "rust.parallel-compiler", "build a multi-threaded rustc") o("test-miri", "rust.test-miri", "run miri's test suite") -o("debuginfo-tests", "rust.debuginfo-tests", "build tests with debugger metadata") o("verbose-tests", "rust.verbose-tests", "enable verbose output when running tests") o("ccache", "llvm.ccache", "invoke gcc/clang via ccache to reuse object files between builds") o("sccache", None, "invoke gcc/clang via sccache to reuse object files between builds") @@ -77,10 +76,11 @@ o("optimize-llvm", "llvm.optimize", "build optimized LLVM") o("llvm-assertions", "llvm.assertions", "build LLVM with assertions") o("debug-assertions", "rust.debug-assertions", "build with debugging assertions") o("llvm-release-debuginfo", "llvm.release-debuginfo", "build LLVM with debugger metadata") -o("debuginfo", "rust.debuginfo", "build with debugger metadata") -o("debuginfo-lines", "rust.debuginfo-lines", "build with line number debugger metadata") -o("debuginfo-only-std", "rust.debuginfo-only-std", "build only libstd with debugging information") -o("debuginfo-tools", "rust.debuginfo-tools", "build extended tools with debugging information") +o("debuginfo-level", "rust.debuginfo-level", "debuginfo level for Rust code") +o("debuginfo-level-rustc", "rust.debuginfo-level-rustc", "debuginfo level for the compiler") +o("debuginfo-level-std", "rust.debuginfo-level-std", "debuginfo level for the standard library") +o("debuginfo-level-tools", "rust.debuginfo-level-tools", "debuginfo level for the tools") +o("debuginfo-level-tests", "rust.debuginfo-level-tests", "debuginfo level for the test suites run with compiletest") v("save-toolstates", "rust.save-toolstates", "save build and test status of external tools into this file") v("prefix", "install.prefix", "set installation prefix") diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs index 25d45fa5f40..05b3ce6bc89 100644 --- a/src/bootstrap/test.rs +++ b/src/bootstrap/test.rs @@ -1078,10 +1078,8 @@ impl Step for Compiletest { if builder.config.rust_optimize_tests { flags.push("-O".to_string()); } - if builder.config.rust_debuginfo_tests { - flags.push("-g".to_string()); - } } + flags.push(format!("-Cdebuginfo={}", builder.config.rust_debuginfo_level_tests)); flags.push("-Zunstable-options".to_string()); flags.push(builder.config.cmd.rustc_args().join(" ")); diff --git a/src/bootstrap/tool.rs b/src/bootstrap/tool.rs index edcd68d010e..d723f286fa8 100644 --- a/src/bootstrap/tool.rs +++ b/src/bootstrap/tool.rs @@ -485,10 +485,6 @@ impl Step for Rustdoc { &[], ); - // Most tools don't get debuginfo, but rustdoc should. - cargo.env("RUSTC_DEBUGINFO", builder.config.rust_debuginfo.to_string()) - .env("RUSTC_DEBUGINFO_LINES", builder.config.rust_debuginfo_lines.to_string()); - let _folder = builder.fold_output(|| format!("stage{}-rustdoc", target_compiler.stage)); builder.info(&format!("Building rustdoc for stage{} ({})", target_compiler.stage, target_compiler.host)); |
