Skip to content

Commit f8cc146

Browse files
committed
Auto merge of #132237 - matthiaskrgr:rollup-ulogwtd, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #132043 (Simplify param handling in `resolve_bound_vars`) - #132214 (Cleanup: Move an impl-Trait check from AST validation to AST lowering) - #132221 (Clean up some comments on lint implementation) - #132228 (Revert "ci update freebsd version proposal, freebsd 12 being eol.") - #132234 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2f438e0 + bfcf442 commit f8cc146

37 files changed

+612
-299
lines changed

.github/workflows/ci.yml

+19-25
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
name: CI
22

33
on:
4-
push:
5-
# Run in PRs and for bors, but not on master.
6-
branches:
7-
- 'auto'
8-
- 'try'
4+
merge_group:
95
pull_request:
106
branches:
117
- 'master'
@@ -38,7 +34,7 @@ jobs:
3834
# The `style` job only runs on Linux; this makes sure the Windows-host-specific
3935
# code is also covered by clippy.
4036
- name: Check clippy
41-
if: matrix.os == 'windows-latest'
37+
if: ${{ matrix.os == 'windows-latest' }}
4238
run: ./miri clippy -- -D warnings
4339

4440
- name: Test Miri
@@ -62,27 +58,25 @@ jobs:
6258
- name: rustdoc
6359
run: RUSTDOCFLAGS="-Dwarnings" ./miri doc --document-private-items
6460

65-
# These jobs doesn't actually test anything, but they're only used to tell
66-
# bors the build completed, as there is no practical way to detect when a
67-
# workflow is successful listening to webhooks only.
68-
#
61+
# Summary job for the merge queue.
6962
# ALL THE PREVIOUS JOBS NEED TO BE ADDED TO THE `needs` SECTION OF THIS JOB!
70-
end-success:
71-
name: bors build finished
72-
runs-on: ubuntu-latest
63+
# And they should be added below in `cron-fail-notify` as well.
64+
conclusion:
7365
needs: [build, style]
74-
if: github.event.pusher.name == 'bors' && success()
75-
steps:
76-
- name: mark the job as a success
77-
run: exit 0
78-
end-failure:
79-
name: bors build finished
66+
# We need to ensure this job does *not* get skipped if its dependencies fail,
67+
# because a skipped job is considered a success by GitHub. So we have to
68+
# overwrite `if:`. We use `!cancelled()` to ensure the job does still not get run
69+
# when the workflow is canceled manually.
70+
if: ${{ !cancelled() }}
8071
runs-on: ubuntu-latest
81-
needs: [build, style]
82-
if: github.event.pusher.name == 'bors' && (failure() || cancelled())
8372
steps:
84-
- name: mark the job as a failure
85-
run: exit 1
73+
# Manually check the status of all dependencies. `if: failure()` does not work.
74+
- name: Conclusion
75+
run: |
76+
# Print the dependent jobs to see them in the CI log
77+
jq -C <<< '${{ toJson(needs) }}'
78+
# Check if all jobs that we depend on (in the needs array) were successful.
79+
jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
8680
8781
cron-fail-notify:
8882
name: cronjob failure notification
@@ -93,7 +87,7 @@ jobs:
9387
# ... and create a PR.
9488
pull-requests: write
9589
needs: [build, style]
96-
if: github.event_name == 'schedule' && failure()
90+
if: ${{ github.event_name == 'schedule' && failure() }}
9791
steps:
9892
# Send a Zulip notification
9993
- name: Install zulip-send
@@ -145,7 +139,7 @@ jobs:
145139
git push -u origin $BRANCH
146140
- name: Create Pull Request
147141
run: |
148-
PR=$(gh pr create -B master --title 'Automatic Rustup' --body '')
142+
PR=$(gh pr create -B master --title 'Automatic Rustup' --body 'Please close and re-open this PR to trigger CI, then enable auto-merge.')
149143
~/.local/bin/zulip-send --user $ZULIP_BOT_EMAIL --api-key $ZULIP_API_TOKEN --site https://rust-lang.zulipchat.com \
150144
--stream miri --subject "Miri Build Failure ($(date -u +%Y-%m))" \
151145
--message "A PR doing a rustc-pull [has been automatically created]($PR) for your convenience."

