Skip to content

Commit da01952

Browse files
committed
Use linker plugin LTO for compiling rustc
1 parent 4b5fcae commit da01952

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/bootstrap/compile.rs

+18-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use serde::Deserialize;
2121
use crate::builder::Cargo;
2222
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
2323
use crate::cache::{Interned, INTERNER};
24-
use crate::config::{LlvmLibunwind, RustcLto, TargetSelection};
24+
use crate::config::{LlvmLibunwind, TargetSelection};
2525
use crate::dist;
2626
use crate::native;
2727
use crate::tool::SourceType;
@@ -702,7 +702,7 @@ impl Step for Rustc {
702702
}
703703

704704
// cfg(bootstrap): remove if condition once the bootstrap compiler supports dylib LTO
705-
if compiler.stage != 0 {
705+
/*if compiler.stage != 0 {
706706
match builder.config.rust_lto {
707707
RustcLto::Thin | RustcLto::Fat => {
708708
// Since using LTO for optimizing dylibs is currently experimental,
@@ -721,6 +721,22 @@ impl Step for Rustc {
721721
}
722722
RustcLto::ThinLocal => { /* Do nothing, this is the default */ }
723723
}
724+
}*/
725+
726+
if compiler.stage == 1 {
727+
// let build_bin = builder.llvm_out(builder.config.build).join("build").join("bin");
728+
// let clang = build_bin.join("clang");
729+
// let clang = PathBuf::from("/projects/personal/llvm-project/build/install/bin/clang");
730+
cargo.rustflag("-Clinker-plugin-lto");
731+
// cargo.rustflag(&format!("-Clinker={}", clang.display()));
732+
// cargo.rustflag("-Clink-arg=-fuse-ld=lld");
733+
734+
// let path = builder.ensure(CrtBeginEnd {
735+
// target
736+
// });
737+
// cargo.rustflag(&format!("-Clink-args=-L{}", path.display()));
738+
// cargo.rustflag(&format!("-Clink-args=-B{}", path.display()));
739+
// cargo.rustflag(&format!("-Clink-args=--gcc-toolchain={}", path.display()));
724740
}
725741

726742
builder.info(&format!(

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

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ RUN curl -LS -o perf.zip https://github.com/rust-lang/rustc-perf/archive/$PERF_C
6363
COPY scripts/sccache.sh /scripts/
6464
RUN sh /scripts/sccache.sh
6565

66+
RUN yum install -y libgcc.x86_64 libgcc.i686
67+
6668
ENV PGO_HOST=x86_64-unknown-linux-gnu
6769

6870
ENV HOSTS=x86_64-unknown-linux-gnu
@@ -77,6 +79,7 @@ ENV RUST_CONFIGURE_ARGS \
7779
--set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \
7880
--set llvm.thin-lto=true \
7981
--set llvm.ninja=false \
82+
--set llvm.clang=true \
8083
--set rust.jemalloc \
8184
--set rust.use-lld=true \
8285
--set rust.lto=thin

0 commit comments

Comments
 (0)