From d8a8486afd78494f5710f065df784b16fef0c481 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 8 Dec 2023 17:32:56 +0100 Subject: [PATCH] Review fixes --- src/bootstrap/src/core/build_steps/test.rs | 7 ++++--- src/bootstrap/src/core/builder.rs | 22 ++++++++++------------ src/bootstrap/src/core/config/config.rs | 2 +- src/bootstrap/src/utils/helpers.rs | 3 ++- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index 2184dcbf58989..d0f36f99342fe 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -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}; @@ -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); } diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index 75c06dd5510ac..2356565190bdc 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -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}; @@ -1675,9 +1673,9 @@ 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); @@ -1685,12 +1683,12 @@ impl<'a> Builder<'a> { } // 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)); diff --git a/src/bootstrap/src/core/config/config.rs b/src/bootstrap/src/core/config/config.rs index 105b7d74dfc1e..f7044bd1b7066 100644 --- a/src/bootstrap/src/core/config/config.rs +++ b/src/bootstrap/src/core/config/config.rs @@ -116,7 +116,7 @@ impl Display for DebuginfoLevel { /// 2) MSVC /// - Self-contained: -Clinker= /// - External: -Clinker=lld -#[derive(Default, Clone)] +#[derive(Default, Copy, Clone)] pub enum LldMode { /// Do not use LLD #[default] diff --git a/src/bootstrap/src/utils/helpers.rs b/src/bootstrap/src/utils/helpers.rs index 8a818fb87ffde..e563a83c5c478 100644 --- a/src/bootstrap/src/utils/helpers.rs +++ b/src/bootstrap/src/utils/helpers.rs @@ -378,6 +378,7 @@ fn absolute_unix(path: &Path) -> io::Result { #[cfg(windows)] fn absolute_windows(path: &std::path::Path) -> std::io::Result { + use std::ffi::OsString; use std::io::Error; use std::os::windows::ffi::{OsStrExt, OsStringExt}; use std::ptr::null_mut; @@ -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()) )); } }