Skip to content

Commit 5cddb15

Browse files
committed
rewrite target-specs to rmake
1 parent 1086aff commit 5cddb15

File tree

2 files changed

+71
-12
lines changed

2 files changed

+71
-12
lines changed

tests/run-make/target-specs/Makefile

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/run-make/target-specs/rmake.rs

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Target-specific compilation in rustc used to have case-by-case peculiarities in 2014,
2+
// with the compiler having redundant target types and unspecific names. An overarching rework
3+
// in #161156 changed the way the target flag functions, and this test attempts compilation
4+
// with the target flag's bundle of new features to check that compilation either succeeds while
5+
// using them correctly, or fails with the right error message when using them improperly.
6+
// See https://github.com/rust-lang/rust/pull/16156
7+
8+
use run_make_support::{diff, fs_wrapper, rustc};
9+
10+
fn main() {
11+
rustc().input("foo.rs").target("my-awesome-platform.json").crate_type("lib").emit("asm").run();
12+
assert!(!fs_wrapper::read_to_string("foo.s").contains("morestack"));
13+
rustc()
14+
.input("foo.rs")
15+
.target("my-invalid-platform.json")
16+
.run_fail()
17+
.assert_stderr_contains("Error loading target specification");
18+
rustc()
19+
.input("foo.rs")
20+
.target("my-incomplete-platform.json")
21+
.run_fail()
22+
.assert_stderr_contains("Field llvm-target");
23+
rustc()
24+
.env("RUST_TARGET_PATH", ".")
25+
.input("foo.rs")
26+
.target("my-awesome-platform")
27+
.crate_type("lib")
28+
.emit("asm")
29+
.run();
30+
rustc()
31+
.env("RUST_TARGET_PATH", ".")
32+
.input("foo.rs")
33+
.target("my-x86_64-unknown-linux-gnu-platform")
34+
.crate_type("lib")
35+
.emit("asm")
36+
.run();
37+
let test_platform = rustc()
38+
.arg("-Zunstable-options")
39+
.target("my-awesome-platform.json")
40+
.print("target-spec-json")
41+
.run()
42+
.stdout_utf8();
43+
fs_wrapper::create_file("test-platform.json");
44+
fs_wrapper::write("test-platform.json", test_platform.as_bytes());
45+
let test_platform_2 = rustc()
46+
.arg("-Zunstable-options")
47+
.target("test-platform.json")
48+
.print("target-spec-json")
49+
.run()
50+
.stdout_utf8();
51+
diff()
52+
.expected_file("test-platform.json")
53+
.actual_text("test-platform-2", test_platform_2)
54+
.run();
55+
rustc()
56+
.input("foo.rs")
57+
.target("definitely-not-builtin-target")
58+
.run_fail()
59+
.assert_stderr_contains("may not set is_builtin");
60+
rustc()
61+
.input("foo.rs")
62+
.target("endianness-mismatch")
63+
.run_fail()
64+
.assert_stderr_contains(r#""data-layout" claims architecture is little-endian"#);
65+
rustc()
66+
.input("foo.rs")
67+
.target("mismatching-data-layout")
68+
.crate_type("lib")
69+
.run_fail()
70+
.assert_stderr_contains("data-layout for target");
71+
}

0 commit comments

Comments
 (0)