Skip to content

Commit

Permalink
Auto merge of rust-lang#107651 - Kobzol:ci-single-cgu, r=<try>
Browse files Browse the repository at this point in the history
[WIP] Build `rustc` with a single CGU on x64 Linux

Follow-up attempt to rust-lang#87650. I wonder if anything changed with the addition of LTO.

I also enabled a single CGU only for the actual build of the compiler on CI, so that we can better see the perf. effects on the bootstrap benchmark.
  • Loading branch information
bors committed Sep 15, 2023
2 parents e7f9f48 + dba68fa commit a3b1fd2
Show file tree
Hide file tree
Showing 27 changed files with 29 additions and 40 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,6 @@ jobs:
try:
name: "try - ${{ matrix.name }}"
env:
DIST_TRY_BUILD: 1
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
HEAD_SHA: "${{ github.event.pull_request.head.sha || github.sha }}"
Expand Down
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/17.0-2023-07-29
branch = rustc/16.0-2023-06-05
shallow = true
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,17 +146,6 @@ pub unsafe fn create_module<'ll>(
target_data_layout = target_data_layout.replace("-n32:64-", "-n64-");
}
}
if llvm_version < (17, 0, 0) {
if sess.target.arch.starts_with("powerpc") {
// LLVM 17 specifies function pointer alignment for ppc:
// https://reviews.llvm.org/D147016
target_data_layout = target_data_layout
.replace("-Fn32", "")
.replace("-Fi32", "")
.replace("-Fn64", "")
.replace("-Fi64", "");
}
}

