Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3352,6 +3352,9 @@ impl Target {

Err(format!("could not find specification for target {target_tuple:?}"))
}
TargetTuple::TargetJson { ref contents, .. } if !unstable_options => {
Err("custom targets are unstable and require `-Zunstable-options`".to_string())
}
TargetTuple::TargetJson { ref contents, .. } => Target::from_json(contents),
}
}
Expand Down
6 changes: 5 additions & 1 deletion tests/run-make/rust-lld-custom-target/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@ fn main() {
// Compile to a custom target spec with rust-lld enabled by default. We'll check that by asking
// the linker to display its version number with a link-arg.
assert_rustc_uses_lld(
rustc().crate_type("cdylib").target("custom-target.json").input("lib.rs"),
rustc()
.crate_type("cdylib")
.target("custom-target.json")
.arg("-Zunstable-options")
.input("lib.rs"),
);

// But it can also be disabled via linker features.
Expand Down
8 changes: 7 additions & 1 deletion tests/run-make/rustdoc-target-spec-json-path/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,14 @@ use run_make_support::{cwd, rustc, rustdoc};

fn main() {
let out_dir = "rustdoc-target-spec-json-path";
rustc().crate_type("lib").input("dummy_core.rs").target("target.json").run();
rustc()
.arg("-Zunstable-options")
.crate_type("lib")
.input("dummy_core.rs")
.target("target.json")
.run();
rustdoc()
.arg("-Zunstable-options")
.input("my_crate.rs")
.out_dir(out_dir)
.library_search_path(cwd())
Expand Down
9 changes: 8 additions & 1 deletion tests/run-make/target-specs/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,20 @@ fn main() {
.target("my-incomplete-platform.json")
.run_fail()
.assert_stderr_contains("missing field `llvm-target`");
let test_platform = rustc()
let _ = rustc()
.input("foo.rs")
.target("my-x86_64-unknown-linux-gnu-platform")
.crate_type("lib")
.emit("asm")
.run_fail()
.assert_stderr_contains("custom targets are unstable and require `-Zunstable-options`");
let _ = rustc()
.input("foo.rs")
.target("my-awesome-platform.json")
.crate_type("lib")
.emit("asm")
.run_fail()
.assert_stderr_contains("custom targets are unstable and require `-Zunstable-options`");
rustc()
.arg("-Zunstable-options")
.env("RUST_TARGET_PATH", ".")
Expand Down
3 changes: 2 additions & 1 deletion tests/ui/check-cfg/values-target-json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
//@ check-pass
//@ no-auto-check-cfg
//@ needs-llvm-components: x86
//@ compile-flags: --crate-type=lib --check-cfg=cfg() --target={{src-base}}/check-cfg/my-awesome-platform.json
//@ compile-flags: --crate-type=lib --check-cfg=cfg()
//@ compile-flags: -Zunstable-options --target={{src-base}}/check-cfg/my-awesome-platform.json
//@ ignore-backends: gcc

#![feature(lang_items, no_core, auto_traits, rustc_attrs)]
Expand Down
Loading