Skip to content

Commit

Permalink
rewrite foreign-exceptions to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jul 18, 2024
1 parent 796d8e9 commit c6a29da
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
15 changes: 15 additions & 0 deletions src/tools/run-make-support/src/external_deps/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,21 @@ impl Rustc {
// endif
// ```
let flag = if is_windows() {
// So this is a bit hacky: we can't use the DLL version of libstdc++ because
// it pulls in the DLL version of libgcc, which means that we end up with 2
// instances of the DW2 unwinding implementation. This is a problem on
// i686-pc-windows-gnu because each module (DLL/EXE) needs to register its
// unwind information with the unwinding implementation, and libstdc++'s
// __cxa_throw won't see the unwinding info we registered with our statically
// linked libgcc.
//
// Now, simply statically linking libstdc++ would fix this problem, except
// that it is compiled with the expectation that pthreads is dynamically
// linked as a DLL and will fail to link with a statically linked libpthread.
//
// So we end up with the following hack: we link use static:-bundle to only
// link the parts of libstdc++ that we actually use, which doesn't include
// the dependency on the pthreads DLL.
if is_msvc() { None } else { Some("-lstatic:-bundle=stdc++") }
} else {
match &uname()[..] {
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ run-make/extern-fn-with-union/Makefile
run-make/extern-multiple-copies/Makefile
run-make/extern-multiple-copies2/Makefile
run-make/fmt-write-bloat/Makefile
run-make/foreign-exceptions/Makefile
run-make/foreign-rust-exceptions/Makefile
run-make/incr-add-rust-src-component/Makefile
run-make/incr-foreign-head-span/Makefile
Expand Down
12 changes: 0 additions & 12 deletions tests/run-make/foreign-exceptions/Makefile

This file was deleted.

18 changes: 18 additions & 0 deletions tests/run-make/foreign-exceptions/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// This test was created to check that compilation and execution still works
// after the addition of a new feature, in #65646: the ability to unwind panics
// and exceptions back and forth between Rust and C++. Should this feature be broken,
// the test should fail.
// See https://github.com/rust-lang/rust/pull/65646

//@ needs-unwind
// Reason: this test exercises panic unwinding
//@ ignore-cross-compile
// Reason: the compiled binary is executed

use run_make_support::{build_native_static_lib_cxx, run, rustc};

fn main() {
build_native_static_lib_cxx("foo");
rustc().input("foo.rs").arg("-lfoo").extra_rs_cxx_flags().run();
run("foo");
}

0 comments on commit c6a29da

Please sign in to comment.