Skip to content

Commit e5f0d6f

Browse files
committed
Auto merge of rust-lang#134803 - clubby789:strip-debuginfo, r=Kobzol
Strip debuginfo from rustc-main and rustdoc r? `@Kobzol` Split from rust-lang#134690
2 parents 6d3db55 + e5f6765 commit e5f0d6f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,7 @@ impl Step for Rustc {
984984
true, // Only ship rustc_driver.so and .rmeta files, not all intermediate .rlib files.
985985
);
986986

987+
let target_root_dir = stamp.parent().unwrap();
987988
// When building `librustc_driver.so` (like `libLLVM.so`) on linux, it can contain
988989
// unexpected debuginfo from dependencies, for example from the C++ standard library used in
989990
// our LLVM wrapper. Unless we're explicitly requesting `librustc_driver` to be built with
@@ -992,11 +993,16 @@ impl Step for Rustc {
992993
if builder.config.rust_debuginfo_level_rustc == DebuginfoLevel::None
993994
&& builder.config.rust_debuginfo_level_tools == DebuginfoLevel::None
994995
{
995-
let target_root_dir = stamp.parent().unwrap();
996996
let rustc_driver = target_root_dir.join("librustc_driver.so");
997997
strip_debug(builder, target, &rustc_driver);
998998
}
999999

1000+
if builder.config.rust_debuginfo_level_rustc == DebuginfoLevel::None {
1001+
// Due to LTO a lot of debug info from C++ dependencies such as jemalloc can make it into
1002+
// our final binaries
1003+
strip_debug(builder, target, &target_root_dir.join("rustc-main"));
1004+
}
1005+
10001006
builder.ensure(RustcLink::from_rustc(
10011007
self,
10021008
builder.compiler(compiler.stage, builder.config.build),

src/bootstrap/src/core/build_steps/tool.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use crate::core::build_steps::toolstate::ToolState;
55
use crate::core::build_steps::{compile, llvm};
66
use crate::core::builder;
77
use crate::core::builder::{Builder, Cargo as CargoCommand, RunConfig, ShouldRun, Step};
8-
use crate::core::config::TargetSelection;
8+
use crate::core::config::{DebuginfoLevel, TargetSelection};
99
use crate::utils::channel::GitInfo;
1010
use crate::utils::exec::{BootstrapCommand, command};
1111
use crate::utils::helpers::{add_dylib_path, exe, t};
@@ -671,6 +671,11 @@ impl Step for Rustdoc {
671671

672672
// don't create a stage0-sysroot/bin directory.
673673
if target_compiler.stage > 0 {
674+
if builder.config.rust_debuginfo_level_tools == DebuginfoLevel::None {
675+
// Due to LTO a lot of debug info from C++ dependencies such as jemalloc can make it into
676+
// our final binaries
677+
compile::strip_debug(builder, target, &tool_rustdoc);
678+
}
674679
let bin_rustdoc = bin_rustdoc();
675680
builder.copy_link(&tool_rustdoc, &bin_rustdoc);
676681
bin_rustdoc

src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ ENV RUST_CONFIGURE_ARGS \
8989
--set rust.lto=thin \
9090
--set rust.codegen-units=1
9191

92+
# Note that `rust.debug` is set to true *only* for `opt-dist`
9293
ENV SCRIPT python3 ../x.py build --set rust.debug=true opt-dist && \
9394
./build/$HOSTS/stage0-tools-bin/opt-dist linux-ci -- python3 ../x.py dist \
9495
--host $HOSTS --target $HOSTS \

0 commit comments

Comments
 (0)