Skip to content

Commit

Permalink
Auto merge of #127989 - Oneirical:testricted-area, r=<try>
Browse files Browse the repository at this point in the history
Migrate `interdependent-c-libraries`, `compiler-rt-works-on-mingw` and `incr-foreign-head-span` `run-make` tests to rmake

Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).

try-job: aarch64-apple
try-job: armhf-gnu
try-job: test-various
try-job: x86_64-mingw
try-job: x86_64-msvc
try-job: x86_64-gnu-llvm-18
  • Loading branch information
bors committed Jul 22, 2024
2 parents aee3dc4 + 3085334 commit 6ab1b97
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 49 deletions.
1 change: 1 addition & 0 deletions src/tools/compiletest/src/command-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-wasm32-wasip1",
"only-watchos",
"only-windows",
"only-windows-gnu",
"only-x86",
"only-x86_64",
"only-x86_64-fortanix-unknown-sgx",
Expand Down
23 changes: 23 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,13 @@ pub fn cc() -> Cc {
Cc::new()
}

/// Construct a new platform-specific CXX compiler invocation.
/// CXX_DEFAULT_FLAGS is passed from compiletest.
#[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 +51,22 @@ impl Cc {
Self { cmd }
}

/// Construct a new platform-specific CXX compiler invocation.
/// CXX_DEFAULT_FLAGS is passed from compiletest.
#[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
3 changes: 0 additions & 3 deletions 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 All @@ -25,8 +24,6 @@ run-make/foreign-double-unwind/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
run-make/interdependent-c-libraries/Makefile
run-make/issue-107094/Makefile
run-make/issue-14698/Makefile
run-make/issue-15460/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 is a basic smoke test to
// check if building and linking to it can work at all.
// 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");
}
21 changes: 0 additions & 21 deletions tests/run-make/incr-foreign-head-span/Makefile

This file was deleted.

25 changes: 25 additions & 0 deletions tests/run-make/incr-foreign-head-span/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Ensure that modifying a crate on disk (without recompiling it)
// does not cause ICEs (internal compiler errors) in downstream crates.
// Previously, we would call `SourceMap.guess_head_span` on a span
// from an external crate, which would cause us to read an upstream
// source file from disk during compilation of a downstream crate.
// See https://github.com/rust-lang/rust/issues/86480

//@ ignore-none
// Reason: no-std is not supported
//@ ignore-nvptx64-nvidia-cuda
// Reason: can't find crate for 'std'

use run_make_support::{rfs, rust_lib_name, rustc};

fn main() {
rustc().input("first_crate.rs").incremental("incr").crate_type("lib").run();
rustc()
.input("second_crate.rs")
.incremental("incr")
.extern_("first_crate", rust_lib_name("first_crate"))
.crate_type("lib")
.run();
rfs::remove_file("first_crate.rs");
rustc().input("second_crate.rs").incremental("incr").cfg("second_run").crate_type("lib").run();
}
15 changes: 0 additions & 15 deletions tests/run-make/interdependent-c-libraries/Makefile

This file was deleted.

21 changes: 21 additions & 0 deletions tests/run-make/interdependent-c-libraries/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// The rust crate foo will link to the native library foo, while the rust crate
// bar will link to the native library bar. There is also a dependency between
// the native library bar to the natibe library foo.
// This test ensures that the ordering of -lfoo and -lbar on the command line is
// correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo'
// library will be stripped out, and the linkage will fail.
// See https://github.com/rust-lang/rust/commit/e6072fa0c4c22d62acf3dcb78c8ee260a1368bd7

//@ ignore-cross-compile
// Reason: linkage still fails as the object files produced are not in the correct
// format in the `build_native_static_lib` step

use run_make_support::{build_native_static_lib, rustc};

fn main() {
build_native_static_lib("foo");
build_native_static_lib("bar");
rustc().input("foo.rs").run();
rustc().input("bar.rs").run();
rustc().input("main.rs").print("link-args").run();
}

0 comments on commit 6ab1b97

Please sign in to comment.