Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Dec 10, 2023
1 parent 4750e9d commit 53031b2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
7 changes: 4 additions & 3 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ use crate::utils::cache::{Interned, INTERNER};
use crate::utils::exec::BootstrapCommand;
use crate::utils::helpers::{
self, add_link_lib_path, add_rustdoc_cargo_linker_args, dylib_path, dylib_path_var,
linker_args, output, t, target_supports_cranelift_backend, up_to_date, LldThreads,
linker_args, linker_flags, output, t, target_supports_cranelift_backend, up_to_date,
LldThreads,
};
use crate::utils::render_tests::{add_flags_and_try_run_tests, try_run_tests};
use crate::{envify, CLang, DocTests, GitRepo, Mode};
Expand Down Expand Up @@ -1746,14 +1747,14 @@ NOTE: if you're sure you want to do this, please open an issue as to why. In the

let mut hostflags = flags.clone();
hostflags.push(format!("-Lnative={}", builder.test_helpers_out(compiler.host).display()));
hostflags.extend(linker_args(builder, compiler.host, LldThreads::No));
hostflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
for flag in hostflags {
cmd.arg("--host-rustcflags").arg(flag);
}

let mut targetflags = flags;
targetflags.push(format!("-Lnative={}", builder.test_helpers_out(target).display()));
targetflags.extend(linker_args(builder, compiler.host, LldThreads::No));
targetflags.extend(linker_flags(builder, compiler.host, LldThreads::No));
for flag in targetflags {
cmd.arg("--target-rustcflags").arg(flag);
}
Expand Down
22 changes: 10 additions & 12 deletions src/bootstrap/src/core/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ use crate::core::build_steps::{check, clean, compile, dist, doc, install, run, s
use crate::core::config::flags::{Color, Subcommand};
use crate::core::config::{DryRun, SplitDebuginfo, TargetSelection};
use crate::utils::cache::{Cache, Interned, INTERNER};
use crate::utils::helpers::{
self, add_dylib_path, add_link_lib_path, exe, linker_args, linker_flags,
};
use crate::utils::helpers::{libdir, output, t, LldThreads};
use crate::utils::helpers::{self, add_dylib_path, add_link_lib_path, exe, linker_args};
use crate::utils::helpers::{libdir, linker_flags, output, t, LldThreads};
use crate::Crate;
use crate::EXTRA_CHECK_CFGS;
use crate::{Build, CLang, DocTests, GitRepo, Mode};
Expand Down Expand Up @@ -1675,22 +1673,22 @@ impl<'a> Builder<'a> {
rustflags.arg(&format!("-Zstack-protector={stack_protector}"));
}

linker_args(self, compiler.host, LldThreads::Yes).into_iter().for_each(|flag| {
hostflags.arg(flag);
});
for arg in linker_args(self, compiler.host, LldThreads::Yes) {
hostflags.arg(&arg);
}

if let Some(target_linker) = self.linker(target) {
let target = crate::envify(&target.triple);
cargo.env(&format!("CARGO_TARGET_{target}_LINKER"), target_linker);
}
// We want to set -Clinker using Cargo, therefore we only call `linker_flags` and not
// `linker_args` here.
linker_flags(self, target, LldThreads::Yes).into_iter().for_each(|flag| {
for flag in linker_flags(self, target, LldThreads::Yes) {
rustflags.arg(&flag);
});
linker_args(self, target, LldThreads::Yes).into_iter().for_each(|flag| {
rustdocflags.arg(&flag);
});
}
for arg in linker_args(self, target, LldThreads::Yes) {
rustdocflags.arg(&arg);
}

if !(["build", "check", "clippy", "fix", "rustc"].contains(&cmd)) && want_rustdoc {
cargo.env("RUSTDOC_LIBDIR", self.rustc_libdir(compiler));
Expand Down
10 changes: 5 additions & 5 deletions src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ impl Display for DebuginfoLevel {
///
/// It is configured depending on the target:
/// 1) Everything except MSVC
/// - Self-contained: -Clinker-flavor=gnu-lld-cc -Clink-self-contained=+linker
/// - External: -Clinker-flavor=gnu-lld-cc
/// - Self-contained: `-Clinker-flavor=gnu-lld-cc -Clink-self-contained=+linker`
/// - External: `-Clinker-flavor=gnu-lld-cc`
/// 2) MSVC
/// - Self-contained: -Clinker=<path to rust-lld>
/// - External: -Clinker=lld
#[derive(Default, Clone)]
/// - Self-contained: `-Clinker=<path to rust-lld>`
/// - External: `-Clinker=lld`
#[derive(Default, Copy, Clone)]
pub enum LldMode {
/// Do not use LLD
#[default]
Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/src/utils/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ fn absolute_unix(path: &Path) -> io::Result<PathBuf> {

#[cfg(windows)]
fn absolute_windows(path: &std::path::Path) -> std::io::Result<std::path::PathBuf> {
use std::ffi::OsString;
use std::io::Error;
use std::os::windows::ffi::{OsStrExt, OsStringExt};
use std::ptr::null_mut;
Expand Down Expand Up @@ -526,7 +527,7 @@ pub fn linker_flags(
if matches!(lld_threads, LldThreads::No) {
args.push(format!(
"-Clink-arg=-Wl,{}",
lld_flag_no_threads(builder.config.lld_mode.clone(), target.is_msvc())
lld_flag_no_threads(builder.config.lld_mode, target.is_msvc())
));
}
}
Expand Down

0 comments on commit 53031b2

Please sign in to comment.