Skip to content

Commit

Permalink
rewrite compiler-rt-works-on-mingw to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jul 22, 2024
1 parent 67b8e48 commit 95dd189
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
21 changes: 21 additions & 0 deletions src/tools/run-make-support/src/external_deps/cc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -44,6 +50,21 @@ impl Cc {
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());
Expand Down
2 changes: 1 addition & 1 deletion src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub use external_deps::{c_build, cc, clang, htmldocck, llvm, python, rustc, rust

// These rely on external dependencies.
pub use c_build::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::{
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 @@ -4,7 +4,6 @@ run-make/c-dynamic-rlib/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
Expand Down
9 changes: 0 additions & 9 deletions tests/run-make/compiler-rt-works-on-mingw/Makefile

This file was deleted.

15 changes: 15 additions & 0 deletions tests/run-make/compiler-rt-works-on-mingw/rmake.rs
Original file line number Diff line number Diff line change
@@ -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");
}

0 comments on commit 95dd189

Please sign in to comment.