Skip to content

Commit

Permalink
Add support for x86-64-{2,3,4} target CPUs and pass -Ctarget-cpu=x86-…
Browse files Browse the repository at this point in the history
…64-v2
  • Loading branch information
est31 committed Nov 14, 2020
1 parent f7801d6 commit cca4102
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
url = https://github.com/rust-lang/edition-guide.git
[submodule "src/llvm-project"]
path = src/llvm-project
url = https://github.com/rust-lang/llvm-project.git
branch = rustc/11.0-2020-10-12
url = https://github.com/est31/llvm-project.git
branch = rustc/11.0-2020-11-14
[submodule "src/doc/embedded-book"]
path = src/doc/embedded-book
url = https://github.com/rust-embedded/book.git
Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Step for Rustc {
target,
cargo_subcommand(builder.kind),
);
rustc_cargo(builder, &mut cargo, target);
rustc_cargo(builder, &mut cargo, target, compiler);
if let Subcommand::Check { all_targets: true, .. } = builder.config.cmd {
cargo.arg("--all-targets");
}
Expand Down Expand Up @@ -215,7 +215,7 @@ impl Step for CodegenBackend {
cargo
.arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend)));
rustc_cargo_env(builder, &mut cargo, target);
rustc_cargo_env(builder, &mut cargo, target, compiler);

run_cargo(
builder,
Expand Down
16 changes: 10 additions & 6 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl Step for Rustc {
});

let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build");
rustc_cargo(builder, &mut cargo, target);
rustc_cargo(builder, &mut cargo, target, compiler);

builder.info(&format!(
"Building stage{} compiler artifacts ({} -> {})",
Expand All @@ -522,16 +522,16 @@ impl Step for Rustc {
}
}

pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection) {
pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection, compiler: Compiler) {
cargo
.arg("--features")
.arg(builder.rustc_features())
.arg("--manifest-path")
.arg(builder.src.join("compiler/rustc/Cargo.toml"));
rustc_cargo_env(builder, cargo, target);
rustc_cargo_env(builder, cargo, target, compiler);
}

pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection) {
pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection, compiler: Compiler) {
// Set some configuration variables picked up by build scripts and
// the compiler alike
cargo
Expand Down Expand Up @@ -561,7 +561,11 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
if builder.config.rust_verify_llvm_ir {
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
}

if target == "x86_64-unknown-linux-gnu" && compiler.stage > 0 {
if builder.is_rust_llvm(target) {
cargo.rustflag("-Ctarget-cpu=x86-64-v2");
}
}
// Pass down configuration from the LLVM build into the build of
// rustc_llvm and rustc_codegen_llvm.
//
Expand Down Expand Up @@ -701,7 +705,7 @@ impl Step for CodegenBackend {
cargo
.arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend)));
rustc_cargo_env(builder, &mut cargo, target);
rustc_cargo_env(builder, &mut cargo, target, compiler);

let tmp_stamp = out_dir.join(".tmp.stamp");

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ impl Step for Rustc {
cargo.rustdocflag("--document-private-items");
cargo.rustdocflag("--enable-index-page");
cargo.rustdocflag("-Zunstable-options");
compile::rustc_cargo(builder, &mut cargo, target);
compile::rustc_cargo(builder, &mut cargo, target, compiler);

// Only include compiler crates, no dependencies of those, such as `libc`.
cargo.arg("--no-deps");
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,7 @@ impl Step for Crate {
}
Mode::Rustc => {
builder.ensure(compile::Rustc { compiler, target });
compile::rustc_cargo(builder, &mut cargo, target);
compile::rustc_cargo(builder, &mut cargo, target, compiler);
}
_ => panic!("can only test libraries"),
};
Expand Down

0 comments on commit cca4102

Please sign in to comment.