Skip to content

Commit f2ea2f6

Browse files
committedNov 8, 2020
Auto merge of #77729 - petrochenkov:mergetarg, r=Mark-Simulacrum
rustc_target: Move some target options from `Target` to `TargetOptions` The only reason for `Target` to `TargetOptions` to be separate structures is that options in `TargetOptions` have reasonable defaults and options in `Target` don't. (Otherwise all the options logically belong to a single `Target` struct.) This PR moves a number of options with reasonable defaults from `Target` to `TargetOptions`, so they no longer needs to be specified explicitly for majority of the targets. The move also allows to inherit the options from `rustc_target/src/spec/*_base.rs` files in a nicer way. I didn't change any specific option values here. The moved options are `target_c_int_width` (defaults to `"32"`), `target_endian` (defaults to `"little"`), `target_os` (defaults to `"none"`), `target_env` (defaults to `""`), `target_vendor` (defaults to `"unknown"`) and `linker_flavor` (defaults to `LinkerFlavor::Gcc`). Next steps (in later PRs): - Find a way to merge `TargetOptions` into `Target` - If not, always access `TargetOptions` fields through `Deref` making it a part of `Target` at least logically (`session.target.target.options.foo` -> `session.target.target.foo`) - ~Eliminate `session::config::Config` and use `Target` instead (`session.target.target.foo` -> `session.target.foo`)~ Done in #77943. - Avoid tautologies in option names (`target.target_os` -> `target.os`) - Resolve _ #77730 (rustc_target: The differences between `target_os = "none"` and `target_os = "unknown"`, and `target_vendor = "unknown"` and `target_vendor = ""` are unclear) noticed during implementation of this PR.
·
1.90.01.49.0
2 parents 771cc7f + c0c0597 commit f2ea2f6

File tree

181 files changed

+322
-1061
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+322
-1061
lines changed
 
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::spec::{LinkerFlavor, Target, TargetOptions};
22

33
pub fn target() -> Target {
4-
let mut base = super::apple_base::opts();
4+
let mut base = super::apple_base::opts("macos");
55
base.cpu = "apple-a12".to_string();
66
base.max_atomic_width = Some(128);
77
base.pre_link_args.insert(LinkerFlavor::Gcc, vec!["-arch".to_string(), "arm64".to_string()]);
@@ -16,15 +16,9 @@ pub fn target() -> Target {
1616

1717
Target {
1818
llvm_target,
19-
target_endian: "little".to_string(),
2019
pointer_width: 64,
21-
target_c_int_width: "32".to_string(),
2220
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
2321
arch: arch.to_string(),
24-
target_os: "macos".to_string(),
25-
target_env: String::new(),
26-
target_vendor: "apple".to_string(),
27-
linker_flavor: LinkerFlavor::Gcc,
2822
options: TargetOptions { target_mcount: "\u{1}mcount".to_string(), ..base },
2923
}
3024
}

‎compiler/rustc_target/src/spec/aarch64_apple_ios.rs‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
use super::apple_sdk_base::{opts, Arch};
2-
use crate::spec::{LinkerFlavor, Target, TargetOptions};
2+
use crate::spec::{Target, TargetOptions};
33

44
pub fn target() -> Target {
5-
let base = opts(Arch::Arm64);
5+
let base = opts("ios", Arch::Arm64);
66
Target {
77
llvm_target: "arm64-apple-ios".to_string(),
8-
target_endian: "little".to_string(),
98
pointer_width: 64,
10-
target_c_int_width: "32".to_string(),
119
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".to_string(),
1210
arch: "aarch64".to_string(),
13-
target_os: "ios".to_string(),
14-
target_env: String::new(),
15-
target_vendor: "apple".to_string(),
16-
linker_flavor: LinkerFlavor::Gcc,
1711
options: TargetOptions {
1812
features: "+neon,+fp-armv8,+apple-a7".to_string(),
1913
eliminate_frame_pointer: false,

0 commit comments

Comments
 (0)
Please sign in to comment.