Skip to content

Commit d39561c

Browse files
committed
Auto merge of rust-lang#159192 - JonathanBrouwer:rollup-d2abRmH, r=JonathanBrouwer
Rollup of 6 pull requests Successful merges: - rust-lang#158732 (Apply MCP 1003 and move diagnostics.rs into its own module) - rust-lang#159131 (bootstrap: Allow path-based skipping of the coverage test suite) - rust-lang#159134 (std: fix panic in Windows Stdin::read_vectored with pending surrogate) - rust-lang#159178 (Print duration of BOLT instrumentation and optimization steps) - rust-lang#159112 (Fix segfault in env access in statically linked FreeBSD binaries) - rust-lang#159124 (compiletest: use VecDeque::pop_front_if)
2 parents 77cf889 + 7f9a0ab commit d39561c

22 files changed

Lines changed: 733 additions & 73 deletions

File tree

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use tracing::debug;
3232

3333
use crate::Namespace::{MacroNS, TypeNS, ValueNS};
3434
use crate::def_collector::DefCollector;
35-
use crate::error_helper::{OnUnknownData, StructCtor};
35+
use crate::diagnostics::impls::{OnUnknownData, StructCtor};
3636
use crate::imports::{ImportData, ImportKind, NameResolution, NameResolutionRef};
3737
use crate::macros::{MacroRulesDecl, MacroRulesScope, MacroRulesScopeRef};
3838
use crate::ref_mut::CmCell;
File renamed without changes.

compiler/rustc_resolve/src/diagnostics.rs renamed to compiler/rustc_resolve/src/diagnostics/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ use rustc_span::{Ident, Span, Spanned, Symbol};
1010
use crate::Res;
1111
use crate::late::{PatternSource, ResolvingRestrictionKind};
1212

13+
pub(crate) mod impls;
14+
1315
#[derive(Diagnostic)]
1416
#[diag("can't use {$is_self ->
1517
[true] `Self`

compiler/rustc_resolve/src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ use rustc_span::{Ident, Span, Symbol, kw, sym};
2525
use tracing::debug;
2626