// Ensure the data-layout values hardcoded remain the defaults.
if sess.target.is_builtin {
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
#if LLVM_VERSION_GE(17, 0)
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getAllProcessorDescriptions();
#elif defined(LLVM_RUSTLLVM)
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
#else
Buf << "Full target CPU help is not supported by this LLVM version.\n\n";
SubtargetSubTypeKV TargetCPUKV = { TargetCPU, {{}}, {{}} };
Expand Down Expand Up @@ -1199,7 +1201,7 @@ struct LLVMRustThinLTOData {

// Not 100% sure what these are, but they impact what's internalized and
// what's inlined across modules, I believe.
#if LLVM_VERSION_GE(18, 0)
#if LLVM_VERSION_GE(17, 0)
DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists;
DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists;
DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc64_ibm_aix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-ibm-aix".into(),
pointer_width: 64,
data_layout: "E-m:a-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:a-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: base,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-freebsd".into(),
pointer_width: 64,
data_layout: "E-m:e-Fn32-i64:64-n32:64".into(),
data_layout: "E-m:e-i64:64-n32:64".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-linux-gnu".into(),
pointer_width: 64,
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-linux-musl".into(),
pointer_width: 64,
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-openbsd".into(),
pointer_width: 64,
data_layout: "E-m:e-Fn32-i64:64-n32:64".into(),
data_layout: "E-m:e-i64:64-n32:64".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc64_wrs_vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64-unknown-linux-gnu".into(),
pointer_width: 64,
data_layout: "E-m:e-Fi64-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "E-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { endian: Endian::Big, ..base },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64le-unknown-freebsd".into(),
pointer_width: 64,
data_layout: "e-m:e-Fn32-i64:64-n32:64".into(),
data_layout: "e-m:e-i64:64-n32:64".into(),
arch: "powerpc64".into(),
options: TargetOptions { mcount: "_mcount".into(), ..base },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64le-unknown-linux-gnu".into(),
pointer_width: 64,
data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { mcount: "_mcount".into(), ..base },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc64le-unknown-linux-musl".into(),
pointer_width: 64,
data_layout: "e-m:e-Fn32-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
data_layout: "e-m:e-i64:64-n32:64-S128-v256:256:256-v512:512:512".into(),
arch: "powerpc64".into(),
options: TargetOptions { mcount: "_mcount".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_unknown_freebsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-freebsd13.0".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions {
endian: Endian::Big,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-gnu".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-gnuspe".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions {
abi: "spe".into(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-musl".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, mcount: "_mcount".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_unknown_netbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-netbsd".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, mcount: "__mcount".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_unknown_openbsd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-openbsd".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
arch: "powerpc".into(),
options: base,
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_wrs_vxworks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-gnu".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions { endian: Endian::Big, features: "+secure-plt".into(), ..base },
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_target/src/spec/powerpc_wrs_vxworks_spe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub fn target() -> Target {
Target {
llvm_target: "powerpc-unknown-linux-gnuspe".into(),
pointer_width: 32,
data_layout: "E-m:e-p:32:32-Fn32-i64:64-n32".into(),
data_layout: "E-m:e-p:32:32-i64:64-n32".into(),
arch: "powerpc".into(),
options: TargetOptions {
abi: "spe".into(),
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,8 +1160,8 @@ impl Step for CrtBeginEnd {
return out_dir;
}

let crtbegin_src = builder.src.join("src/llvm-project/compiler-rt/lib/builtins/crtbegin.c");
let crtend_src = builder.src.join("src/llvm-project/compiler-rt/lib/builtins/crtend.c");
let crtbegin_src = builder.src.join("src/llvm-project/compiler-rt/lib/crt/crtbegin.c");
let crtend_src = builder.src.join("src/llvm-project/compiler-rt/lib/crt/crtend.c");
if up_to_date(&crtbegin_src, &out_dir.join("crtbegin.o"))
&& up_to_date(&crtend_src, &out_dir.join("crtendS.o"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ CT_ARCH_64=y
CT_ARCH_ARCH="rv64gc"
CT_KERNEL_LINUX=y
CT_LINUX_V_4_20=y
CT_BINUTILS_V_2_36=y
CT_BINUTILS_V_2_32=y
CT_GLIBC_V_2_29=y
CT_GCC_V_8=y
CT_CC_LANG_CXX=y
4 changes: 2 additions & 2 deletions src/ci/docker/host-x86_64/dist-various-2/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ ENV TARGETS=$TARGETS,x86_64-unknown-uefi
# As per https://bugs.launchpad.net/ubuntu/+source/gcc-defaults/+bug/1300211
# we need asm in the search path for gcc-9 (for gnux32) but not in the search path of the
# cross compilers.
# Luckily one of the folders is /usr/local/include so symlink /usr/include/x86_64-linux-gnu/asm there
RUN ln -s /usr/include/x86_64-linux-gnu/asm /usr/local/include/asm
# Luckily one of the folders is /usr/local/include so symlink /usr/include/asm-generic there
RUN ln -s /usr/include/asm-generic /usr/local/include/asm

ENV RUST_CONFIGURE_ARGS --enable-extended --enable-lld --disable-docs \
--set target.wasm32-wasi.wasi-root=/wasm32-wasi \
Expand Down
3 changes: 2 additions & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ ENV RUST_CONFIGURE_ARGS \
--set llvm.ninja=false \
--set rust.jemalloc \
--set rust.use-lld=true \
--set rust.lto=thin
--set rust.lto=thin \
--set rust.codegen-units=1

ENV SCRIPT python3 ../x.py build --set rust.debug=true opt-dist && \
./build/$HOSTS/stage0-tools-bin/opt-dist python3 ../x.py dist \
Expand Down
2 changes: 1 addition & 1 deletion src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ jobs:
<<: *base-ci-job
name: try - ${{ matrix.name }}
env:
DIST_TRY_BUILD: 1
# DIST_TRY_BUILD: 1
<<: [*shared-ci-variables, *prod-variables]
if: github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'
strategy:
Expand Down
2 changes: 0 additions & 2 deletions tests/ui/abi/stack-protector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ fn vulnerable_function() {
// Overwrite the on-stack return address with the address of `malicious_code()`,
// thereby jumping to that function when returning from `vulnerable_function()`.
unsafe { fill(stackaddr, bad_code_ptr, 20); }
// Capture the address, so the write is not optimized away.
std::hint::black_box(stackaddr);
}

// Use an uninlined function with its own stack frame to make sure that we don't
Expand Down

0 comments on commit a3b1fd2

Please sign in to comment.