ci/ci.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ case $HOST_TARGET in
154154
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX time hashmap random threadname pthread fs libc-pipe
155155
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX time hashmap random thread sync available-parallelism tls libc-pipe
156156
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX time hashmap random thread sync available-parallelism tls libc-pipe
157-
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap pthread --skip threadname
157+
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX time hashmap threadname pthread
158158
TEST_TARGET=wasm32-wasip2 run_tests_minimal $BASIC wasm
159159
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal no_std empty_main wasm # this target doesn't really have std
160160
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
17a19e684cdf3ca088af8b4da6a6209d128913f4
1+
814df6e50eaf89b90793e7d9618bb60f1f18377a

src/borrow_tracker/stacked_borrows/diagnostics.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,11 @@ impl<'history, 'ecx, 'tcx> DiagnosticCx<'history, 'ecx, 'tcx> {
424424
}
425425

426426
#[inline(never)] // This is only called on fatal code paths
427-
pub(super) fn protector_error(&self, item: &Item, kind: ProtectorKind) -> InterpErrorKind<'tcx> {
427+
pub(super) fn protector_error(
428+
&self,
429+
item: &Item,
430+
kind: ProtectorKind,
431+
) -> InterpErrorKind<'tcx> {
428432
let protected = match kind {
429433
ProtectorKind::WeakProtector => "weakly protected",
430434
ProtectorKind::StrongProtector => "strongly protected",

src/intrinsics/mod.rs

+30
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
145145
this.write_scalar(Scalar::from_bool(branch), dest)?;
146146
}
147147

148+
"floorf16" | "ceilf16" | "truncf16" | "roundf16" | "rintf16" => {
149+
let [f] = check_arg_count(args)?;
150+
let f = this.read_scalar(f)?.to_f16()?;
151+
let mode = match intrinsic_name {
152+
"floorf16" => Round::TowardNegative,
153+
"ceilf16" => Round::TowardPositive,
154+
"truncf16" => Round::TowardZero,
155+
"roundf16" => Round::NearestTiesToAway,
156+
"rintf16" => Round::NearestTiesToEven,
157+
_ => bug!(),
158+
};
159+
let res = f.round_to_integral(mode).value;
160+
let res = this.adjust_nan(res, &[f]);
161+
this.write_scalar(res, dest)?;
162+
}
148163
"floorf32" | "ceilf32" | "truncf32" | "roundf32" | "rintf32" => {
149164
let [f] = check_arg_count(args)?;
150165
let f = this.read_scalar(f)?.to_f32()?;
@@ -175,6 +190,21 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
175190
let res = this.adjust_nan(res, &[f]);
176191
this.write_scalar(res, dest)?;
177192
}
193+
"floorf128" | "ceilf128" | "truncf128" | "roundf128" | "rintf128" => {
194+
let [f] = check_arg_count(args)?;
195+
let f = this.read_scalar(f)?.to_f128()?;
196+
let mode = match intrinsic_name {
197+
"floorf128" => Round::TowardNegative,
198+
"ceilf128" => Round::TowardPositive,
199+
"truncf128" => Round::TowardZero,
200+
"roundf128" => Round::NearestTiesToAway,
201+
"rintf128" => Round::NearestTiesToEven,
202+
_ => bug!(),
203+
};
204+
let res = f.round_to_integral(mode).value;
205+
let res = this.adjust_nan(res, &[f]);
206+
this.write_scalar(res, dest)?;
207+
}
178208

179209
#[rustfmt::skip]
180210
| "sinf32"

src/intrinsics/simd.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use either::Either;
22
use rustc_apfloat::{Float, Round};
3+
use rustc_middle::ty::FloatTy;
34
use rustc_middle::ty::layout::LayoutOf;
4-
use rustc_middle::{mir, ty, ty::FloatTy};
5+
use rustc_middle::{mir, ty};
56
use rustc_span::{Symbol, sym};
67
use rustc_target::abi::{Endian, HasDataLayout};
78

