Skip to content

Commit

Permalink
rustc_target: Refactor away TargetResult
Browse files Browse the repository at this point in the history
Construction of a built-in target is always infallible now, so `TargetResult` is no longer necessary.
  • Loading branch information
petrochenkov committed Oct 5, 2020
1 parent f317a93 commit 021fcbd
Show file tree
Hide file tree
Showing 158 changed files with 619 additions and 630 deletions.
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_apple_darwin.rs
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
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,
})
}
}
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
@@ -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
@@ -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
@@ -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,
})
}
}
8 changes: 4 additions & 4 deletions compiler/rustc_target/src/spec/aarch64_wrs_vxworks.rs
@@ -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::vxworks_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 @@ -16,5 +16,5 @@ pub fn target() -> TargetResult {
target_vendor: "wrs".to_string(),
linker_flavor: LinkerFlavor::Gcc,
options: TargetOptions { unsupported_abis: super::arm_base::unsupported_abis(), ..base },
})
}
}

0 comments on commit 021fcbd

Please sign in to comment.