Do not allow JSON targets to set is-builtin: true
This commit is contained in:
parent
6440785304
commit
f4701cd65c
5 changed files with 19 additions and 1 deletions
|
@ -2010,6 +2010,10 @@ impl Target {
|
||||||
key!(supported_sanitizers, SanitizerSet)?;
|
key!(supported_sanitizers, SanitizerSet)?;
|
||||||
key!(default_adjusted_cabi, Option<Abi>)?;
|
key!(default_adjusted_cabi, Option<Abi>)?;
|
||||||
|
|
||||||
|
if base.is_builtin {
|
||||||
|
// This can cause unfortunate ICEs later down the line.
|
||||||
|
return Err(format!("may not set is_builtin for targets not built-in"));
|
||||||
|
}
|
||||||
// Each field should have been read using `Json::remove_key` so any keys remaining are unused.
|
// Each field should have been read using `Json::remove_key` so any keys remaining are unused.
|
||||||
let remaining_keys = obj.as_object().ok_or("Expected JSON object for target")?.keys();
|
let remaining_keys = obj.as_object().ok_or("Expected JSON object for target")?.keys();
|
||||||
Ok((
|
Ok((
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
"executables": true,
|
"executables": true,
|
||||||
"has-elf-tls": true,
|
"has-elf-tls": true,
|
||||||
"has-rpath": true,
|
"has-rpath": true,
|
||||||
"is-builtin": true,
|
|
||||||
"linker-is-gnu": true,
|
"linker-is-gnu": true,
|
||||||
"llvm-target": "x86_64-unknown-linux-gnu",
|
"llvm-target": "x86_64-unknown-linux-gnu",
|
||||||
"max-atomic-width": 64,
|
"max-atomic-width": 64,
|
||||||
|
|
|
@ -7,3 +7,5 @@ all:
|
||||||
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm
|
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-awesome-platform --crate-type=lib --emit=asm
|
||||||
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
|
RUST_TARGET_PATH=. $(RUSTC) foo.rs --target=my-x86_64-unknown-linux-gnu-platform --crate-type=lib --emit=asm
|
||||||
$(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -
|
$(RUSTC) -Z unstable-options --target=my-awesome-platform.json --print target-spec-json > $(TMPDIR)/test-platform.json && $(RUSTC) -Z unstable-options --target=$(TMPDIR)/test-platform.json --print target-spec-json | diff -q $(TMPDIR)/test-platform.json -
|
||||||
|
$(RUSTC) foo.rs --target=definitely-not-builtin-target 2>&1 | $(CGREP) 'may not set is_builtin'
|
||||||
|
$(RUSTC) foo.rs --target=mismatching-data-layout
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"arch": "x86_64",
|
||||||
|
"is-builtin": true,
|
||||||
|
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
|
||||||
|
"llvm-target": "x86_64-unknown-unknown-gnu",
|
||||||
|
"target-pointer-width": "64"
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"arch": "x86_64",
|
||||||
|
"data-layout": "e-m:e-i64:16:32:64",
|
||||||
|
"llvm-target": "x86_64-unknown-unknown-gnu",
|
||||||
|
"target-pointer-width": "64"
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue