Skip to content

Commit

Permalink
Auto merge of rust-lang#109884 - matthiaskrgr:rollup-5wapig9, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#109526 (LIBPATH is used as dylib's path environment variable on AIX)
 - rust-lang#109642 (check for missing codegen backeng config)
 - rust-lang#109722 (Implement read_buf for RustHermit)
 - rust-lang#109856 (fix(middle): emit error rather than delay bug when reaching limit)
 - rust-lang#109868 (Improve PR job names in Github Actions preview)
 - rust-lang#109871 (Include invocation start times)
 - rust-lang#109873 (Move some UI tests into subdirectories)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Apr 3, 2023
2 parents d0eed58 + 22df710 commit 932c173
Show file tree
Hide file tree
Showing 74 changed files with 119 additions and 97 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
pr:
permissions:
actions: write
name: PR
name: "PR - ${{ matrix.name }}"
env:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
Expand Down Expand Up @@ -159,7 +159,7 @@ jobs:
auto:
permissions:
actions: write
name: auto
name: "auto - ${{ matrix.name }}"
env:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
Expand Down Expand Up @@ -578,7 +578,7 @@ jobs:
try:
permissions:
actions: write
name: try
name: "try - ${{ matrix.name }}"
env:
CI_JOB_NAME: "${{ matrix.name }}"
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_middle/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ middle_limit_invalid =
`limit` must be a non-negative integer
.label = {$error_str}
middle_recursion_limit_reached =
reached the recursion limit finding the struct tail for `{$ty}`
.help = consider increasing the recursion limit by adding a `#![recursion_limit = "{$suggested_limit}"]`
middle_const_eval_non_int =
constant evaluation of enum discriminant resulted in non-integer
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_middle/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ pub struct LimitInvalid<'a> {
pub error_str: &'a str,
}

#[derive(Diagnostic)]
#[diag(middle_recursion_limit_reached)]
#[help]
pub struct RecursionLimitReached<'tcx> {
pub ty: Ty<'tcx>,
pub suggested_limit: rustc_session::Limit,
}

