Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crater: test enabling MCP510 #117684

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,12 @@ impl LinkSelfContainedDefault {
_ => "crt-objects-fallback",
}
}

/// Creates a `LinkSelfContained` enabling the self-contained linker for target specs (the
/// equivalent of `-Clink-self-contained=+linker` on the CLI).
pub fn with_linker() -> LinkSelfContainedDefault {
LinkSelfContainedDefault::WithComponents(LinkSelfContainedComponents::LINKER)
}
}

bitflags::bitflags! {
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_target/src/spec/x86_64_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ pub fn target() -> Target {
| SanitizerSet::THREAD;
base.supports_xray = true;

#[cfg(rust_lld)]
{
base.linker_flavor = LinkerFlavor::Gnu(Cc::Yes, Lld::Yes);
base.link_self_contained = crate::spec::LinkSelfContainedDefault::with_linker();
}

Target {
llvm_target: "x86_64-unknown-linux-gnu".into(),
pointer_width: 64,
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,10 @@ pub fn rustc_cargo_env(
cargo.rustflag("--cfg=parallel_compiler");
cargo.rustdocflag("--cfg=parallel_compiler");
}
if builder.config.lld_enabled {
cargo.rustflag("--cfg=rust_lld");
cargo.rustdocflag("--cfg=rust_lld");
}
if builder.config.rust_verify_llvm_ir {
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
}
Expand Down
23 changes: 22 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,7 @@ impl Config {
let mut debuginfo_level_tests = None;
let mut optimize = None;
let mut omit_git_hash = None;
let mut lld_enabled = None;

if let Some(rust) = toml.rust {
set(&mut config.channel, rust.channel);
Expand Down Expand Up @@ -1404,6 +1405,7 @@ impl Config {
debuginfo_level_std = rust.debuginfo_level_std;
debuginfo_level_tools = rust.debuginfo_level_tools;
debuginfo_level_tests = rust.debuginfo_level_tests;
lld_enabled = rust.lld;

config.rust_split_debuginfo = rust
.split_debuginfo
Expand All @@ -1428,7 +1430,6 @@ impl Config {
config.incremental = true;
}
set(&mut config.use_lld, rust.use_lld);
set(&mut config.lld_enabled, rust.lld);
set(&mut config.llvm_tools_enabled, rust.llvm_tools);
config.rustc_parallel = rust
.parallel_compiler
Expand Down Expand Up @@ -1665,6 +1666,26 @@ impl Config {
config.llvm_plugins = llvm_plugins.unwrap_or(false);
config.rust_optimize = optimize.unwrap_or(RustOptimize::Bool(true));

// `x86_64-unknown-linux-gnu` now uses the self-contained linker, so we have to build
// our internal lld by default:
// - when building our in-tree llvm (the target has not set an `llvm-config`), we're able to
// build rust-lld as well
// - when using an external llvm that's downloaded from CI, rust-lld is also packaged there
// - otherwise, we're using an external llvm and lld is not available and thus, disabled
// - similarly, it's not built or used by this target when asked not to (when the config
// sets `rust.lld = false`)
if config.build.triple == "x86_64-unknown-linux-gnu" && config.hosts == &[config.build] {
let no_llvm_config = config
.target_config
.get(&config.build)
.is_some_and(|target_config| target_config.llvm_config.is_none());
let enable_lld = config.llvm_from_ci || no_llvm_config;
// Prefer the config setting in case an explicit opt-out is needed.
config.lld_enabled = lld_enabled.unwrap_or(enable_lld);
} else {
set(&mut config.lld_enabled, lld_enabled);
}

let default = debug == Some(true);
config.rust_debug_assertions = debug_assertions.unwrap_or(default);
config.rust_debug_assertions_std =
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ const EXTRA_CHECK_CFGS: &[(Option<Mode>, &str, Option<&[&'static str]>)] = &[
// Needed to avoid the need to copy windows.lib into the sysroot.
(Some(Mode::Rustc), "windows_raw_dylib", None),
(Some(Mode::ToolRustc), "windows_raw_dylib", None),
// If rustc wants to use rust-lld as the default linker in a target spec.
(Some(Mode::Rustc), "rust_lld", None),
(Some(Mode::ToolRustc), "rust_lld", None),
(Some(Mode::Codegen), "rust_lld", None),
];

/// A structure representing a Rust compiler.
Expand Down
8 changes: 7 additions & 1 deletion src/ci/docker/host-x86_64/dist-x86_64-linux/build-gcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ set -ex

source shared.sh

GCC=8.5.0
# Note: in the future when bumping to version 10.1.0, also take care of the sed block below.
GCC=9.5.0

curl https://ftp.gnu.org/gnu/gcc/gcc-$GCC/gcc-$GCC.tar.xz | xzcat | tar xf -
cd gcc-$GCC
Expand All @@ -22,6 +23,11 @@ cd gcc-$GCC
# latter host is presented to `wget`! Therefore, we choose to download from the insecure HTTP server
# instead here.
#
# Note: in version 10.1.0, the URL used in `download_prerequisites` has changed from using FTP to
# using HTTP. When bumping to that gcc version, we can likely remove the sed replacement below, or
# the expression will need to be updated. That new URL is available at:
# https://github.com/gcc-mirror/gcc/blob/6e6e3f144a33ae504149dc992453b4f6dea12fdb/contrib/download_prerequisites#L35
#
sed -i'' 's|ftp://gcc\.gnu\.org/|https://gcc.gnu.org/|g' ./contrib/download_prerequisites

./contrib/download_prerequisites
Expand Down