Skip to content

Commit 76b6623

Browse files
committed
target: fix destabilising target-spec-json
1 parent 1655912 commit 76b6623

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

compiler/rustc_target/src/spec/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3352,6 +3352,9 @@ impl Target {
33523352

33533353
Err(format!("could not find specification for target {target_tuple:?}"))
33543354
}
3355+
TargetTuple::TargetJson { ref contents, .. } if !unstable_options => {
3356+
Err("custom targets are unstable and require `-Zunstable-options`".to_string())
3357+
}
33553358
TargetTuple::TargetJson { ref contents, .. } => Target::from_json(contents),
33563359
}
33573360
}

tests/run-make/rust-lld-custom-target/rmake.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ fn main() {
1515
// Compile to a custom target spec with rust-lld enabled by default. We'll check that by asking
1616
// the linker to display its version number with a link-arg.
1717
assert_rustc_uses_lld(
18-
rustc().crate_type("cdylib").target("custom-target.json").input("lib.rs"),
18+
rustc()
19+
.crate_type("cdylib")
20+
.target("custom-target.json")
21+
.arg("-Zunstable-options")
22+
.input("lib.rs"),
1923
);
2024

2125
// But it can also be disabled via linker features.

tests/run-make/rustdoc-target-spec-json-path/rmake.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@ use run_make_support::{cwd, rustc, rustdoc};
55

66
fn main() {
77
let out_dir = "rustdoc-target-spec-json-path";
8-
rustc().crate_type("lib").input("dummy_core.rs").target("target.json").run();
8+
rustc()
9+
.arg("-Zunstable-options")
10+
.crate_type("lib")
11+
.input("dummy_core.rs")
12+
.target("target.json")
13+
.run();
914
rustdoc()
15+
.arg("-Zunstable-options")
1016
.input("my_crate.rs")
1117
.out_dir(out_dir)
1218
.library_search_path(cwd())

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@ fn main() {
2020
.target("my-incomplete-platform.json")
2121
.run_fail()
2222
.assert_stderr_contains("missing field `llvm-target`");
23-
let test_platform = rustc()
23+
let _ = rustc()
2424
.input("foo.rs")
2525
.target("my-x86_64-unknown-linux-gnu-platform")
2626
.crate_type("lib")
2727
.emit("asm")
2828
.run_fail()
2929
.assert_stderr_contains("custom targets are unstable and require `-Zunstable-options`");
30+
let _ = rustc()
31+
.input("foo.rs")
32+
.target("my-awesome-platform.json")
33+
.crate_type("lib")
34+
.emit("asm")
35+
.run_fail()
36+
.assert_stderr_contains("custom targets are unstable and require `-Zunstable-options`");
3037
rustc()
3138
.arg("-Zunstable-options")
3239
.env("RUST_TARGET_PATH", ".")

tests/ui/check-cfg/values-target-json.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
//@ check-pass
55
//@ no-auto-check-cfg
66
//@ needs-llvm-components: x86
7-
//@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json
7+
//@ compile-flags: --crate-type=lib --check-cfg=cfg()
8+
//@ compile-flags: -Zunstable-options --target={{src-base}}/check-cfg/my-awesome-platform.json
89
//@ ignore-backends: gcc
910

1011
#![feature(lang_items, no_core, auto_traits, rustc_attrs)]

0 commit comments

Comments
 (0)