#[derive(Diagnostic)]
#[diag(middle_const_eval_non_int)]
pub struct ConstEvalNonIntError {
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_index::bit_set::GrowableBitSet;
use rustc_index::vec::{Idx, IndexVec};
use rustc_macros::HashStable;
use rustc_span::{sym, DUMMY_SP};
use rustc_session::Limit;
use rustc_span::sym;
use rustc_target::abi::{Integer, IntegerType, Size, TargetDataLayout};
use rustc_target::spec::abi::Abi;
use smallvec::SmallVec;
Expand Down Expand Up @@ -225,10 +226,13 @@ impl<'tcx> TyCtxt<'tcx> {
let recursion_limit = self.recursion_limit();
for iteration in 0.. {
if !recursion_limit.value_within_limit(iteration) {
return self.ty_error_with_message(
DUMMY_SP,
&format!("reached the recursion limit finding the struct tail for {}", ty),
);
let suggested_limit = match recursion_limit {
Limit(0) => Limit(2),
limit => limit * 2,
};
let reported =
self.sess.emit_err(crate::error::RecursionLimitReached { ty, suggested_limit });
return self.ty_error(reported);
}
match *ty.kind() {
ty::Adt(def, substs) => {
Expand Down
31 changes: 24 additions & 7 deletions library/std/src/sys/hermit/net.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(dead_code)]

use crate::cmp;
use crate::io::{self, IoSlice, IoSliceMut};
use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
use crate::mem;
use crate::net::{Shutdown, SocketAddr};
use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd};
Expand Down Expand Up @@ -146,18 +146,35 @@ impl Socket {
Ok(Socket(unsafe { FileDesc::from_raw_fd(fd) }))
}

fn recv_with_flags(&self, buf: &mut [u8], flags: i32) -> io::Result<usize> {
let ret =
cvt(unsafe { netc::recv(self.0.as_raw_fd(), buf.as_mut_ptr(), buf.len(), flags) })?;
Ok(ret as usize)
fn recv_with_flags(&self, mut buf: BorrowedCursor<'_>, flags: i32) -> io::Result<()> {
let ret = cvt(unsafe {
netc::recv(
self.0.as_raw_fd(),
buf.as_mut().as_mut_ptr() as *mut u8,
buf.capacity(),
flags,
)
})?;
unsafe {
buf.advance(ret as usize);
}
Ok(())
}

pub fn read(&self, buf: &mut [u8]) -> io::Result<usize> {
self.recv_with_flags(buf, 0)
let mut buf = BorrowedBuf::from(buf);
self.recv_with_flags(buf.unfilled(), 0)?;
Ok(buf.len())
}

pub fn peek(&self, buf: &mut [u8]) -> io::Result<usize> {
self.recv_with_flags(buf, netc::MSG_PEEK)
let mut buf = BorrowedBuf::from(buf);
self.recv_with_flags(buf.unfilled(), netc::MSG_PEEK)?;
Ok(buf.len())
}

pub fn read_buf(&self, buf: BorrowedCursor<'_>) -> io::Result<()> {
self.recv_with_flags(buf, 0)
}

pub fn read_vectored(&self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
Expand Down
3 changes: 3 additions & 0 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,6 +741,9 @@ def build_bootstrap(self, color, verbose_count):
env["LIBRARY_PATH"] = os.path.join(self.bin_root(), "lib") + \
(os.pathsep + env["LIBRARY_PATH"]) \
if "LIBRARY_PATH" in env else ""
env["LIBPATH"] = os.path.join(self.bin_root(), "lib") + \
(os.pathsep + env["LIBPATH"]) \
if "LIBPATH" in env else ""

# Export Stage0 snapshot compiler related env variables
build_section = "target.{}".format(self.build)
Expand Down
44 changes: 43 additions & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use serde_derive::Deserialize;

use crate::builder::crate_description;
use crate::builder::Cargo;
use crate::builder::{Builder, Kind, RunConfig, ShouldRun, Step};
use crate::builder::{Builder, Kind, PathSet, RunConfig, ShouldRun, Step, TaskPath};
use crate::cache::{Interned, INTERNER};
use crate::config::{LlvmLibunwind, RustcLto, TargetSelection};
use crate::dist;
Expand Down Expand Up @@ -995,6 +995,44 @@ pub struct CodegenBackend {
pub backend: Interned<String>,
}

fn needs_codegen_config(run: &RunConfig<'_>) -> bool {
let mut needs_codegen_cfg = false;
for path_set in &run.paths {
needs_codegen_cfg = match path_set {
PathSet::Set(set) => set.iter().any(|p| is_codegen_cfg_needed(p, run)),
PathSet::Suite(suite) => is_codegen_cfg_needed(&suite, run),
}
}
needs_codegen_cfg
}

const CODEGEN_BACKEND_PREFIX: &str = "rustc_codegen_";

fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
if path.path.to_str().unwrap().contains(&CODEGEN_BACKEND_PREFIX) {
let mut needs_codegen_backend_config = true;
for &backend in &run.builder.config.rust_codegen_backends {
if path
.path
.to_str()
.unwrap()
.ends_with(&(CODEGEN_BACKEND_PREFIX.to_owned() + &backend))
{
needs_codegen_backend_config = false;
}
}
if needs_codegen_backend_config {
run.builder.info(
"Warning: no codegen-backends config matched the requested path to build a codegen backend. \
Help: add backend to codegen-backends in config.toml.",
);
return true;
}
}

return false;
}

impl Step for CodegenBackend {
type Output = ();
const ONLY_HOSTS: bool = true;
Expand All @@ -1006,6 +1044,10 @@ impl Step for CodegenBackend {
}

fn make_run(run: RunConfig<'_>) {
if needs_codegen_config(&run) {
return;
}

for &backend in &run.builder.config.rust_codegen_backends {
if backend == "llvm" {
continue; // Already built as part of rustc
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/dylib_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ pub fn dylib_path_var() -> &'static str {
"DYLD_LIBRARY_PATH"
} else if cfg!(target_os = "haiku") {
"LIBRARY_PATH"
} else if cfg!(target_os = "aix") {
"LIBPATH"
} else {
"LD_LIBRARY_PATH"
}
Expand Down
13 changes: 12 additions & 1 deletion src/bootstrap/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use serde_derive::{Deserialize, Serialize};
use std::cell::RefCell;
use std::fs::File;
use std::io::BufWriter;
use std::time::{Duration, Instant};
use std::time::{Duration, Instant, SystemTime};
use sysinfo::{CpuExt, System, SystemExt};

pub(crate) struct BuildMetrics {
Expand All @@ -27,6 +27,7 @@ impl BuildMetrics {
system_info: System::new(),
timer_start: None,
invocation_timer_start: Instant::now(),
invocation_start: SystemTime::now(),
});

BuildMetrics { state }
Expand Down Expand Up @@ -124,6 +125,11 @@ impl BuildMetrics {
}
};
invocations.push(JsonInvocation {
start_time: state
.invocation_start
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_secs(),
duration_including_children_sec: state.invocation_timer_start.elapsed().as_secs_f64(),
children: steps.into_iter().map(|step| self.prepare_json_step(step)).collect(),
});
Expand Down Expand Up @@ -166,6 +172,7 @@ struct MetricsState {
system_info: System,
timer_start: Option<Instant>,
invocation_timer_start: Instant,
invocation_start: SystemTime,
}

struct StepMetrics {
Expand Down Expand Up @@ -194,6 +201,10 @@ struct JsonRoot {
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
struct JsonInvocation {
// Unix timestamp in seconds
//
// This is necessary to easily correlate this invocation with logs or other data.
start_time: u64,
duration_including_children_sec: f64,
children: Vec<JsonNode>,
}
Expand Down
6 changes: 3 additions & 3 deletions src/ci/github-actions/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ jobs:
permissions:
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
<<: *base-ci-job
name: PR
name: PR - ${{ matrix.name }}
env:
<<: [*shared-ci-variables, *public-variables]
if: github.event_name == 'pull_request'
Expand Down Expand Up @@ -312,7 +312,7 @@ jobs:
permissions:
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
<<: *base-ci-job
name: auto
name: auto - ${{ matrix.name }}
env:
<<: [*shared-ci-variables, *prod-variables]
if: github.event_name == 'push' && github.ref == 'refs/heads/auto' && github.repository == 'rust-lang-ci/rust'
Expand Down Expand Up @@ -741,7 +741,7 @@ jobs:
permissions:
actions: write # for rust-lang/simpleinfra/github-actions/cancel-outdated-builds
<<: *base-ci-job
name: try
name: try - ${{ matrix.name }}
env:
<<: [*shared-ci-variables, *prod-variables]
if: github.event_name == 'push' && (github.ref == 'refs/heads/try' || github.ref == 'refs/heads/try-perf') && github.repository == 'rust-lang-ci/rust'
Expand Down
2 changes: 2 additions & 0 deletions src/tools/compiletest/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ pub fn dylib_env_var() -> &'static str {
"DYLD_LIBRARY_PATH"
} else if cfg!(target_os = "haiku") {
"LIBRARY_PATH"
} else if cfg!(target_os = "aix") {
"LIBPATH"
} else {
"LD_LIBRARY_PATH"
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/ui_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::path::{Path, PathBuf};

const ENTRY_LIMIT: usize = 1000;
// FIXME: The following limits should be reduced eventually.
const ROOT_ENTRY_LIMIT: usize = 940;
const ROOT_ENTRY_LIMIT: usize = 881;
const ISSUES_ENTRY_LIMIT: usize = 1978;

fn check_entries(tests_path: &Path, bad: &mut bool) {
Expand Down
52 changes: 0 additions & 52 deletions tests/ui/autoref-autoderef/issue-38940.rs

This file was deleted.

23 changes: 0 additions & 23 deletions tests/ui/autoref-autoderef/issue-38940.stderr

This file was deleted.

Loading

0 comments on commit 932c173

Please sign in to comment.