@@ -630,12 +631,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
630631
let (right, right_len) = this.project_to_simd(right)?;
631632
let (dest, dest_len) = this.project_to_simd(dest)?;
632633

633-
let index = generic_args[2]
634-
.expect_const()
635-
.try_to_valtree()
636-
.unwrap()
637-
.0
638-
.unwrap_branch();
634+
let index =
635+
generic_args[2].expect_const().try_to_valtree().unwrap().0.unwrap_branch();
639636
let index_len = index.len();
640637

641638
assert_eq!(left_len, right_len);

src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ pub use crate::range_map::RangeMap;
147147
pub use crate::shims::EmulateItemResult;
148148
pub use crate::shims::env::{EnvVars, EvalContextExt as _};
149149
pub use crate::shims::foreign_items::{DynSym, EvalContextExt as _};
150-
pub use crate::shims::io_error::{EvalContextExt as _, LibcError};
150+
pub use crate::shims::io_error::{EvalContextExt as _, IoError, LibcError};
151151
pub use crate::shims::os_str::EvalContextExt as _;
152152
pub use crate::shims::panic::{CatchUnwindData, EvalContextExt as _};
153153
pub use crate::shims::time::EvalContextExt as _;

src/shims/foreign_items.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -447,8 +447,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
447447
} else {
448448
// If this does not fit in an isize, return null and, on Unix, set errno.
449449
if this.target_os_is_unix() {
450-
let einval = this.eval_libc("ENOMEM");
451-
this.set_last_error(einval)?;
450+
this.set_last_error(LibcError("ENOMEM"))?;
452451
}
453452
this.write_null(dest)?;
454453
}
@@ -464,8 +463,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
464463
} else {
465464
// On size overflow, return null and, on Unix, set errno.
466465
if this.target_os_is_unix() {
467-
let einval = this.eval_libc("ENOMEM");
468-
this.set_last_error(einval)?;
466+
this.set_last_error(LibcError("ENOMEM"))?;
469467
}
470468
this.write_null(dest)?;
471469
}
@@ -486,8 +484,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
486484
} else {
487485
// If this does not fit in an isize, return null and, on Unix, set errno.
488486
if this.target_os_is_unix() {
489-
let einval = this.eval_libc("ENOMEM");
490-
this.set_last_error(einval)?;
487+
this.set_last_error(LibcError("ENOMEM"))?;
491488
}
492489
this.write_null(dest)?;
493490
}

src/shims/io_error.rs

+10
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,16 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
141141
interp_ok(Scalar::from_i32(-1))
142142
}
143143

144+
/// Sets the last OS error and return `-1` as a `i64`-typed Scalar
145+
fn set_last_error_and_return_i64(
146+
&mut self,
147+
err: impl Into<IoError>,
148+
) -> InterpResult<'tcx, Scalar> {
149+
let this = self.eval_context_mut();
150+
this.set_last_error(err)?;
151+
interp_ok(Scalar::from_i64(-1))
152+
}
153+
144154
/// Gets the last error variable.
145155
fn get_last_error(&mut self) -> InterpResult<'tcx, Scalar> {
146156
let this = self.eval_context_mut();

src/shims/time.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
8181
} else if relative_clocks.contains(&clk_id) {
8282
this.machine.clock.now().duration_since(this.machine.clock.epoch())
8383
} else {
84-
let einval = this.eval_libc("EINVAL");
85-
this.set_last_error(einval)?;
86-
return interp_ok(Scalar::from_i32(-1));
84+
return this.set_last_error_and_return_i32(LibcError("EINVAL"));
8785
};
8886

8987
let tv_sec = duration.as_secs();
@@ -109,9 +107,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
109107
// Using tz is obsolete and should always be null
110108
let tz = this.read_pointer(tz_op)?;
111109
if !this.ptr_is_null(tz)? {
112-
let einval = this.eval_libc("EINVAL");
113-
this.set_last_error(einval)?;
114-
return interp_ok(Scalar::from_i32(-1));
110+
return this.set_last_error_and_return_i32(LibcError("EINVAL"));
115111
}
116112

