Skip to content

Commit 1836e3b

Browse files
committed
Auto merge of rust-lang#71951 - Dylan-DPC:rollup-j9v1p0f, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - rust-lang#71269 (Define UB in float-to-int casts to saturate) - rust-lang#71591 (use new interface to create threads on HermitCore) - rust-lang#71819 (x.py: Give a more helpful error message if curl isn't installed) - rust-lang#71893 (Use the `impls` module to import pre-existing dataflow analyses) - rust-lang#71929 (Use -fvisibility=hidden for libunwind) - rust-lang#71937 (Ignore SGX on a few ui tests) - rust-lang#71944 (Add comment for `Ord` implementation for array) Failed merges: r? @ghost
2 parents 339f574 + fbb4ccb commit 1836e3b

36 files changed

+547
-171
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -1375,9 +1375,9 @@ dependencies = [
13751375

13761376
[[package]]
13771377
name = "hermit-abi"
1378-
version = "0.1.10"
1378+
version = "0.1.12"
13791379
source = "registry+https://github.com/rust-lang/crates.io-index"
1380-
checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e"
1380+
checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4"
13811381
dependencies = [
13821382
"compiler_builtins",
13831383
"libc",

src/bootstrap/bootstrap.py

+25-23
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def _download(path, url, probably_big, verbose, exception):
7979
option = "-#"
8080
else:
8181
option = "-s"
82+
require(["curl", "--version"])
8283
run(["curl", option,
8384
"-y", "30", "-Y", "10", # timeout if speed is < 10 bytes/sec for > 30 seconds
8485
"--connect-timeout", "30", # timeout if cannot connect within 30 seconds
@@ -143,6 +144,21 @@ def run(args, verbose=False, exception=False, **kwargs):
143144
sys.exit(err)
144145

145146

147+
def require(cmd, exit=True):
148+
'''Run a command, returning its output.
149+
On error,
150+
If `exit` is `True`, exit the process.
151+
Otherwise, return None.'''
152+
try:
153+
return subprocess.check_output(cmd).strip()
154+
except (subprocess.CalledProcessError, OSError) as exc:
155+
if not exit:
156+
return None
157+
print("error: unable to run `{}`: {}".format(' '.join(cmd), exc))
158+
print("Please make sure it's installed and in the path.")
159+
sys.exit(1)
160+
161+
146162
def stage0_data(rust_root):
147163
"""Build a dictionary from stage0.txt"""
148164
nightlies = os.path.join(rust_root, "src/stage0.txt")
@@ -164,16 +180,12 @@ def format_build_time(duration):
164180
def default_build_triple():
165181
"""Build triple as in LLVM"""
166182
default_encoding = sys.getdefaultencoding()
167-
try:
168-
ostype = subprocess.check_output(
169-
['uname', '-s']).strip().decode(default_encoding)
170-
cputype = subprocess.check_output(
171-
['uname', '-m']).strip().decode(default_encoding)
172-
except (subprocess.CalledProcessError, OSError):
173-
if sys.platform == 'win32':
174-
return 'x86_64-pc-windows-msvc'
175-
err = "uname not found"
176-
sys.exit(err)
183+
required = not sys.platform == 'win32'
184+
ostype = require(["uname", "-s"], exit=required).decode(default_encoding)
185+
cputype = require(['uname', '-m'], exit=required).decode(default_encoding)
186+
187+
if ostype is None or cputype is None:
188+
return 'x86_64-pc-windows-msvc'
177189

178190
# The goal here is to come up with the same triple as LLVM would,
179191
# at least for the subset of platforms we're willing to target.
@@ -203,12 +215,7 @@ def default_build_triple():
203215
# output from that option is too generic for our purposes (it will
204216
# always emit 'i386' on x86/amd64 systems). As such, isainfo -k
205217
# must be used instead.
206-
try:
207-
cputype = subprocess.check_output(
208-
['isainfo', '-k']).strip().decode(default_encoding)
209-
except (subprocess.CalledProcessError, OSError):
210-
err = "isainfo not found"
211-
sys.exit(err)
218+
cputype = require(['isainfo', '-k']).decode(default_encoding)
212219
elif ostype.startswith('MINGW'):
213220
# msys' `uname` does not print gcc configuration, but prints msys
214221
# configuration. so we cannot believe `uname -m`:
@@ -766,13 +773,8 @@ def update_submodules(self):
766773
default_encoding = sys.getdefaultencoding()
767774

768775
# check the existence and version of 'git' command
769-
try:
770-
git_version_output = subprocess.check_output(['git', '--version'])
771-
git_version_str = git_version_output.strip().split()[2].decode(default_encoding)
772-
self.git_version = distutils.version.LooseVersion(git_version_str)
773-
except (subprocess.CalledProcessError, OSError):
774-
print("error: `git` is not found, please make sure it's installed and in the path.")
775-
sys.exit(1)
776+
git_version_str = require(['git', '--version']).split()[2].decode(default_encoding)
777+
self.git_version = distutils.version.LooseVersion(git_version_str)
776778

777779
slow_submodules = self.get_toml('fast-submodules') == "false"
778780
start_time = time()

src/libcore/array/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ where
375375
}
376376
}
377377

378+
/// Implements comparison of arrays lexicographically.
378379
#[stable(feature = "rust1", since = "1.0.0")]
379380
impl<T: Ord, const N: usize> Ord for [T; N]
380381
where

src/librustc_codegen_ssa/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ fn cast_float_to_int<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
768768
) -> Bx::Value {
769769
let fptosui_result = if signed { bx.fptosi(x, int_ty) } else { bx.fptoui(x, int_ty) };
770770

771-
if !bx.cx().sess().opts.debugging_opts.saturating_float_casts {
771+
if let Some(false) = bx.cx().sess().opts.debugging_opts.saturating_float_casts {
772772
return fptosui_result;
773773
}
774774

src/librustc_interface/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ fn test_debugging_options_tracking_hash() {
559559
tracked!(sanitizer, Some(Sanitizer::Address));
560560
tracked!(sanitizer_memory_track_origins, 2);
561561
tracked!(sanitizer_recover, vec![Sanitizer::Address]);
562-
tracked!(saturating_float_casts, true);
562+
tracked!(saturating_float_casts, Some(true));
563563
tracked!(share_generics, Some(true));
564564
tracked!(show_span, Some(String::from("abc")));
565565
tracked!(src_hash_algorithm, Some(SourceFileHashAlgorithm::Sha1));

src/librustc_mir/borrow_check/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ use std::mem;
3232
use std::rc::Rc;
3333

3434
use crate::dataflow;
35+
use crate::dataflow::impls::{
36+
Borrows, EverInitializedPlaces, MaybeInitializedPlaces, MaybeUninitializedPlaces,
37+
};
3538
use crate::dataflow::indexes::{BorrowIndex, InitIndex, MoveOutIndex, MovePathIndex};
3639
use crate::dataflow::move_paths::{InitLocation, LookupResult, MoveData, MoveError};
37-
use crate::dataflow::Borrows;
38-
use crate::dataflow::EverInitializedPlaces;
3940
use crate::dataflow::MoveDataParamEnv;
4041
use crate::dataflow::{Analysis, BorrowckFlowState as Flows, BorrowckResults};
41-
use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
4242
use crate::transform::MirSource;
4343

4444
use self::diagnostics::{AccessKind, RegionName};

src/librustc_mir/borrow_check/nll.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use std::str::FromStr;
2121
use self::mir_util::PassWhere;
2222
use polonius_engine::{Algorithm, Output};
2323

24+
use crate::dataflow::impls::MaybeInitializedPlaces;
2425
use crate::dataflow::move_paths::{InitKind, InitLocation, MoveData};
25-
use crate::dataflow::MaybeInitializedPlaces;
2626
use crate::dataflow::ResultsCursor;
2727
use crate::transform::MirSource;
2828
use crate::util as mir_util;

src/librustc_mir/borrow_check/type_check/liveness/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ use rustc_middle::mir::{Body, Local};
33
use rustc_middle::ty::{RegionVid, TyCtxt};
44
use std::rc::Rc;
55

6+
use crate::dataflow::impls::MaybeInitializedPlaces;
67
use crate::dataflow::move_paths::MoveData;
7-
use crate::dataflow::MaybeInitializedPlaces;
88
use crate::dataflow::ResultsCursor;
99

1010
use crate::borrow_check::{

src/librustc_mir/borrow_check/type_check/liveness/trace.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use rustc_trait_selection::traits::query::type_op::outlives::DropckOutlives;
88
use rustc_trait_selection::traits::query::type_op::TypeOp;
99
use std::rc::Rc;
1010

11+
use crate::dataflow::impls::MaybeInitializedPlaces;
1112
use crate::dataflow::indexes::MovePathIndex;
1213
use crate::dataflow::move_paths::{HasMoveData, MoveData};
13-
use crate::dataflow::MaybeInitializedPlaces;
1414
use crate::dataflow::ResultsCursor;
1515

1616
use crate::borrow_check::{

src/librustc_mir/borrow_check/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ use rustc_trait_selection::traits::query::type_op::custom::CustomTypeOp;
3939
use rustc_trait_selection::traits::query::{Fallible, NoSolution};
4040
use rustc_trait_selection::traits::{self, ObligationCause, PredicateObligations};
4141

42+
use crate::dataflow::impls::MaybeInitializedPlaces;
4243
use crate::dataflow::move_paths::MoveData;
43-
use crate::dataflow::MaybeInitializedPlaces;
4444
use crate::dataflow::ResultsCursor;
4545
use crate::transform::{
4646
check_consts::ConstCx,

src/librustc_mir/dataflow/impls/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ use super::on_lookup_result_bits;
2121
use crate::dataflow::drop_flag_effects;
2222

2323
mod borrowed_locals;
24+
pub(super) mod borrows;
2425
mod liveness;
2526
mod storage_liveness;
2627

27-
pub use self::borrowed_locals::*;
28+
pub use self::borrowed_locals::{MaybeBorrowedLocals, MaybeMutBorrowedLocals};
29+
pub use self::borrows::Borrows;
2830
pub use self::liveness::MaybeLiveLocals;
29-
pub use self::storage_liveness::*;
30-
31-
pub(super) mod borrows;
31+
pub use self::storage_liveness::{MaybeRequiresStorage, MaybeStorageLive};
3232

3333
/// `MaybeInitializedPlaces` tracks all places that might be
3434
/// initialized upon reaching a particular point in the control flow

src/librustc_mir/dataflow/mod.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,12 @@ pub use self::framework::{
88
BottomValue, Engine, Forward, GenKill, GenKillAnalysis, Results, ResultsCursor,
99
ResultsRefCursor, ResultsVisitor,
1010
};
11-
pub use self::impls::{
12-
borrows::Borrows, DefinitelyInitializedPlaces, EverInitializedPlaces, MaybeBorrowedLocals,
13-
MaybeInitializedPlaces, MaybeLiveLocals, MaybeMutBorrowedLocals, MaybeRequiresStorage,
14-
MaybeStorageLive, MaybeUninitializedPlaces,
15-
};
1611

1712
use self::move_paths::MoveData;
1813

1914
pub mod drop_flag_effects;
2015
mod framework;
21-
mod impls;
16+
pub mod impls;
2217
pub mod move_paths;
2318

2419
pub(crate) mod indexes {

src/librustc_mir/transform/check_consts/validation.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use super::qualifs::{self, CustomEq, HasMutInterior, NeedsDrop};
2020
use super::resolver::FlowSensitiveAnalysis;
2121
use super::{is_lang_panic_fn, ConstCx, ConstKind, Qualif};
2222
use crate::const_eval::{is_const_fn, is_unstable_const_fn};
23-
use crate::dataflow::MaybeMutBorrowedLocals;
23+
use crate::dataflow::impls::MaybeMutBorrowedLocals;
2424
use crate::dataflow::{self, Analysis};
2525

2626
// We are using `MaybeMutBorrowedLocals` as a proxy for whether an item may have been mutated

src/librustc_mir/transform/elaborate_drops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use crate::dataflow;
2+
use crate::dataflow::impls::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
23
use crate::dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
34
use crate::dataflow::on_lookup_result_bits;
45
use crate::dataflow::MoveDataParamEnv;
56
use crate::dataflow::{on_all_children_bits, on_all_drop_children_bits};
67
use crate::dataflow::{Analysis, ResultsCursor};
7-
use crate::dataflow::{MaybeInitializedPlaces, MaybeUninitializedPlaces};
88
use crate::transform::{MirPass, MirSource};
99
use crate::util::elaborate_drops::{elaborate_drop, DropFlagState, Unwind};
1010
use crate::util::elaborate_drops::{DropElaborator, DropFlagMode, DropStyle};

src/librustc_mir/transform/generator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@
4949
//! For generators with state 1 (returned) and state 2 (poisoned) it does nothing.
5050
//! Otherwise it drops all the values in scope at the last suspension point.
5151
52-
use crate::dataflow::{self, Analysis};
53-
use crate::dataflow::{
52+
use crate::dataflow::impls::{
5453
MaybeBorrowedLocals, MaybeLiveLocals, MaybeRequiresStorage, MaybeStorageLive,
5554
};
55+
use crate::dataflow::{self, Analysis};
5656
use crate::transform::no_landing_pads::no_landing_pads;
5757
use crate::transform::simplify;
5858
use crate::transform::{MirPass, MirSource};

src/librustc_mir/transform/rustc_peek.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ use rustc_index::bit_set::BitSet;
99
use rustc_middle::mir::{self, Body, Local, Location};
1010
use rustc_middle::ty::{self, Ty, TyCtxt};
1111

12+
use crate::dataflow::impls::{
13+
DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeLiveLocals, MaybeMutBorrowedLocals,
14+
MaybeUninitializedPlaces,
15+
};
1216
use crate::dataflow::move_paths::{HasMoveData, MoveData};
1317
use crate::dataflow::move_paths::{LookupResult, MovePathIndex};
14-
use crate::dataflow::MaybeMutBorrowedLocals;
1518
use crate::dataflow::MoveDataParamEnv;
1619
use crate::dataflow::{Analysis, Results, ResultsCursor};
17-
use crate::dataflow::{
18-
DefinitelyInitializedPlaces, MaybeInitializedPlaces, MaybeLiveLocals, MaybeUninitializedPlaces,
19-
};
2020

2121
pub struct SanityCheck;
2222

src/librustc_session/options.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,9 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
938938
"enable origins tracking in MemorySanitizer"),
939939
sanitizer_recover: Vec<Sanitizer> = (vec![], parse_sanitizer_list, [TRACKED],
940940
"enable recovery for selected sanitizers"),
941-
saturating_float_casts: bool = (false, parse_bool, [TRACKED],
941+
saturating_float_casts: Option<bool> = (None, parse_opt_bool, [TRACKED],
942942
"make float->int casts UB-free: numbers outside the integer type's range are clipped to \
943-
the max/min integer respectively, and NaN is mapped to 0 (default: no)"),
943+
the max/min integer respectively, and NaN is mapped to 0 (default: yes)"),
944944
save_analysis: bool = (false, parse_bool, [UNTRACKED],
945945
"write syntax and type analysis (in JSON format) information, in \
946946
addition to normal output (default: no)"),

src/librustc_typeck/check/demand.rs

-7
Original file line numberDiff line numberDiff line change
@@ -909,13 +909,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
909909
cast_suggestion,
910910
Applicability::MaybeIncorrect, // lossy conversion
911911
);
912-
err.warn(
913-
"if the rounded value cannot be represented by the target \
914-
integer type, including `Inf` and `NaN`, casting will cause \
915-
undefined behavior \
916-
(see issue #10184 <https://github.com/rust-lang/rust/issues/10184> \
917-
for more information)",
918-
);
919912
}
920913
true
921914
}

src/libstd/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ dlmalloc = { version = "0.1", features = ['rustc-dep-of-std'] }
4141
fortanix-sgx-abi = { version = "0.3.2", features = ['rustc-dep-of-std'] }
4242

4343
[target.'cfg(all(any(target_arch = "x86_64", target_arch = "aarch64"), target_os = "hermit"))'.dependencies]
44-
hermit-abi = { version = "0.1.10", features = ['rustc-dep-of-std'] }
44+
hermit-abi = { version = "0.1.12", features = ['rustc-dep-of-std'] }
4545

4646
[target.wasm32-wasi.dependencies]
4747
wasi = { version = "0.9.0", features = ['rustc-dep-of-std'], default-features = false }

src/libstd/sys/hermit/thread.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,24 @@ pub struct Thread {
1616
unsafe impl Send for Thread {}
1717
unsafe impl Sync for Thread {}
1818

19-
pub const DEFAULT_MIN_STACK_SIZE: usize = 262144;
19+
pub const DEFAULT_MIN_STACK_SIZE: usize = 1 << 20;
2020

2121
impl Thread {
2222
pub unsafe fn new_with_coreid(
23-
_stack: usize,
23+
stack: usize,
2424
p: Box<dyn FnOnce()>,
2525
core_id: isize,
2626
) -> io::Result<Thread> {
2727
let p = Box::into_raw(box p);
28-
let mut tid: Tid = u32::MAX;
29-
let ret = abi::spawn(
30-
&mut tid as *mut Tid,
28+
let tid = abi::spawn2(
3129
thread_start,
32-
&*p as *const _ as *const u8 as usize,
30+
p as usize,
3331
abi::Priority::into(abi::NORMAL_PRIO),
32+
stack,
3433
core_id,
3534
);
3635

37-
return if ret != 0 {
36+
return if tid == 0 {
3837
// The thread failed to start and as a result p was not consumed. Therefore, it is
3938
// safe to reconstruct the box so that it gets deallocated.
4039
drop(Box::from_raw(p));

src/libunwind/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ mod llvm_libunwind {
8989
cfg.flag("-fno-rtti");
9090
cfg.flag("-fstrict-aliasing");
9191
cfg.flag("-funwind-tables");
92+
cfg.flag("-fvisibility=hidden");
9293
}
9394

9495
let mut unwind_sources = vec![
+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
// compile-flags: -C no-prepopulate-passes
1+
// This file tests that we don't generate any code for saturation when using the
2+
// unchecked intrinsics.
23

3-
// This file tests that we don't generate any code for saturation if
4-
// -Z saturating-float-casts is not enabled.
4+
// compile-flags: -C opt-level=3
55

66
#![crate_type = "lib"]
77

@@ -12,7 +12,7 @@ pub fn f32_to_u32(x: f32) -> u32 {
1212
// CHECK-NOT: fcmp
1313
// CHECK-NOT: icmp
1414
// CHECK-NOT: select
15-
x as u32
15+
unsafe { x.to_int_unchecked() }
1616
}
1717

1818
// CHECK-LABEL: @f32_to_i32
@@ -22,7 +22,7 @@ pub fn f32_to_i32(x: f32) -> i32 {
2222
// CHECK-NOT: fcmp
2323
// CHECK-NOT: icmp
2424
// CHECK-NOT: select
25-
x as i32
25+
unsafe { x.to_int_unchecked() }
2626
}
2727

2828
#[no_mangle]
@@ -31,5 +31,5 @@ pub fn f64_to_u16(x: f64) -> u16 {
3131
// CHECK-NOT: fcmp
3232
// CHECK-NOT: icmp
3333
// CHECK-NOT: select
34-
x as u16
34+
unsafe { x.to_int_unchecked() }
3535
}

src/test/ui/eprint-on-tls-drop.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// run-pass
22
// ignore-emscripten no processes
3+
// ignore-sgx no processes
34

45
use std::cell::RefCell;
56
use std::env;

src/test/ui/issues/issue-15487.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#![allow(unused_attributes)]
33
// ignore-windows
44
// ignore-wasm32-bare no libs to link
5+
// ignore-sgx no libs to link
56

67
#![feature(link_args)]
78

0 commit comments

Comments
 (0)