2727
use crate::Namespace::{self, *};
28+
use crate::diagnostics::impls::{OnUnknownData, Suggestion};
2829
use crate::diagnostics::{
2930
self, CannotBeReexportedCratePublic, CannotBeReexportedCratePublicNS,
3031
CannotBeReexportedPrivate, CannotBeReexportedPrivateNS, CannotDetermineImportResolution,
3132
CannotGlobImportAllCrates, ConsiderAddingMacroExport, ConsiderMarkingAsPub,
3233
ConsiderMarkingAsPubCrate,
3334
};
34-
use crate::error_helper::{OnUnknownData, Suggestion};
3535
use crate::ref_mut::{CmCell, CmRefCell};
3636
use crate::{
3737
AmbiguityError, BindingKey, CmResolver, Decl, DeclData, DeclKind, Determinacy, Finalize,

compiler/rustc_resolve/src/late/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use thin_vec::{ThinVec, thin_vec};
3232
use tracing::debug;
3333

3434
use super::NoConstantGenericsReason;
35-
use crate::error_helper::{ImportSuggestion, LabelSuggestion, TypoSuggestion};
35+
use crate::diagnostics::impls::{ImportSuggestion, LabelSuggestion, TypoSuggestion};
3636
use crate::late::{
3737
AliasPossibility, LateResolutionVisitor, LifetimeBinderKind, LifetimeRes, LifetimeRibKind,
3838
LifetimeUseSet, QSelf, RibKind,

compiler/rustc_resolve/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use std::{fmt, mem};
2929

3030
use diagnostics::{ParamKindInEnumDiscriminant, ParamKindInNonTrivialAnonConst};
3131
use effective_visibilities::EffectiveVisibilitiesVisitor;
32-
use error_helper::{ImportSuggestion, LabelSuggestion, StructCtor, Suggestion};
3332
use hygiene::Macros20NormalizedSyntaxContext;
3433
use imports::{Import, ImportData, ImportKind, NameResolution, PendingDecl};
3534
use late::{
@@ -77,7 +76,9 @@ use rustc_span::{DUMMY_SP, Ident, Span, Symbol, kw, sym};
7776
use smallvec::{SmallVec, smallvec};
7877
use tracing::{debug, instrument};
7978

80-
use crate::error_helper::OnUnknownData;
79+
use crate::diagnostics::impls::{
80+
ImportSuggestion, LabelSuggestion, OnUnknownData, StructCtor, Suggestion,
81+
};
8182
use crate::imports::NameResolutionRef;
8283
use crate::ref_mut::{CmCell, CmRefCell};
8384

@@ -86,7 +87,6 @@ mod check_unused;
8687
mod def_collector;
8788
mod diagnostics;
8889
mod effective_visibilities;
89-
mod error_helper;
9090
mod ident;
9191
mod imports;
9292
mod late;

library/std/src/sys/env/unix.rs

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,19 @@ pub unsafe fn environ() -> *mut *const *const c_char {
3838
unsafe { libc::_NSGetEnviron() as *mut *const *const c_char }
3939
}
4040

41-
// On FreeBSD, environ comes from CRT rather than libc
41+
// On FreeBSD, environ lives in crt1.o, not libc.so, so a shared library
42+
// cannot take a strong link-time reference to it (#153451), and dlsym cannot
43+
// find it in a statically linked executable, which has no dynamic symbol
44+
// table to search (#158939). A weak reference covers both: it binds at link
45+
// time in any executable, and in a shared library the runtime linker
46+
// resolves it against the environ the executable exports.
4247
#[cfg(target_os = "freebsd")]
4348
pub unsafe fn environ() -> *mut *const *const c_char {
44-
use crate::sync::LazyLock;
45-
46-
struct Environ(*mut *const *const c_char);
47-
unsafe impl Send for Environ {}
48-
unsafe impl Sync for Environ {}
49-
50-
static ENVIRON: LazyLock<Environ> = LazyLock::new(|| {
51-
Environ(unsafe {
52-
libc::dlsym(libc::RTLD_DEFAULT, c"environ".as_ptr()) as *mut *const *const c_char
53-
})
54-
});
55-
ENVIRON.0
49+
unsafe extern "C" {
50+
#[linkage = "extern_weak"]
51+
static environ: *mut *const *const c_char;
52+
}
53+
unsafe { environ }
5654
}
5755

5856
// Use the `environ` static which is part of POSIX.
@@ -75,14 +73,19 @@ pub fn env_read_lock() -> impl Drop {
7573
pub fn env() -> Env {
7674
unsafe {
7775
let _guard = env_read_lock();
78-
let mut environ = *environ();
7976
let mut result = Vec::new();
80-
if !environ.is_null() {
81-
while !(*environ).is_null() {
82-
if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) {
83-
result.push(key_value);
77+
// A null return means the platform could not locate the symbol;
78+
// treat it like an empty environment.
79+
let environ_ptr = environ();
80+
if !environ_ptr.is_null() {
81+
let mut environ = *environ_ptr;
82+
if !environ.is_null() {
83+
while !(*environ).is_null() {
84+
if let Some(key_value) = parse(CStr::from_ptr(*environ).to_bytes()) {
85+
result.push(key_value);
86+
}
87+
environ = environ.add(1);
8488
}
85-
environ = environ.add(1);
8689
}
8790
}
8891
return Env::new(result);

library/std/src/sys/stdio/windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ impl io::Read for Stdin {
278278
Ok(bytes_copied)
279279
} else if buf.len() - bytes_copied < 4 {
280280
// Not enough space to get a UTF-8 byte. We will use the incomplete UTF8.
281-
let mut utf16_buf = [MaybeUninit::new(0); 1];
281+
let mut utf16_buf = [MaybeUninit::new(0); 2];
282282
// Read one u16 character.
283283
let read = read_u16s_fixup_surrogates(handle, &mut utf16_buf, 1, &mut self.surrogate)?;
284284
// Read bytes, using the (now-empty) self.incomplete_utf8 as extra space.

src/bootstrap/mk/Makefile.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ prepare:
106106
SKIP_COMPILER := --skip=compiler
107107
SKIP_SRC := --skip=src
108108
TEST_SET1 := $(SKIP_COMPILER) $(SKIP_SRC)
109-
TEST_SET2 := --skip=tests --skip=coverage-map --skip=coverage-run --skip=library --skip=tidyselftest
109+
TEST_SET2 := --skip=tests --skip=library --skip=tidyselftest
110110

111111
## MSVC native builders
112112

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,6 +1975,12 @@ impl Step for Coverage {
19751975
for mode in Self::ALL_MODES {
19761976
run = run.alias(mode.as_str());
19771977
}
1978+
1979+
// Allow `./x test --skip=tests` to properly skip the coverage tests,
1980+
// by not treating the `coverage-map` and `coverage-run` aliases as
1981+
// implied command-line arguments.
1982+
run = run.default_to_suites_only();
1983+
19781984
run
19791985
}
19801986

@@ -2016,13 +2022,6 @@ impl Step for Coverage {
20162022
!run.builder.config.skip.iter().any(|skip| skip == Path::new(mode.as_str()))
20172023
});
20182024

2019-
// FIXME(Zalathar): Make these commands skip all coverage tests, as expected:
2020-
// - `./x test --skip=tests`
2021-
// - `./x test --skip=tests/coverage`
2022-
// - `./x test --skip=coverage`
2023-
// Skip handling currently doesn't have a way to know that skipping the coverage
2024-
// suite should also skip the `coverage-map` and `coverage-run` aliases.
2025-
20262025
for mode in modes {
20272026
run.builder.ensure(Coverage { compiler, target, mode });
20282027
}

0 commit comments

Comments
 (0)