117113
let duration = system_time_to_duration(&SystemTime::now())?;
@@ -323,9 +319,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
323319
let duration = match this.read_timespec(&req)? {
324320
Some(duration) => duration,
325321
None => {
326-
let einval = this.eval_libc("EINVAL");
327-
this.set_last_error(einval)?;
328-
return interp_ok(Scalar::from_i32(-1));
322+
return this.set_last_error_and_return_i32(LibcError("EINVAL"));
329323
}
330324
};
331325

src/shims/unix/android/foreign_items.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use rustc_span::Symbol;
22
use rustc_target::spec::abi::Abi;
33

4+
use crate::shims::unix::android::thread::prctl;
45
use crate::*;
56

67
pub fn is_dyn_sym(_name: &str) -> bool {
@@ -25,6 +26,9 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
2526
this.write_scalar(errno_place.to_ref(this).to_scalar(), dest)?;
2627
}
2728

29+
// Threading
30+
"prctl" => prctl(this, link_name, abi, args, dest)?,
31+
2832
_ => return interp_ok(EmulateItemResult::NotSupported),
2933
}
3034
interp_ok(EmulateItemResult::NeedsReturn)

src/shims/unix/android/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pub mod foreign_items;
2+
pub mod thread;

src/shims/unix/android/thread.rs

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
use rustc_span::Symbol;
2+
use rustc_target::abi::Size;
3+
use rustc_target::spec::abi::Abi;
4+
5+
use crate::helpers::check_min_arg_count;
6+
use crate::shims::unix::thread::EvalContextExt as _;
7+
use crate::*;
8+
9+
const TASK_COMM_LEN: usize = 16;
10+
11+
pub fn prctl<'tcx>(
12+
this: &mut MiriInterpCx<'tcx>,
13+
link_name: Symbol,
14+
abi: Abi,
15+
args: &[OpTy<'tcx>],
16+
dest: &MPlaceTy<'tcx>,
17+
) -> InterpResult<'tcx> {
18+
// We do not use `check_shim` here because `prctl` is variadic. The argument
19+
// count is checked bellow.
20+
this.check_abi_and_shim_symbol_clash(abi, Abi::C { unwind: false }, link_name)?;
21+
22+
// FIXME: Use constants once https://github.com/rust-lang/libc/pull/3941 backported to the 0.2 branch.
23+
let pr_set_name = 15;
24+
let pr_get_name = 16;
25+
26+
let [op] = check_min_arg_count("prctl", args)?;
27+
let res = match this.read_scalar(op)?.to_i32()? {
28+
op if op == pr_set_name => {
29+
let [_, name] = check_min_arg_count("prctl(PR_SET_NAME, ...)", args)?;
30+
let name = this.read_scalar(name)?;
31+
let thread = this.pthread_self()?;
32+
// The Linux kernel silently truncates long names.
33+
// https://www.man7.org/linux/man-pages/man2/PR_SET_NAME.2const.html
34+
let res =
35+
this.pthread_setname_np(thread, name, TASK_COMM_LEN, /* truncate */ true)?;
36+
assert!(res);
37+
Scalar::from_u32(0)
38+
}
39+
op if op == pr_get_name => {
40+
let [_, name] = check_min_arg_count("prctl(PR_GET_NAME, ...)", args)?;
41+
let name = this.read_scalar(name)?;
42+
let thread = this.pthread_self()?;
43+
let len = Scalar::from_target_usize(TASK_COMM_LEN as u64, this);
44+
this.check_ptr_access(
45+
name.to_pointer(this)?,
46+
Size::from_bytes(TASK_COMM_LEN),
47+
CheckInAllocMsg::MemoryAccessTest,
48+
)?;
49+
let res = this.pthread_getname_np(thread, name, len, /* truncate*/ false)?;
50+
assert!(res);
51+
Scalar::from_u32(0)
52+
}
53+
op => throw_unsup_format!("Miri does not support `prctl` syscall with op={}", op),
54+
};
55+
this.write_scalar(res, dest)?;
56+
interp_ok(())
57+
}

0 commit comments

Comments
 (0)