Skip to content

Commit

Permalink
Auto merge of #62603 - cuviper:no-unwind-abort, r=joshtriplett
Browse files Browse the repository at this point in the history
Permit unwinding through FFI by default

This repeats #62505 for master (Rust 1.38+), as #58794 is not yet resolved. This is a stopgap until a stable alternative is available, like [RFC 2699](rust-lang/rfcs#2699), as long as progress is being made to that end.

r? @joshtriplett
  • Loading branch information
bors committed Aug 26, 2019
2 parents 521d784 + 367b793 commit 4c58535
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/librustc_mir/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ fn should_abort_on_panic(tcx: TyCtxt<'_>, fn_def_id: DefId, abi: Abi) -> bool {
// This is a special case: some functions have a C abi but are meant to
// unwind anyway. Don't stop them.
match unwind_attr {
None => true,
None => false, // FIXME(#58794)
Some(UnwindAttr::Allowed) => false,
Some(UnwindAttr::Aborts) => true,
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/codegen/c-variadic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#![crate_type = "lib"]
#![feature(c_variadic)]
#![feature(unwind_attributes)]
#![no_std]
use core::ffi::VaList;

Expand All @@ -10,6 +11,7 @@ extern "C" {
fn foreign_c_variadic_1(_: VaList, ...);
}

#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_0() {
// Ensure that we correctly call foreign C-variadic functions.
// CHECK: invoke void (i32, ...) @foreign_c_variadic_0(i32 0)
Expand All @@ -24,20 +26,24 @@ pub unsafe extern "C" fn use_foreign_c_variadic_0() {

// Ensure that we do not remove the `va_list` passed to the foreign function when
// removing the "spoofed" `VaListImpl` that is used by Rust defined C-variadics.
#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_1_0(ap: VaList) {
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap)
foreign_c_variadic_1(ap);
}

#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_1_1(ap: VaList) {
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 42)
foreign_c_variadic_1(ap, 42i32);
}
#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_1_2(ap: VaList) {
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42)
foreign_c_variadic_1(ap, 2i32, 42i32);
}

#[unwind(aborts)] // FIXME(#58794)
pub unsafe extern "C" fn use_foreign_c_variadic_1_3(ap: VaList) {
// CHECK: invoke void ({{.*}}*, ...) @foreign_c_variadic_1({{.*}} %ap, i32 2, i32 42, i32 0)
foreign_c_variadic_1(ap, 2i32, 42i32, 0i32);
Expand Down
2 changes: 1 addition & 1 deletion src/test/incremental/hashes/function_interfaces.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pub unsafe fn make_unsafe() {}
pub fn make_extern() {}

#[cfg(not(cfail1))]
#[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, mir_built, typeck_tables_of, fn_sig")]
#[rustc_clean(cfg = "cfail2", except = "Hir, HirBody, typeck_tables_of, fn_sig")]
#[rustc_clean(cfg = "cfail3")]
pub extern "C" fn make_extern() {}

Expand Down
2 changes: 1 addition & 1 deletion src/test/incremental/hashes/inherent_impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl Foo {
#[rustc_clean(cfg="cfail2")]
#[rustc_clean(cfg="cfail3")]
impl Foo {
#[rustc_clean(cfg="cfail2", except="Hir,HirBody,mir_built,fn_sig,typeck_tables_of")]
#[rustc_clean(cfg="cfail2", except="Hir,HirBody,fn_sig,typeck_tables_of")]
#[rustc_clean(cfg="cfail3")]
pub extern fn make_method_extern(&self) { }
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/ui/abi/abort-on-c-abi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// run-pass

#![allow(unused_must_use)]
#![feature(unwind_attributes)]
// Since we mark some ABIs as "nounwind" to LLVM, we must make sure that
// we never unwind through them.

Expand All @@ -13,6 +14,7 @@ use std::io::prelude::*;
use std::io;
use std::process::{Command, Stdio};

#[unwind(aborts)] // FIXME(#58794)
extern "C" fn panic_in_ffi() {
panic!("Test");
}
Expand Down

0 comments on commit 4c58535

Please sign in to comment.