diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-30 03:59:35 +0000 |
commit | d1b2d29528b7794b41e66fc2136e395a02f8529b (patch) | |
tree | a4a17504b260206dec3cf55b2dca82929a348ac2 /compiler/rustc_codegen_cranelift/build_system/utils.rs | |
parent | Releasing progress-linux version 1.72.1+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.tar.xz rustc-d1b2d29528b7794b41e66fc2136e395a02f8529b.zip |
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_codegen_cranelift/build_system/utils.rs')
-rw-r--r-- | compiler/rustc_codegen_cranelift/build_system/utils.rs | 61 |
1 files changed, 50 insertions, 11 deletions
diff --git a/compiler/rustc_codegen_cranelift/build_system/utils.rs b/compiler/rustc_codegen_cranelift/build_system/utils.rs index 41fc366e2..24624cdea 100644 --- a/compiler/rustc_codegen_cranelift/build_system/utils.rs +++ b/compiler/rustc_codegen_cranelift/build_system/utils.rs @@ -3,16 +3,18 @@ use std::fs; use std::io::{self, Write}; use std::path::{Path, PathBuf}; use std::process::{self, Command, Stdio}; +use std::sync::atomic::{AtomicBool, Ordering}; -use super::path::{Dirs, RelPath}; +use crate::path::{Dirs, RelPath}; +use crate::shared_utils::rustflags_to_cmd_env; #[derive(Clone, Debug)] pub(crate) struct Compiler { pub(crate) cargo: PathBuf, pub(crate) rustc: PathBuf, pub(crate) rustdoc: PathBuf, - pub(crate) rustflags: String, - pub(crate) rustdocflags: String, + pub(crate) rustflags: Vec<String>, + pub(crate) rustdocflags: Vec<String>, pub(crate) triple: String, pub(crate) runner: Vec<String>, } @@ -22,8 +24,8 @@ impl Compiler { match self.triple.as_str() { "aarch64-unknown-linux-gnu" => { // We are cross-compiling for aarch64. Use the correct linker and run tests in qemu. - self.rustflags += " -Clinker=aarch64-linux-gnu-gcc"; - self.rustdocflags += " -Clinker=aarch64-linux-gnu-gcc"; + self.rustflags.push("-Clinker=aarch64-linux-gnu-gcc".to_owned()); + self.rustdocflags.push("-Clinker=aarch64-linux-gnu-gcc".to_owned()); self.runner = vec![ "qemu-aarch64".to_owned(), "-L".to_owned(), @@ -32,8 +34,8 @@ impl Compiler { } "s390x-unknown-linux-gnu" => { // We are cross-compiling for s390x. Use the correct linker and run tests in qemu. - self.rustflags += " -Clinker=s390x-linux-gnu-gcc"; - self.rustdocflags += " -Clinker=s390x-linux-gnu-gcc"; + self.rustflags.push("-Clinker=s390x-linux-gnu-gcc".to_owned()); + self.rustdocflags.push("-Clinker=s390x-linux-gnu-gcc".to_owned()); self.runner = vec![ "qemu-s390x".to_owned(), "-L".to_owned(), @@ -99,8 +101,8 @@ impl CargoProject { cmd.env("RUSTC", &compiler.rustc); cmd.env("RUSTDOC", &compiler.rustdoc); - cmd.env("RUSTFLAGS", &compiler.rustflags); - cmd.env("RUSTDOCFLAGS", &compiler.rustdocflags); + rustflags_to_cmd_env(&mut cmd, "RUSTFLAGS", &compiler.rustflags); + rustflags_to_cmd_env(&mut cmd, "RUSTDOCFLAGS", &compiler.rustdocflags); if !compiler.runner.is_empty() { cmd.env( format!("CARGO_TARGET_{}_RUNNER", compiler.triple.to_uppercase().replace('-', "_")), @@ -136,10 +138,13 @@ pub(crate) fn hyperfine_command( warmup: u64, runs: u64, prepare: Option<&str>, - cmds: &[&str], + cmds: &[(&str, &str)], + markdown_export: &Path, ) -> Command { let mut bench = Command::new("hyperfine"); + bench.arg("--export-markdown").arg(markdown_export); + if warmup != 0 { bench.arg("--warmup").arg(warmup.to_string()); } @@ -152,7 +157,12 @@ pub(crate) fn hyperfine_command( bench.arg("--prepare").arg(prepare); } - bench.args(cmds); + for &(name, cmd) in cmds { + if name != "" { + bench.arg("-n").arg(name); + } + bench.arg(cmd); + } bench } @@ -167,6 +177,8 @@ pub(crate) fn git_command<'a>(repo_dir: impl Into<Option<&'a Path>>, cmd: &str) .arg("user.email=dummy@example.com") .arg("-c") .arg("core.autocrlf=false") + .arg("-c") + .arg("commit.gpgSign=false") .arg(cmd); if let Some(repo_dir) = repo_dir.into() { git_cmd.current_dir(repo_dir); @@ -259,6 +271,33 @@ pub(crate) fn is_ci_opt() -> bool { env::var("CI_OPT").is_ok() } +static IN_GROUP: AtomicBool = AtomicBool::new(false); +pub(crate) struct LogGroup { + is_gha: bool, +} + +impl LogGroup { + pub(crate) fn guard(name: &str) -> LogGroup { + let is_gha = env::var("GITHUB_ACTIONS").is_ok(); + + assert!(!IN_GROUP.swap(true, Ordering::SeqCst)); + if is_gha { + eprintln!("::group::{name}"); + } + + LogGroup { is_gha } + } +} + +impl Drop for LogGroup { + fn drop(&mut self) { + if self.is_gha { + eprintln!("::endgroup::"); + } + IN_GROUP.store(false, Ordering::SeqCst); + } +} + pub(crate) fn maybe_incremental(cmd: &mut Command) { if is_ci() || std::env::var("CARGO_BUILD_INCREMENTAL").map_or(false, |val| val == "false") { // Disabling incr comp reduces cache size and incr comp doesn't save as much on CI anyway |