Repository: rust
Issue: Panic backtrace doesn't traverse ffi code with panic=abort
Labels: C-enhancement,T-compiler,A-docs,A-panic

<!--
Thank you for filing a bug report! 🐛 Please provide a short summary of the bug,
along with any information you feel relevant to replicating the bug.
-->

I tried this code:

`Cargo.toml`:
```
[package]
name = "testcase"
version = "0.1.0"
edition = "2018"

[profile.release]
panic="abort"

[profile.dev]
panic="abort"

[build-dependencies]
cc = "1"
```
`build.rs`:
```rust
fn main() {
    cc::Build::new().file("foo.c").compile("foo");
}
```
`foo.c`:
```c
#include <stdio.h>

extern void do_rust_panic(const char *msg);

void foo() {
	do_rust_panic("foo");
        // prevent tail-call optimization so that the frame for foo is always there
	printf("foo\n");
}
```
`src/main.rs`:
```rust
use std::ffi::CStr;
use std::os::raw::c_char;

#[no_mangle]
pub unsafe extern "C" fn do_rust_panic(message: *const c_char) {
    panic!("{}", CStr::from_ptr(message).to_string_lossy());
}

extern "C" {
    fn foo();
}

fn main() {
    unsafe {
        foo();
    }
    // prevent tail-call optimization so that the frame for main is always there
    println!("Hello, world!");
}
```
I expected to see this happen: the panic backtrace would traverse the ffi code, like it does without panic=abort.

Instead, this happened: the panic backtrace stops at `do_rust_panic`:
```
$ RUST_BACKTRACE=1 cargo run --release
    Finished release [optimized] target(s) in 0.00s
     Running `target/release/testcase`
Hello, world!
thread 'main' panicked at 'foo', src/main.rs:6:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:457:5
   2: do_rust_panic
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```

Without panic=abort:
```
$ RUST_BACKTRACE=1 cargo run --release
    Finished release [optimized] target(s) in 0.00s
     Running `target/release/testcase`
thread 'main' panicked at 'foo', src/main.rs:6:5
stack backtrace:
   0: rust_begin_unwind
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
   1: std::panicking::begin_panic_fmt
             at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:457:5
   2: do_rust_panic
   3: foo
   4: testcase::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
```

### Meta
<!--
If you're using the stable version of the compiler, you should also check if the
bug also exists in the beta or nightly versions.
-->

`rustc --version --verbose`:
```
rustc 1.54.0 (a178d0322 2021-07-26)
binary: rustc
commit-hash: a178d0322ce20e33eac124758e837cbd80a6f633
commit-date: 2021-07-26
host: x86_64-unknown-linux-gnu
release: 1.54.0
LLVM version: 12.0.1
```

Also reproducible with nightly:
```
rustc 1.56.0-nightly (af140757b 2021-08-22)
binary: rustc
commit-hash: af140757b4cb1a60d107c690720311ba8e06e7de
commit-date: 2021-08-22
host: x86_64-unknown-linux-gnu
release: 1.56.0-nightly
LLVM version: 13.0.0
```

I tried tweaking the FFI build flags, adding combinations of `-fno-omit-frame-pointer`, `-funwind-tables` and `-g`, and none of them changed anything.