rewrite foreign-exceptions to rmake
This commit is contained in:
parent
5b44f800f3
commit
46b4083e6f
@ -1,13 +1,8 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
use super::cygpath::get_windows_path;
|
use super::cygpath::get_windows_path;
|
||||||
use crate::artifact_names::{dynamic_lib_name, static_lib_name};
|
use crate::artifact_names::{dynamic_lib_name, static_lib_name};
|
||||||
use crate::external_deps::cc::cc;
|
|
||||||
=======
|
|
||||||
use crate::artifact_names::static_lib_name;
|
|
||||||
use crate::external_deps::cc::{cc, cxx};
|
use crate::external_deps::cc::{cc, cxx};
|
||||||
>>>>>>> e3cf7e53339 (rewrite foreign-double-unwind to rmake)
|
|
||||||
use crate::external_deps::llvm::llvm_ar;
|
use crate::external_deps::llvm::llvm_ar;
|
||||||
use crate::path_helpers::path;
|
use crate::path_helpers::path;
|
||||||
use crate::targets::{is_darwin, is_msvc, is_windows};
|
use crate::targets::{is_darwin, is_msvc, is_windows};
|
||||||
|
@ -214,41 +214,3 @@ pub fn extra_cxx_flags() -> Vec<&'static str> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// `EXTRARSCXXFLAGS`
|
|
||||||
pub fn extra_rs_cxx_flags() -> Vec<&'static str> {
|
|
||||||
// Adapted from tools.mk (trimmed):
|
|
||||||
//
|
|
||||||
// ```makefile
|
|
||||||
// ifdef IS_WINDOWS
|
|
||||||
// ifdef IS_MSVC
|
|
||||||
// else
|
|
||||||
// EXTRARSCXXFLAGS := -lstatic:-bundle=stdc++
|
|
||||||
// endif
|
|
||||||
// else
|
|
||||||
// ifeq ($(UNAME),Darwin)
|
|
||||||
// EXTRARSCXXFLAGS := -lc++
|
|
||||||
// else
|
|
||||||
// ifeq ($(UNAME),FreeBSD)
|
|
||||||
// else
|
|
||||||
// ifeq ($(UNAME),SunOS)
|
|
||||||
// else
|
|
||||||
// ifeq ($(UNAME),OpenBSD)
|
|
||||||
// else
|
|
||||||
// EXTRARSCXXFLAGS := -lstdc++
|
|
||||||
// endif
|
|
||||||
// endif
|
|
||||||
// endif
|
|
||||||
// endif
|
|
||||||
// endif
|
|
||||||
// ```
|
|
||||||
if is_windows() {
|
|
||||||
if is_msvc() { vec![] } else { vec!["-lstatic:-bundle=stdc++"] }
|
|
||||||
} else {
|
|
||||||
match &uname()[..] {
|
|
||||||
"Darwin" => vec!["-lc++"],
|
|
||||||
"FreeBSD" | "SunOS" | "OpenBSD" => vec![],
|
|
||||||
_ => vec!["-lstdc++"],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
use crate::env::env_var;
|
use crate::env::env_var;
|
||||||
use crate::path_helpers::cwd;
|
use crate::path_helpers::cwd;
|
||||||
use crate::util::set_host_rpath;
|
use crate::util::set_host_rpath;
|
||||||
use crate::{is_msvc, is_windows, uname};
|
use crate::{is_darwin, is_msvc, is_windows, uname};
|
||||||
|
|
||||||
/// Construct a new `rustc` invocation. This will automatically set the library
|
/// Construct a new `rustc` invocation. This will automatically set the library
|
||||||
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
|
/// search path as `-L cwd()`. Use [`bare_rustc`] to avoid this.
|
||||||
@ -344,10 +344,26 @@ pub fn extra_rs_cxx_flags(&mut self) -> &mut Self {
|
|||||||
// endif
|
// endif
|
||||||
// ```
|
// ```
|
||||||
let flag = if is_windows() {
|
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++") }
|
if is_msvc() { None } else { Some("-lstatic:-bundle=stdc++") }
|
||||||
|
} else if is_darwin() {
|
||||||
|
Some("-lc++")
|
||||||
} else {
|
} else {
|
||||||
match &uname()[..] {
|
match &uname()[..] {
|
||||||
"Darwin" => Some("-lc++"),
|
|
||||||
"FreeBSD" | "SunOS" | "OpenBSD" => None,
|
"FreeBSD" | "SunOS" | "OpenBSD" => None,
|
||||||
_ => Some("-lstdc++"),
|
_ => Some("-lstdc++"),
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ run-make/dep-info-spaces/Makefile
|
|||||||
run-make/dep-info/Makefile
|
run-make/dep-info/Makefile
|
||||||
run-make/emit-to-stdout/Makefile
|
run-make/emit-to-stdout/Makefile
|
||||||
run-make/extern-fn-reachable/Makefile
|
run-make/extern-fn-reachable/Makefile
|
||||||
run-make/foreign-exceptions/Makefile
|
|
||||||
run-make/incr-add-rust-src-component/Makefile
|
run-make/incr-add-rust-src-component/Makefile
|
||||||
run-make/issue-84395-lto-embed-bitcode/Makefile
|
run-make/issue-84395-lto-embed-bitcode/Makefile
|
||||||
run-make/issue-88756-default-output/Makefile
|
run-make/issue-88756-default-output/Makefile
|
||||||
|
@ -6,17 +6,16 @@
|
|||||||
//@ ignore-cross-compile
|
//@ ignore-cross-compile
|
||||||
// Reason: the compiled binary is executed
|
// Reason: the compiled binary is executed
|
||||||
|
|
||||||
// FIXME(Oneirical): are these really necessary? This test is supposed to test a musl
|
//@ ignore-none
|
||||||
// bug... and it ignores musl? This wasn't part of the original test at its creation, which
|
// Reason: no-std is not supported.
|
||||||
// had no ignores.
|
//@ ignore-wasm32
|
||||||
|
//@ ignore-wasm64
|
||||||
|
// Reason: compiling C++ to WASM may cause problems.
|
||||||
|
|
||||||
//# ignore-none no-std is not supported
|
// Neither of these are tested in full CI.
|
||||||
//# ignore-wasm32 FIXME: don't attempt to compile C++ to WASM
|
//@ ignore-nvptx64-nvidia-cuda
|
||||||
//# ignore-wasm64 FIXME: don't attempt to compile C++ to WASM
|
// Reason: can't find crate "std"
|
||||||
//# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for `std`
|
//@ ignore-sgx
|
||||||
//# ignore-musl FIXME: this makefile needs teaching how to use a musl toolchain
|
|
||||||
//# (see dist-i586-gnu-i586-i686-musl Dockerfile)
|
|
||||||
//# ignore-sgx
|
|
||||||
|
|
||||||
use run_make_support::{build_native_static_lib_cxx, run, rustc};
|
use run_make_support::{build_native_static_lib_cxx, run, rustc};
|
||||||
|
|
||||||
|
@ -12,10 +12,10 @@
|
|||||||
//@ ignore-cross-compile
|
//@ ignore-cross-compile
|
||||||
// Reason: the compiled binary is executed
|
// Reason: the compiled binary is executed
|
||||||
|
|
||||||
use run_make_support::{build_native_static_lib_cxx, run, rustc};
|
use run_make_support::{build_native_static_lib_cxx, run_fail, rustc};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
build_native_static_lib_cxx("foo");
|
build_native_static_lib_cxx("foo");
|
||||||
rustc().input("foo.rs").arg("-lfoo").extra_rs_cxx_flags().run();
|
rustc().input("foo.rs").arg("-lfoo").extra_rs_cxx_flags().run();
|
||||||
run("foo").assert_stdout_not_contains("unreachable");
|
run_fail("foo").assert_stdout_not_contains("unreachable");
|
||||||
}
|
}
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
# ignore-cross-compile
|
|
||||||
# needs-unwind
|
|
||||||
include ../tools.mk
|
|
||||||
|
|
||||||
all: foo
|
|
||||||
$(call RUN,foo)
|
|
||||||
|
|
||||||
foo: foo.rs $(call NATIVE_STATICLIB,foo)
|
|
||||||
$(RUSTC) $< -lfoo $(EXTRARSCXXFLAGS)
|
|
||||||
|
|
||||||
$(TMPDIR)/libfoo.o: foo.cpp
|
|
||||||
$(call COMPILE_OBJ_CXX,$@,$<)
|
|
19
tests/run-make/foreign-exceptions/rmake.rs
Normal file
19
tests/run-make/foreign-exceptions/rmake.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// 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++. This is a basic smoke test,
|
||||||
|
// this feature being broken in quiet or subtle ways could still result in this test
|
||||||
|
// passing.
|
||||||
|
// 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");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user