rewrite compiler-rt-works-on-mingw to rmake

This commit is contained in:
Oneirical 2024-07-19 15:51:49 -04:00
parent 4dad2a332b
commit c424bc61bf
5 changed files with 37 additions and 11 deletions

View File

@ -15,6 +15,12 @@ pub fn cc() -> Cc {
Cc::new()
}
/// Construct a new platform-specific CXX compiler invocation.
#[track_caller]
pub fn cxx() -> Cc {
Cc::new_cxx()
}
/// A platform-specific C compiler invocation builder. The specific C compiler used is
/// passed down from compiletest.
#[derive(Debug)]
@ -44,6 +50,21 @@ pub fn new() -> Self {
Self { cmd }
}
/// Construct a new platform-specific CXX compiler invocation.
#[track_caller]
pub fn new_cxx() -> Self {
let compiler = env_var("CXX");
let mut cmd = Command::new(compiler);
let default_cflags = env_var("CXX_DEFAULT_FLAGS");
for flag in default_cflags.split(char::is_whitespace) {
cmd.arg(flag);
}
Self { cmd }
}
/// Specify path of the input file.
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());

View File

@ -44,7 +44,7 @@ pub mod rfs {
// These rely on external dependencies.
pub use c_build::{build_native_dynamic_lib, build_native_static_lib};
pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc};
pub use clang::{clang, Clang};
pub use htmldocck::htmldocck;
pub use llvm::{

View File

@ -2,7 +2,6 @@ run-make/branch-protection-check-IBT/Makefile
run-make/c-unwind-abi-catch-lib-panic/Makefile
run-make/cat-and-grep-sanity-check/Makefile
run-make/cdylib-dylib-linkage/Makefile
run-make/compiler-rt-works-on-mingw/Makefile
run-make/cross-lang-lto-clang/Makefile
run-make/cross-lang-lto-pgo-smoketest/Makefile
run-make/cross-lang-lto-upstream-rlibs/Makefile

View File

@ -1,9 +0,0 @@
include ../tools.mk
# only-windows-gnu
all:
$(CXX) foo.cpp -c -o $(TMPDIR)/foo.o
$(AR) crus $(TMPDIR)/libfoo.a $(TMPDIR)/foo.o
$(RUSTC) foo.rs -lfoo -lstdc++
$(call RUN,foo)

View File

@ -0,0 +1,15 @@
// `compiler-rt` ("runtime") is a suite of LLVM features compatible with rustc.
// After building it was enabled on Windows-gnu in #29874, this test checks
// that compilation and execution with it are successful.
// See https://github.com/rust-lang/rust/pull/29478
//@ only-windows-gnu
use run_make_support::{cxx, is_msvc, llvm_ar, run, rustc, static_lib_name};
fn main() {
cxx().input("foo.cpp").arg("-c").out_exe("foo.o").run();
llvm_ar().obj_to_ar().output_input(static_lib_name("foo"), "foo.o").run();
rustc().input("foo.rs").arg("-lfoo").arg("-lstdc++").run();
run("foo");
}