Skip to content

Commit

Permalink
Auto merge of #77580 - petrochenkov:norestarg, r=matthewjasper
Browse files Browse the repository at this point in the history
rustc_target: Refactor away `TargetResult`

Follow-up to #77202.

Construction of a built-in target is always infallible now, so `TargetResult` is no longer necessary.

The second commit contains some further cleanup based on built-in target construction being infallible.
  • Loading branch information
bors committed Oct 10, 2020
2 parents 1661f77 + 1444ad7 commit 0e022fc
Show file tree
Hide file tree
Showing 159 changed files with 633 additions and 668 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,8 @@ impl RustcDefaultCalls {
for req in &sess.opts.prints {
match *req {
TargetList => {
let mut targets = rustc_target::spec::get_targets().collect::<Vec<String>>();
let mut targets =
rustc_target::spec::TARGETS.iter().copied().collect::<Vec<_>>();
targets.sort();
println!("{}", targets.join("\n"));
}
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_apple_darwin.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::apple_base::opts();
base.cpu = "apple-a12".to_string();
base.max_atomic_width = Some(128);
Expand All @@ -14,7 +14,7 @@ pub fn target() -> TargetResult {
let arch = "aarch64";
let llvm_target = super::apple_base::macos_llvm_target(&arch);

Ok(Target {
Target {
llvm_target,
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -26,5 +26,5 @@ pub fn target() -> TargetResult {
target_vendor: "apple".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { target_mcount: "\u{1}mcount".to_string(), ..base },
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_apple_ios.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::apple_sdk_base::{opts, Arch};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let base = opts(Arch::Arm64);
Ok(Target {
Target {
llvm_target: "arm64-apple-ios".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand Down Expand Up @@ -33,5 +33,5 @@ pub fn target() -> TargetResult {
.to_string(),
..base
},
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_apple_tvos.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use super::apple_sdk_base::{opts, Arch};
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let base = opts(Arch::Arm64);
Ok(Target {
Target {
llvm_target: "arm64-apple-tvos".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -22,5 +22,5 @@ pub fn target() -> TargetResult {
forces_embed_bitcode: true,
..base
},
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_fuchsia.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetOptions};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::fuchsia_base::opts();
base.max_atomic_width = Some(128);

Ok(Target {
Target {
llvm_target: "aarch64-fuchsia".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -16,5 +16,5 @@ pub fn target() -> TargetResult {
target_vendor: String::new(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_linux_android.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions};

// See https://developer.android.com/ndk/guides/abis.html#arm64-v8a
// for target ABI requirements.

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::android_base::opts();
base.max_atomic_width = Some(128);
// As documented in http://developer.android.com/ndk/guides/cpu-features.html
// the neon (ASIMD) and FP must exist on all android aarch64 targets.
base.features = "+neon,+fp-armv8".to_string();
Ok(Target {
Target {
llvm_target: "aarch64-linux-android".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -21,5 +21,5 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_pc_windows_msvc.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::windows_msvc_base::opts();
base.max_atomic_width = Some(64);
base.has_elf_tls = true;
base.features = "+neon,+fp-armv8".to_string();

Ok(Target {
Target {
llvm_target: "aarch64-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -18,5 +18,5 @@ pub fn target() -> TargetResult {
target_vendor: "pc".to_string(),
linker_flavor: LinkerFlavor::Msvc,
options: base,
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_unknown_cloudabi.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::cloudabi_base::opts();
base.max_atomic_width = Some(128);
base.unsupported_abis = super::arm_base::unsupported_abis();
base.linker = Some("aarch64-unknown-cloudabi-cc".to_string());

Ok(Target {
Target {
llvm_target: "aarch64-unknown-cloudabi".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -18,5 +18,5 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_unknown_freebsd.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::freebsd_base::opts();
base.max_atomic_width = Some(128);

Ok(Target {
Target {
llvm_target: "aarch64-unknown-freebsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -16,5 +16,5 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_unknown_hermit.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::spec::{LinkerFlavor, LldFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, LldFlavor, Target};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::hermit_base::opts();
base.max_atomic_width = Some(128);

Ok(Target {
Target {
llvm_target: "aarch64-unknown-hermit".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -16,5 +16,5 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
options: base,
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_unknown_linux_gnu.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::linux_base::opts();
base.max_atomic_width = Some(128);

Ok(Target {
Target {
llvm_target: "aarch64-unknown-linux-gnu".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -20,5 +20,5 @@ pub fn target() -> TargetResult {
target_mcount: "\u{1}_mcount".to_string(),
..base
},
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_unknown_linux_musl.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::linux_musl_base::opts();
base.max_atomic_width = Some(128);

Ok(Target {
Target {
llvm_target: "aarch64-unknown-linux-musl".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -20,5 +20,5 @@ pub fn target() -> TargetResult {
target_mcount: "\u{1}_mcount".to_string(),
..base
},
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_unknown_netbsd.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::spec::{LinkerFlavor, Target, TargetOptions, TargetResult};
use crate::spec::{LinkerFlavor, Target, TargetOptions};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::netbsd_base::opts();
base.max_atomic_width = Some(128);
base.unsupported_abis = super::arm_base::unsupported_abis();

Ok(Target {
Target {
llvm_target: "aarch64-unknown-netbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -17,5 +17,5 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { target_mcount: "__mcount".to_string(), ..base },
})
}
}
6 changes: 3 additions & 3 deletions compiler/rustc_target/src/spec/aarch64_unknown_none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOptions};

pub fn target() -> Result<Target, String> {
pub fn target() -> Target {
let opts = TargetOptions {
linker: Some("rust-lld".to_owned()),
features: "+strict-align,+neon,+fp-armv8".to_string(),
Expand All @@ -21,7 +21,7 @@ pub fn target() -> Result<Target, String> {
unsupported_abis: super::arm_base::unsupported_abis(),
..Default::default()
};
Ok(Target {
Target {
llvm_target: "aarch64-unknown-none".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -33,5 +33,5 @@ pub fn target() -> Result<Target, String> {
arch: "aarch64".to_string(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
options: opts,
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

use super::{LinkerFlavor, LldFlavor, PanicStrategy, RelocModel, Target, TargetOptions};

pub fn target() -> Result<Target, String> {
pub fn target() -> Target {
let opts = TargetOptions {
linker: Some("rust-lld".to_owned()),
features: "+strict-align,-neon,-fp-armv8".to_string(),
Expand All @@ -21,7 +21,7 @@ pub fn target() -> Result<Target, String> {
unsupported_abis: super::arm_base::unsupported_abis(),
..Default::default()
};
Ok(Target {
Target {
llvm_target: "aarch64-unknown-none".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -33,5 +33,5 @@ pub fn target() -> Result<Target, String> {
arch: "aarch64".to_string(),
linker_flavor: LinkerFlavor::Lld(LldFlavor::Ld),
options: opts,
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_unknown_openbsd.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::openbsd_base::opts();
base.max_atomic_width = Some(128);
base.unsupported_abis = super::arm_base::unsupported_abis();

Ok(Target {
Target {
llvm_target: "aarch64-unknown-openbsd".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -17,5 +17,5 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_unknown_redox.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::redox_base::opts();
base.max_atomic_width = Some(128);

Ok(Target {
Target {
llvm_target: "aarch64-unknown-redox".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -16,5 +16,5 @@ pub fn target() -> TargetResult {
target_vendor: "unknown".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: base,
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_uwp_windows_msvc.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::spec::{LinkerFlavor, Target, TargetResult};
use crate::spec::{LinkerFlavor, Target};

pub fn target() -> TargetResult {
pub fn target() -> Target {
let mut base = super::windows_uwp_msvc_base::opts();
base.max_atomic_width = Some(64);
base.has_elf_tls = true;

Ok(Target {
Target {
llvm_target: "aarch64-pc-windows-msvc".to_string(),
target_endian: "little".to_string(),
target_pointer_width: "64".to_string(),
Expand All @@ -17,5 +17,5 @@ pub fn target() -> TargetResult {
target_vendor: "uwp".to_string(),
linker_flavor: LinkerFlavor::Msvc,
options: base,
})
}
}
Loading

0 comments on commit 0e022fc

Please sign in to comment.