Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 29179f4

Browse files
committedJul 22, 2024
Auto merge of #127989 - Oneirical:testricted-area, r=<try>
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). Please try: try-job: x86_64-mingw
2 parents aee3dc4 + ba78a9e commit 29179f4

File tree

10 files changed

+84
-49
lines changed

10 files changed

+84
-49
lines changed
 

‎src/tools/compiletest/src/command-list.rs

+1
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
201201
"only-wasm32-wasip1",
202202
"only-watchos",
203203
"only-windows",
204+
"only-windows-gnu",
204205
"only-x86",
205206
"only-x86_64",
206207
"only-x86_64-fortanix-unknown-sgx",

‎src/tools/run-make-support/src/external_deps/cc.rs

+21
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ pub fn cc() -> Cc {
1515
Cc::new()
1616
}
1717

18+
/// Construct a new platform-specific CXX compiler invocation.
19+
#[track_caller]
20+
pub fn cxx() -> Cc {
21+
Cc::new_cxx()
22+
}
23+
1824
/// A platform-specific C compiler invocation builder. The specific C compiler used is
1925
/// passed down from compiletest.
2026
#[derive(Debug)]
@@ -44,6 +50,21 @@ impl Cc {
4450
Self { cmd }
4551
}
4652

53+
/// Construct a new platform-specific CXX compiler invocation.
54+
#[track_caller]
55+
pub fn new_cxx() -> Self {
56+
let compiler = env_var("CXX");
57+
58+
let mut cmd = Command::new(compiler);
59+
60+
let default_cflags = env_var("CXX_DEFAULT_FLAGS");
61+
for flag in default_cflags.split(char::is_whitespace) {
62+
cmd.arg(flag);
63+
}
64+
65+
Self { cmd }
66+
}
67+
4768
/// Specify path of the input file.
4869
pub fn input<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
4970
self.cmd.arg(path.as_ref());

‎src/tools/run-make-support/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub use external_deps::{c_build, cc, clang, htmldocck, llvm, python, rustc, rust
4444

4545
// These rely on external dependencies.
4646
pub use c_build::build_native_static_lib;
47-
pub use cc::{cc, extra_c_flags, extra_cxx_flags, Cc};
47+
pub use cc::{cc, cxx, extra_c_flags, extra_cxx_flags, Cc};
4848
pub use clang::{clang, Clang};
4949
pub use htmldocck::htmldocck;
5050
pub use llvm::{

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ run-make/c-dynamic-rlib/Makefile
44
run-make/c-unwind-abi-catch-lib-panic/Makefile
55
run-make/cat-and-grep-sanity-check/Makefile
66
run-make/cdylib-dylib-linkage/Makefile
7-
run-make/compiler-rt-works-on-mingw/Makefile
87
run-make/cross-lang-lto-clang/Makefile
98
run-make/cross-lang-lto-pgo-smoketest/Makefile
109
run-make/cross-lang-lto-upstream-rlibs/Makefile
@@ -25,8 +24,6 @@ run-make/foreign-double-unwind/Makefile
2524
run-make/foreign-exceptions/Makefile
2625
run-make/foreign-rust-exceptions/Makefile
2726
run-make/incr-add-rust-src-component/Makefile
28-
run-make/incr-foreign-head-span/Makefile
29-
run-make/interdependent-c-libraries/Makefile
3027
run-make/issue-107094/Makefile
3128
run-make/issue-14698/Makefile
3229
run-make/issue-15460/Makefile

‎tests/run-make/compiler-rt-works-on-mingw/Makefile

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

‎tests/run-make/incr-foreign-head-span/Makefile

-21
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Ensure that modifying a crate on disk (without recompiling it)
2+
// does not cause ICEs (internal compiler errors) in downstream crates.
3+
// Previously, we would call `SourceMap.guess_head_span` on a span
4+
// from an external crate, which would cause us to read an upstream
5+
// source file from disk during compilation of a downstream crate.
6+
// See https://github.com/rust-lang/rust/issues/86480
7+
8+
//@ ignore-none
9+
// Reason: no-std is not supported
10+
//@ ignore-nvptx64-nvidia-cuda
11+
// Reason: can't find crate for 'std'
12+
13+
use run_make_support::{rfs, rust_lib_name, rustc};
14+
15+
fn main() {
16+
rustc().input("first_crate.rs").incremental("incr").crate_type("lib").run();
17+
rustc()
18+
.input("second_crate.rs")
19+
.incremental("incr")
20+
.extern_("first_crate", rust_lib_name("first_crate"))
21+
.crate_type("lib")
22+
.run();
23+
rfs::remove_file("first_crate.rs");
24+
rustc().input("second_crate.rs").incremental("incr").cfg("second_run").crate_type("lib").run();
25+
}

‎tests/run-make/interdependent-c-libraries/Makefile

-15
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// The rust crate foo will link to the native library foo, while the rust crate
2+
// bar will link to the native library bar. There is also a dependency between
3+
// the native library bar to the natibe library foo.
4+
// This test ensures that the ordering of -lfoo and -lbar on the command line is
5+
// correct to complete the linkage. If passed as "-lfoo -lbar", then the 'foo'
6+
// library will be stripped out, and the linkage will fail.
7+
// See https://github.com/rust-lang/rust/commit/e6072fa0c4c22d62acf3dcb78c8ee260a1368bd7
8+
9+
//@ ignore-cross-compile
10+
// Reason: linkage still fails as the object files produced are not in the correct
11+
// format in the `build_native_static_lib` step
12+
13+
use run_make_support::{build_native_static_lib, rustc};
14+
15+
fn main() {
16+
build_native_static_lib("foo");
17+
build_native_static_lib("bar");
18+
rustc().input("foo.rs").run();
19+
rustc().input("bar.rs").run();
20+
rustc().input("main.rs").print("link-args").run();
21+
}

0 commit comments

Comments
 (0)
Failed to load comments.