diff --git a/compiler/rustc_llvm/build.rs b/compiler/rustc_llvm/build.rs index 5be8bd466f854..d847110320c3e 100644 --- a/compiler/rustc_llvm/build.rs +++ b/compiler/rustc_llvm/build.rs @@ -36,11 +36,11 @@ const REQUIRED_COMPONENTS: &[&str] = fn detect_llvm_link() -> (&'static str, &'static str) { // Force the link mode we want, preferring static by default, but // possibly overridden by `configure --enable-llvm-link-shared`. - if tracked_env_var_os("LLVM_LINK_SHARED").is_some() { - ("dylib", "--link-shared") - } else { - ("static", "--link-static") - } + // if tracked_env_var_os("LLVM_LINK_SHARED").is_some() { + // ("dylib", "--link-shared") + // } else { + ("static", "--link-static") + // } } // Because Cargo adds the compiler's dylib path to our library search path, llvm-config may diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index 3216fd671c3f8..b9b36ac833d75 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -1262,16 +1262,17 @@ pub fn rustc_cargo( // Since using LTO for optimizing dylibs is currently experimental, // we need to pass -Zdylib-lto. cargo.rustflag("-Zdylib-lto"); - // Cargo by default passes `-Cembed-bitcode=no` and doesn't pass `-Clto` when - // compiling dylibs (and their dependencies), even when LTO is enabled for the - // crate. Therefore, we need to override `-Clto` and `-Cembed-bitcode` here. - let lto_type = match builder.config.rust_lto { - RustcLto::Thin => "thin", - RustcLto::Fat => "fat", - _ => unreachable!(), - }; - cargo.rustflag(&format!("-Clto={lto_type}")); - cargo.rustflag("-Cembed-bitcode=yes"); + // // Cargo by default passes `-Cembed-bitcode=no` and doesn't pass `-Clto` when + // // compiling dylibs (and their dependencies), even when LTO is enabled for the + // // crate. Therefore, we need to override `-Clto` and `-Cembed-bitcode` here. + // let lto_type = match builder.config.rust_lto { + // RustcLto::Thin => "thin", + // RustcLto::Fat => "fat", + // _ => unreachable!(), + // }; + // cargo.rustflag(&format!("-Clto={lto_type}")); + // cargo.rustflag("-Cembed-bitcode=yes"); + cargo.rustflag("-Clinker-plugin-lto"); } RustcLto::ThinLocal => { /* Do nothing, this is the default */ } RustcLto::Off => { diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 267e21c599728..620097866e261 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -1424,7 +1424,7 @@ NOTE: Please add `--stage 2` to your command line, or if you're sure you want to // the link step) with each stage. llvm_link_shared: Cell::new( llvm_link_shared - .or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true)), + // .or((!llvm_from_ci && llvm_thin_lto.unwrap_or(false)).then_some(true)), ), llvm_offload: llvm_offload.unwrap_or(false), llvm_optimize: llvm_optimize.unwrap_or(true), diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile index b168c739c9793..7344c0d5aeb81 100644 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/Dockerfile @@ -88,6 +88,7 @@ ENV RUST_CONFIGURE_ARGS="--enable-full-tools \ --set target.x86_64-unknown-linux-gnu.ar=/rustroot/bin/llvm-ar \ --set target.x86_64-unknown-linux-gnu.ranlib=/rustroot/bin/llvm-ranlib \ --set llvm.thin-lto=true \ + --set llvm.link-shared=true \ --set llvm.ninja=false \ --set llvm.libzstd=true \ --set rust.jemalloc \ diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh index 46d34cd001a95..ccf2b4141b237 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/dist.sh @@ -4,7 +4,7 @@ set -eux python3 ../x.py build --set rust.debug=true opt-dist -./build/$HOSTS/stage1-tools-bin/opt-dist linux-ci -- python3 ../x.py dist \ +python3 ../x.py dist \ --host $HOSTS --target $HOSTS \ --include-default-paths \ build-manifest \ diff --git a/src/ci/docker/run.sh b/src/ci/docker/run.sh index d62fe1a1aa928..215eda1cb7778 100755 --- a/src/ci/docker/run.sh +++ b/src/ci/docker/run.sh @@ -365,6 +365,6 @@ if [ -f /.dockerenv ]; then docker cp checkout:/checkout/obj $objdir fi -if isCI; then - cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}" -fi +#if isCI; then +# cat $objdir/${SUMMARY_FILE} >> "${GITHUB_STEP_SUMMARY}" +#fi diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs index cdbeee63d6c26..7d05ae38e11e1 100644 --- a/src/tools/opt-dist/src/main.rs +++ b/src/tools/opt-dist/src/main.rs @@ -1,3 +1,5 @@ +#![allow(unused)] + use anyhow::Context; use camino::{Utf8Path, Utf8PathBuf}; use clap::Parser; @@ -313,41 +315,41 @@ fn execute_pipeline( // therefore the LLVM artifacts on disk are not "tainted" with BOLT instrumentation and they can be reused. let libdir = env.build_artifacts().join("stage2").join("lib"); timer.section("Stage 3 (BOLT)", |stage| { - let llvm_profile = if env.build_llvm() { - stage.section("Build PGO optimized LLVM", |stage| { - Bootstrap::build(env) - .with_llvm_bolt_ldflags() - .llvm_pgo_optimize(llvm_pgo_profile.as_ref()) - .avoid_rustc_rebuild() - .run(stage) - })?; - - // The actual name will be something like libLLVM.so.18.1-rust-dev. - let llvm_lib = io::find_file_in_dir(&libdir, "libLLVM.so", "")?; - - log::info!("Optimizing {llvm_lib} with BOLT"); - - // FIXME(kobzol): try gather profiles together, at once for LLVM and rustc - // Instrument the libraries and gather profiles - let llvm_profile = with_bolt_instrumented(env, &llvm_lib, |llvm_profile_dir| { - stage.section("Gather profiles", |_| { - gather_bolt_profiles(env, "LLVM", llvm_benchmarks(env), llvm_profile_dir) - }) - })?; - print_free_disk_space()?; - - // Now optimize the library with BOLT. The `libLLVM-XXX.so` library is actually hard-linked - // from several places, and this specific path (`llvm_lib`) will *not* be packaged into - // the final dist build. However, when BOLT optimizes an artifact, it does so *in-place*, - // therefore it will actually optimize all the hard links, which means that the final - // packaged `libLLVM.so` file *will* be BOLT optimized. - bolt_optimize(&llvm_lib, &llvm_profile, env) - .context("Could not optimize LLVM with BOLT")?; - - Some(llvm_profile) - } else { - None - }; + // let llvm_profile = if env.build_llvm() { + // stage.section("Build PGO optimized LLVM", |stage| { + // Bootstrap::build(env) + // .with_llvm_bolt_ldflags() + // .llvm_pgo_optimize(llvm_pgo_profile.as_ref()) + // .avoid_rustc_rebuild() + // .run(stage) + // })?; + // + // // The actual name will be something like libLLVM.so.18.1-rust-dev. + // let llvm_lib = io::find_file_in_dir(&libdir, "libLLVM.so", "")?; + // + // log::info!("Optimizing {llvm_lib} with BOLT"); + // + // // FIXME(kobzol): try gather profiles together, at once for LLVM and rustc + // // Instrument the libraries and gather profiles + // let llvm_profile = with_bolt_instrumented(env, &llvm_lib, |llvm_profile_dir| { + // stage.section("Gather profiles", |_| { + // gather_bolt_profiles(env, "LLVM", llvm_benchmarks(env), llvm_profile_dir) + // }) + // })?; + // print_free_disk_space()?; + // + // // Now optimize the library with BOLT. The `libLLVM-XXX.so` library is actually hard-linked + // // from several places, and this specific path (`llvm_lib`) will *not* be packaged into + // // the final dist build. However, when BOLT optimizes an artifact, it does so *in-place*, + // // therefore it will actually optimize all the hard links, which means that the final + // // packaged `libLLVM.so` file *will* be BOLT optimized. + // bolt_optimize(&llvm_lib, &llvm_profile, env) + // .context("Could not optimize LLVM with BOLT")?; + // + // Some(llvm_profile) + // } else { + // None + // }; let rustc_lib = io::find_file_in_dir(&libdir, "librustc_driver", ".so")?; @@ -367,7 +369,7 @@ fn execute_pipeline( // LLVM is not being cleared here. Either we built it and we want to use the BOLT-optimized LLVM, or we // didn't build it, so we don't want to remove it. - Ok(vec![llvm_profile, Some(rustc_profile)]) + Ok(vec![None, Some(rustc_profile)]) })? } else { vec![]