Skip to content

Commit 3160f10

Browse files
committed
Auto merge of #128650 - matthiaskrgr:rollup-gvrnowj, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #127655 (turn `invalid_type_param_default` into a `FutureReleaseErrorReportInDeps`) - #127974 (force compiling std from source if modified) - #128026 (std::thread: available_parallelism implementation for vxWorks proposal.) - #128362 (add test for symbol visibility of `#[naked]` functions) - #128500 (Add test for updating enum discriminant through pointer) - #128630 (docs(resolve): more explain about `target`) - #128638 (run-make: enable msvc for `link-dedup`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents ab1527f + 0c0354d commit 3160f10

File tree

20 files changed

+371
-48
lines changed

20 files changed

+371
-48
lines changed

compiler/rustc_feature/src/removed.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ declare_features! (
8282
/// Allows the use of `#[derive(Anything)]` as sugar for `#[derive_Anything]`.
8383
(removed, custom_derive, "1.32.0", Some(29644),
8484
Some("subsumed by `#[proc_macro_derive]`")),
85+
/// Allows default type parameters to influence type inference.
86+
(removed, default_type_parameter_fallback, "CURRENT_RUSTC_VERSION", Some(27336),
87+
Some("never properly implemented; requires significant design work")),
8588
/// Allows using `#[doc(keyword = "...")]`.
8689
(removed, doc_keyword, "1.28.0", Some(51315),
8790
Some("merged into `#![feature(rustdoc_internals)]`")),

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,6 @@ declare_features! (
431431
(unstable, custom_test_frameworks, "1.30.0", Some(50297)),
432432
/// Allows declarative macros 2.0 (`macro`).
433433
(unstable, decl_macro, "1.17.0", Some(39412)),
434-
/// Allows default type parameters to influence type inference.
435-
(unstable, default_type_parameter_fallback, "1.3.0", Some(27336)),
436434
/// Allows using `#[deprecated_safe]` to deprecate the safeness of a function or trait
437435
(unstable, deprecated_safe, "1.61.0", Some(94978)),
438436
/// Allows having using `suggestion` in the `#[deprecated]` attribute.

compiler/rustc_hir_analysis/src/collect/generics_of.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,6 @@ pub(super) fn generics_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> ty::Generics {
338338
if default.is_some() {
339339
match allow_defaults {
340340
Defaults::Allowed => {}
341-
Defaults::FutureCompatDisallowed
342-
if tcx.features().default_type_parameter_fallback => {}
343341
Defaults::FutureCompatDisallowed => {
344342
tcx.node_span_lint(
345343
lint::builtin::INVALID_TYPE_PARAM_DEFAULT,

compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,7 @@ declare_lint! {
12671267
Deny,
12681268
"type parameter default erroneously allowed in invalid location",
12691269
@future_incompatible = FutureIncompatibleInfo {
1270-
reason: FutureIncompatibilityReason::FutureReleaseErrorDontReportInDeps,
1270+
reason: FutureIncompatibilityReason::FutureReleaseErrorReportInDeps,
12711271
reference: "issue #36887 <https://github.com/rust-lang/rust/issues/36887>",
12721272
};
12731273
}

compiler/rustc_resolve/src/imports.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub(crate) enum ImportKind<'a> {
4848
/// `source` in `use prefix::source as target`.
4949
source: Ident,
5050
/// `target` in `use prefix::source as target`.
51+
/// It will directly use `source` when the format is `use prefix::source`.
5152
target: Ident,
5253
/// Bindings to which `source` refers to.
5354
source_bindings: PerNS<Cell<Result<NameBinding<'a>, Determinacy>>>,

config.example.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,8 @@
472472
# This is mostly useful for tools; if you have changes to `compiler/` or `library/` they will be ignored.
473473
#
474474
# Set this to "if-unchanged" to only download if the compiler and standard library have not been modified.
475-
# Set this to `true` to download unconditionally (useful if e.g. you are only changing doc-comments).
475+
# Set this to `true` to download unconditionally. This is useful if you are working on tools, doc-comments,
476+
# or library (you will be able to build the standard library without needing to build the compiler).
476477
#download-rustc = false
477478

478479
# Number of codegen units to use for each compiler invocation. A value of 0

library/std/src/sys/pal/unix/thread.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,18 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
455455

456456
Ok(NonZero::new_unchecked(sinfo.cpu_count as usize))
457457
}
458+
} else if #[cfg(target_os = "vxworks")] {
459+
// Note: there is also `vxCpuConfiguredGet`, closer to _SC_NPROCESSORS_CONF
460+
// expectations than the actual cores availability.
461+
extern "C" {
462+
fn vxCpuEnabledGet() -> libc::cpuset_t;
463+
}
464+
465+
// always fetches a valid bitmask
466+
let set = unsafe { vxCpuEnabledGet() };
467+
Ok(NonZero::new_unchecked(set.count_ones() as usize))
458468
} else {
459-
// FIXME: implement on vxWorks, Redox, l4re
469+
// FIXME: implement on Redox, l4re
460470
Err(io::const_io_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform"))
461471
}
462472
}

src/bootstrap/src/core/build_steps/compile.rs

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ use crate::core::builder::{
2626
use crate::core::config::{DebuginfoLevel, LlvmLibunwind, RustcLto, TargetSelection};
2727
use crate::utils::exec::command;
2828
use crate::utils::helpers::{
29-
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
29+
self, exe, get_clang_cl_resource_dir, get_closest_merge_base_commit, is_debug_info, is_dylib,
30+
symlink_dir, t, up_to_date,
3031
};
3132
use crate::{CLang, Compiler, DependencyType, GitRepo, Mode, LLVM_TOOLS};
3233

@@ -114,21 +115,43 @@ impl Step for Std {
114115
const DEFAULT: bool = true;
115116

116117
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
117-
// When downloading stage1, the standard library has already been copied to the sysroot, so
118-
// there's no need to rebuild it.
119-
let builder = run.builder;
120-
run.crate_or_deps("sysroot")
121-
.path("library")
122-
.lazy_default_condition(Box::new(|| !builder.download_rustc()))
118+
run.crate_or_deps("sysroot").path("library")
123119
}
124120

125121
fn make_run(run: RunConfig<'_>) {
126122
let crates = std_crates_for_run_make(&run);
123+
let builder = run.builder;
124+
125+
// Force compilation of the standard library from source if the `library` is modified. This allows
126+
// library team to compile the standard library without needing to compile the compiler with
127+
// the `rust.download-rustc=true` option.
128+
let force_recompile =
129+
if builder.rust_info().is_managed_git_subrepository() && builder.download_rustc() {
130+
let closest_merge_commit = get_closest_merge_base_commit(
131+
Some(&builder.src),
132+
&builder.config.git_config(),
133+
&builder.config.stage0_metadata.config.git_merge_commit_email,
134+
&[],
135+
)
136+
.unwrap();
137+
138+
// Check if `library` has changes (returns false otherwise)
139+
!t!(helpers::git(Some(&builder.src))
140+
.args(["diff-index", "--quiet", &closest_merge_commit])
141+
.arg("--")
142+
.arg(builder.src.join("library"))
143+
.as_command_mut()
144+
.status())
145+
.success()
146+
} else {
147+
false
148+
};
149+
127150
run.builder.ensure(Std {
128151
compiler: run.builder.compiler(run.builder.top_stage, run.build_triple()),
129152
target: run.target,
130153
crates,
131-
force_recompile: false,
154+
force_recompile,
132155
extra_rust_args: &[],
133156
is_for_mir_opt_tests: false,
134157
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ compile-flags: -O
2+
//@ min-llvm-version: 19
3+
4+
#![crate_type = "lib"]
5+
6+
pub enum State {
7+
A([u8; 753]),
8+
B([u8; 753]),
9+
}
10+
11+
// CHECK-LABEL: @update
12+
#[no_mangle]
13+
pub unsafe fn update(s: *mut State) {
14+
// CHECK-NEXT: start:
15+
// CHECK-NEXT: store i8
16+
// CHECK-NEXT: ret
17+
let State::A(v) = s.read() else { std::hint::unreachable_unchecked() };
18+
s.write(State::B(v));
19+
}

tests/run-make/link-dedup/rmake.rs

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,37 @@
55
// Without the --cfg flag, there should be a single -ltesta, no more, no less.
66
// See https://github.com/rust-lang/rust/pull/84794
77

8-
//@ ignore-msvc
8+
use std::fmt::Write;
99

10-
use run_make_support::rustc;
10+
use run_make_support::{is_msvc, rustc};
1111

1212
fn main() {
1313
rustc().input("depa.rs").run();
1414
rustc().input("depb.rs").run();
1515
rustc().input("depc.rs").run();
16+
1617
let output = rustc().input("empty.rs").cfg("bar").run_fail();
17-
output.assert_stderr_contains(r#""-ltesta" "-ltestb" "-ltesta""#);
18-
let output = rustc().input("empty.rs").run_fail();
19-
output.assert_stderr_contains(r#""-ltesta""#);
20-
let output = rustc().input("empty.rs").run_fail();
21-
output.assert_stderr_not_contains(r#""-ltestb""#);
18+
output.assert_stderr_contains(needle_from_libs(&["testa", "testb", "testa"]));
19+
2220
let output = rustc().input("empty.rs").run_fail();
23-
output.assert_stderr_not_contains(r#""-ltesta" "-ltesta" "-ltesta""#);
21+
output.assert_stderr_contains(needle_from_libs(&["testa"]));
22+
output.assert_stderr_not_contains(needle_from_libs(&["testb"]));
23+
output.assert_stderr_not_contains(needle_from_libs(&["testa", "testa", "testa"]));
24+
// Adjacent identical native libraries are no longer deduplicated if
25+
// they come from different crates (https://github.com/rust-lang/rust/pull/103311)
26+
// so the following will fail:
27+
//output.assert_stderr_not_contains(needle_from_libs(&["testa", "testa"]));
28+
}
29+
30+
fn needle_from_libs(libs: &[&str]) -> String {
31+
let mut needle = String::new();
32+
for lib in libs {
33+
if is_msvc() {
34+
let _ = needle.write_fmt(format_args!(r#""{lib}.lib" "#));
35+
} else {
36+
let _ = needle.write_fmt(format_args!(r#""-l{lib}" "#));
37+
}
38+
}
39+
needle.pop(); // remove trailing space
40+
needle
2441
}

0 commit comments

Comments
 (0)