Skip to content

Commit

Permalink
Auto merge of rust-lang#131630 - tgross35:rollup-2feqbwv, r=tgross35
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - rust-lang#131120 (Stabilize `const_option`)
 - rust-lang#131207 (ci: aarch64-gnu-debug job)
 - rust-lang#131334 (Enable sanitizers for loongarch64-unknown-*)
 - rust-lang#131358 (force "HEAD" for non-CI and `git_upstream_merge_base` for CI environment)
 - rust-lang#131418 (Use throw intrinsic from stdarch in wasm libunwind)
 - rust-lang#131579 (Remap path prefix in the panic message of `tests/ui/meta/revision-bad.rs`)
 - rust-lang#131591 (add latest crash tests)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Oct 13, 2024
2 parents ef4e825 + e1b21ce commit 0c3a4ea
Show file tree
Hide file tree
Showing 36 changed files with 263 additions and 51 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ jobs:
# which then uses log commands to actually set them.
EXTRA_VARIABLES: ${{ toJson(matrix.env) }}

- name: setup upstream remote
run: src/ci/scripts/setup-upstream-remote.sh

- name: ensure the channel matches the target branch
run: src/ci/scripts/verify-channel.sh

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_middle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#![feature(box_as_ptr)]
#![feature(box_patterns)]
#![feature(closure_track_caller)]
#![feature(const_option)]
#![feature(const_type_name)]
#![feature(core_intrinsics)]
#![feature(coroutines)]
Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_serialize/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
test(attr(allow(unused_variables), deny(warnings)))
)]
#![doc(rust_logo)]
#![feature(const_option)]
#![feature(core_intrinsics)]
#![feature(min_specialization)]
#![feature(never_type)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{CodeModel, Target, TargetOptions, base};
use crate::spec::{CodeModel, SanitizerSet, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -18,6 +18,11 @@ pub(crate) fn target() -> Target {
features: "+f,+d".into(),
llvm_abiname: "lp64d".into(),
max_atomic_width: Some(64),
supported_sanitizers: SanitizerSet::ADDRESS
| SanitizerSet::CFI
| SanitizerSet::LEAK
| SanitizerSet::MEMORY
| SanitizerSet::THREAD,
direct_access_external_data: Some(false),
..base::linux_gnu::opts()
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{CodeModel, Target, TargetOptions, base};
use crate::spec::{CodeModel, SanitizerSet, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -19,6 +19,11 @@ pub(crate) fn target() -> Target {
llvm_abiname: "lp64d".into(),
max_atomic_width: Some(64),
crt_static_default: false,
supported_sanitizers: SanitizerSet::ADDRESS
| SanitizerSet::CFI
| SanitizerSet::LEAK
| SanitizerSet::MEMORY
| SanitizerSet::THREAD,
..base::linux_musl::opts()
},
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::spec::{Target, TargetOptions, base};
use crate::spec::{SanitizerSet, Target, TargetOptions, base};

pub(crate) fn target() -> Target {
Target {
Expand All @@ -17,6 +17,11 @@ pub(crate) fn target() -> Target {
features: "+f,+d".into(),
llvm_abiname: "lp64d".into(),
max_atomic_width: Some(64),
supported_sanitizers: SanitizerSet::ADDRESS
| SanitizerSet::CFI
| SanitizerSet::LEAK
| SanitizerSet::MEMORY
| SanitizerSet::THREAD,
..base::linux_ohos::opts()
},
}
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@
#![feature(const_eval_select)]
#![feature(const_heap)]
#![feature(const_maybe_uninit_write)]
#![feature(const_option)]
#![feature(const_pin)]
#![feature(const_size_of_val)]
#![feature(const_vec_string_slice)]
Expand Down
1 change: 0 additions & 1 deletion library/core/src/array/ascii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ impl<const N: usize> [u8; N] {
///
/// ```
/// #![feature(ascii_char)]
/// #![feature(const_option)]
///
/// const HEX_DIGITS: [std::ascii::Char; 16] =
/// *b"0123456789abcdef".as_ascii().unwrap();
Expand Down
1 change: 0 additions & 1 deletion library/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@
#![feature(const_maybe_uninit_assume_init)]
#![feature(const_nonnull_new)]
#![feature(const_num_midpoint)]
#![feature(const_option)]
#![feature(const_option_ext)]
#![feature(const_pin)]
#![feature(const_pointer_is_aligned)]
Expand Down
30 changes: 19 additions & 11 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,8 @@ impl<T> Option<T> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn as_mut(&mut self) -> Option<&mut T> {
match *self {
Some(ref mut x) => Some(x),
Expand Down Expand Up @@ -924,7 +925,8 @@ impl<T> Option<T> {
#[track_caller]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "option_expect")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn expect(self, msg: &str) -> T {
match self {
Some(val) => val,
Expand Down Expand Up @@ -962,7 +964,8 @@ impl<T> Option<T> {
#[track_caller]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "option_unwrap")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn unwrap(self) -> T {
match self {
Some(val) => val,
Expand Down Expand Up @@ -1069,7 +1072,8 @@ impl<T> Option<T> {
#[inline]
#[track_caller]
#[stable(feature = "option_result_unwrap_unchecked", since = "1.58.0")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const unsafe fn unwrap_unchecked(self) -> T {
match self {
Some(val) => val,
Expand Down Expand Up @@ -1712,7 +1716,8 @@ impl<T> Option<T> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn take(&mut self) -> Option<T> {
// FIXME(const-hack) replace `mem::replace` by `mem::take` when the latter is const ready
mem::replace(self, None)
Expand Down Expand Up @@ -1769,8 +1774,9 @@ impl<T> Option<T> {
/// assert_eq!(old, None);
/// ```
#[inline]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[stable(feature = "option_replace", since = "1.31.0")]
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn replace(&mut self, value: T) -> Option<T> {
mem::replace(self, Some(value))
}
Expand Down Expand Up @@ -1878,7 +1884,7 @@ impl<T> Option<&T> {
/// ```
#[must_use = "`self` will be dropped if the result is not used"]
#[stable(feature = "copied", since = "1.35.0")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn copied(self) -> Option<T>
where
T: Copy,
Expand Down Expand Up @@ -1931,7 +1937,8 @@ impl<T> Option<&mut T> {
/// ```
#[must_use = "`self` will be dropped if the result is not used"]
#[stable(feature = "copied", since = "1.35.0")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[cfg_attr(bootstrap, rustc_allow_const_fn_unstable(const_mut_refs))]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn copied(self) -> Option<T>
where
T: Copy,
Expand Down Expand Up @@ -1986,7 +1993,8 @@ impl<T, E> Option<Result<T, E>> {
/// ```
#[inline]
#[stable(feature = "transpose_result", since = "1.33.0")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn transpose(self) -> Result<Option<T>, E> {
match self {
Some(Ok(x)) => Ok(Some(x)),
Expand All @@ -2009,7 +2017,6 @@ const fn unwrap_failed() -> ! {
#[cfg_attr(feature = "panic_immediate_abort", inline)]
#[cold]
#[track_caller]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
const fn expect_failed(msg: &str) -> ! {
panic_display(&msg)
}
Expand Down Expand Up @@ -2534,7 +2541,8 @@ impl<T> Option<Option<T>> {
/// ```
#[inline]
#[stable(feature = "option_flattening", since = "1.40.0")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
#[rustc_const_stable(feature = "const_option", since = "CURRENT_RUSTC_VERSION")]
pub const fn flatten(self) -> Option<T> {
// FIXME(const-hack): could be written with `and_then`
match self {
Expand Down
2 changes: 0 additions & 2 deletions library/core/src/ptr/non_null.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1211,7 +1211,6 @@ impl<T: ?Sized> NonNull<T> {
///
/// ```
/// #![feature(const_nonnull_new)]
/// #![feature(const_option)]
/// #![feature(const_pointer_is_aligned)]
/// use std::ptr::NonNull;
///
Expand Down Expand Up @@ -1264,7 +1263,6 @@ impl<T: ?Sized> NonNull<T> {
///
/// ```
/// #![feature(const_pointer_is_aligned)]
/// #![feature(const_option)]
/// #![feature(const_nonnull_new)]
/// use std::ptr::NonNull;
///
Expand Down
1 change: 0 additions & 1 deletion library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ impl Duration {
/// ```
#[stable(feature = "duration_abs_diff", since = "1.81.0")]
#[rustc_const_stable(feature = "duration_abs_diff", since = "1.81.0")]
#[rustc_allow_const_fn_unstable(const_option)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#![feature(const_ipv6)]
#![feature(const_likely)]
#![feature(const_nonnull_new)]
#![feature(const_option)]
#![feature(const_option_ext)]
#![feature(const_pin)]
#![feature(const_pointer_is_aligned)]
Expand Down
3 changes: 1 addition & 2 deletions library/unwind/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
#![feature(link_cfg)]
#![feature(staged_api)]
#![feature(strict_provenance)]
#![cfg_attr(target_arch = "wasm64", feature(simd_wasm64))]
#![cfg_attr(not(target_env = "msvc"), feature(libc))]
#![cfg_attr(
all(target_family = "wasm", not(target_os = "emscripten")),
feature(link_llvm_intrinsics)
feature(simd_wasm64, wasm_exception_handling_intrinsics)
)]
#![allow(internal_features)]

Expand Down
24 changes: 10 additions & 14 deletions library/unwind/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,25 @@ pub unsafe fn _Unwind_DeleteException(exception: *mut _Unwind_Exception) {
}

pub unsafe fn _Unwind_RaiseException(exception: *mut _Unwind_Exception) -> _Unwind_Reason_Code {
#[cfg(panic = "unwind")]
extern "C" {
/// LLVM lowers this intrinsic to the `throw` instruction.
// FIXME(coolreader18): move to stdarch
#[link_name = "llvm.wasm.throw"]
fn wasm_throw(tag: i32, ptr: *mut u8) -> !;
}

// The wasm `throw` instruction takes a "tag", which differentiates certain
// types of exceptions from others. LLVM currently just identifies these
// via integers, with 0 corresponding to C++ exceptions and 1 to C setjmp()/longjmp().
// Ideally, we'd be able to choose something unique for Rust, but for now,
// we pretend to be C++ and implement the Itanium exception-handling ABI.
cfg_if::cfg_if! {
// for now, unless we're -Zbuild-std with panic=unwind, never codegen a throw.
// panic=abort is default for wasm targets. Because an unknown instruction is a load-time
// error on wasm, instead of a runtime error like on traditional architectures, we never
// want to codegen a `throw` instruction, as that would break users using runtimes that
// don't yet support exceptions. The only time this first branch would be selected is if
// the user explicitly opts in to wasm exceptions, via -Zbuild-std with -Cpanic=unwind.
if #[cfg(panic = "unwind")] {
wasm_throw(0, exception.cast())
// corresponds with llvm::WebAssembly::Tag::CPP_EXCEPTION
// in llvm-project/llvm/include/llvm/CodeGen/WasmEHFuncInfo.h
const CPP_EXCEPTION_TAG: i32 = 0;
core::arch::wasm::throw::<CPP_EXCEPTION_TAG>(exception.cast())
} else {
let _ = exception;
#[cfg(target_arch = "wasm32")]
core::arch::wasm32::unreachable();
#[cfg(target_arch = "wasm64")]
core::arch::wasm64::unreachable();
core::arch::wasm::unreachable()
}
}
}
3 changes: 3 additions & 0 deletions src/bootstrap/src/core/build_steps/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,6 +1228,9 @@ fn supported_sanitizers(
"aarch64-unknown-linux-ohos" => {
common_libs("linux", "aarch64", &["asan", "lsan", "msan", "tsan", "hwasan"])
}
"loongarch64-unknown-linux-gnu" | "loongarch64-unknown-linux-musl" => {
common_libs("linux", "loongarch64", &["asan", "lsan", "msan", "tsan"])
}
"x86_64-apple-darwin" => darwin_libs("osx", &["asan", "lsan", "tsan"]),
"x86_64-unknown-fuchsia" => common_libs("fuchsia", "x86_64", &["asan"]),
"x86_64-apple-ios" => darwin_libs("iossim", &["asan", "tsan"]),
Expand Down
57 changes: 57 additions & 0 deletions src/ci/docker/host-aarch64/aarch64-gnu-debug/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
FROM ubuntu:22.04

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
make \
ninja-build \
file \
curl \
ca-certificates \
python3 \
python3-dev \
libxml2-dev \
libncurses-dev \
libedit-dev \
swig \
doxygen \
git \
cmake \
sudo \
gdb \
libssl-dev \
pkg-config \
xz-utils \
lld \
clang \
&& rm -rf /var/lib/apt/lists/*

COPY scripts/sccache.sh /scripts/
RUN sh /scripts/sccache.sh

ENV RUSTBUILD_FORCE_CLANG_BASED_TESTS 1
ENV RUN_CHECK_WITH_PARALLEL_QUERIES 1

# llvm.use-linker conflicts with downloading CI LLVM
ENV NO_DOWNLOAD_CI_LLVM 1

ENV RUST_CONFIGURE_ARGS \
--build=aarch64-unknown-linux-gnu \
--enable-debug \
--enable-lld \
--set llvm.use-linker=lld \
--set target.aarch64-unknown-linux-gnu.linker=clang \
--set target.aarch64-unknown-linux-gnu.cc=clang \
--set target.aarch64-unknown-linux-gnu.cxx=clang++

# This job appears to be checking two separate things:
# - That we can build the compiler with `--enable-debug`
# (without necessarily testing the result).
# - That the tests with `//@ needs-force-clang-based-tests` pass, since they
# don't run by default unless RUSTBUILD_FORCE_CLANG_BASED_TESTS is set.
# - FIXME(https://github.com/rust-lang/rust/pull/126155#issuecomment-2156314273):
# Currently we only run the subset of tests with "clang" in their name.

ENV SCRIPT \
python3 ../x.py --stage 2 build && \
python3 ../x.py --stage 2 test tests/run-make --test-args clang
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-full-tools \
--enable-profiler \
--enable-sanitizers \
--disable-docs

ENV SCRIPT python3 ../x.py dist --host $HOSTS --target $TARGETS
1 change: 1 addition & 0 deletions src/ci/docker/host-x86_64/dist-loongarch64-musl/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ENV RUST_CONFIGURE_ARGS \
--enable-extended \
--enable-full-tools \
--enable-profiler \
--enable-sanitizers \
--disable-docs \
--set target.loongarch64-unknown-linux-musl.crt-static=false \
--musl-root-loongarch64=/x-tools/loongarch64-unknown-linux-musl/loongarch64-unknown-linux-musl/sysroot/usr
Expand Down
3 changes: 3 additions & 0 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ auto:
- image: aarch64-gnu
<<: *job-aarch64-linux

- image: aarch64-gnu-debug
<<: *job-aarch64-linux

- image: arm-android
<<: *job-linux-4c

Expand Down
Loading

0 comments on commit 0c3a4ea

Please sign in to comment.