@@ -17,6 +17,7 @@ pub enum Arch {
17
17
Arm64 ,
18
18
Arm64_32 ,
19
19
I386 ,
20
+ I686 ,
20
21
X86_64 ,
21
22
X86_64_sim ,
22
23
X86_64_macabi ,
@@ -33,13 +34,23 @@ impl Arch {
33
34
Arm64 | Arm64_macabi | Arm64_sim => "arm64" ,
34
35
Arm64_32 => "arm64_32" ,
35
36
I386 => "i386" ,
37
+ I686 => "i686" ,
36
38
X86_64 | X86_64_sim | X86_64_macabi => "x86_64" ,
37
39
}
38
40
}
39
41
42
+ pub fn target_arch ( self ) -> Cow < ' static , str > {
43
+ Cow :: Borrowed ( match self {
44
+ Armv7 | Armv7k | Armv7s => "arm" ,
45
+ Arm64 | Arm64_32 | Arm64_macabi | Arm64_sim => "aarch64" ,
46
+ I386 | I686 => "x86" ,
47
+ X86_64 | X86_64_sim | X86_64_macabi => "x86_64" ,
48
+ } )
49
+ }
50
+
40
51
fn target_abi ( self ) -> & ' static str {
41
52
match self {
42
- Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | X86_64 => "" ,
53
+ Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 => "" ,
43
54
X86_64_macabi | Arm64_macabi => "macabi" ,
44
55
// x86_64-apple-ios is a simulator target, even though it isn't
45
56
// declared that way in the target like the other ones...
@@ -54,7 +65,7 @@ impl Arch {
54
65
Armv7s => "cortex-a9" ,
55
66
Arm64 => "apple-a7" ,
56
67
Arm64_32 => "apple-s4" ,
57
- I386 => "yonah" ,
68
+ I386 | I686 => "yonah" ,
58
69
X86_64 | X86_64_sim => "core2" ,
59
70
X86_64_macabi => "core2" ,
60
71
Arm64_macabi => "apple-a12" ,
@@ -64,15 +75,16 @@ impl Arch {
64
75
65
76
fn link_env_remove ( self ) -> StaticCow < [ StaticCow < str > ] > {
66
77
match self {
67
- Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | X86_64 | X86_64_sim | Arm64_sim => {
78
+ Armv7 | Armv7k | Armv7s | Arm64 | Arm64_32 | I386 | I686 | X86_64 | X86_64_sim
79
+ | Arm64_sim => {
68
80
cvs ! [ "MACOSX_DEPLOYMENT_TARGET" ]
69
81
}
70
82
X86_64_macabi | Arm64_macabi => cvs ! [ "IPHONEOS_DEPLOYMENT_TARGET" ] ,
71
83
}
72
84
}
73
85
}
74
86
75
- fn pre_link_args ( os : & ' static str , arch : & ' static str , abi : & ' static str ) -> LinkArgs {
87
+ fn pre_link_args ( os : & ' static str , arch : Arch , abi : & ' static str ) -> LinkArgs {
76
88
let platform_name: StaticCow < str > = match abi {
77
89
"sim" => format ! ( "{}-simulator" , os) . into ( ) ,
78
90
"macabi" => "mac-catalyst" . into ( ) ,
@@ -88,6 +100,8 @@ fn pre_link_args(os: &'static str, arch: &'static str, abi: &'static str) -> Lin
88
100
}
89
101
. into ( ) ;
90
102
103
+ let arch = arch. target_name ( ) ;
104
+
91
105
let mut args = TargetOptions :: link_args (
92
106
LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) ,
93
107
& [ "-arch" , arch, "-platform_version" ] ,
@@ -118,7 +132,7 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
118
132
// TLS is flagged as enabled if it looks to be supported. The architecture
119
133
// only matters for default deployment target which is 11.0 for ARM64 and
120
134
// 10.7 for everything else.
121
- let has_thread_local = os == "macos" && macos_deployment_target ( "x86_64" ) >= ( 10 , 7 ) ;
135
+ let has_thread_local = os == "macos" && macos_deployment_target ( Arch :: X86_64 ) >= ( 10 , 7 ) ;
122
136
123
137
let abi = arch. target_abi ( ) ;
124
138
@@ -132,7 +146,7 @@ pub fn opts(os: &'static str, arch: Arch) -> TargetOptions {
132
146
// macOS has -dead_strip, which doesn't rely on function_sections
133
147
function_sections : false ,
134
148
dynamic_linking : true ,
135
- pre_link_args : pre_link_args ( os, arch. target_name ( ) , abi) ,
149
+ pre_link_args : pre_link_args ( os, arch, abi) ,
136
150
families : cvs ! [ "unix" ] ,
137
151
is_like_osx : true ,
138
152
default_dwarf_version : 2 ,
@@ -177,23 +191,24 @@ fn deployment_target(var_name: &str) -> Option<(u32, u32)> {
177
191
. and_then ( |( a, b) | a. parse :: < u32 > ( ) . and_then ( |a| b. parse :: < u32 > ( ) . map ( |b| ( a, b) ) ) . ok ( ) )
178
192
}
179
193
180
- fn macos_default_deployment_target ( arch : & str ) -> ( u32 , u32 ) {
181
- if arch == "arm64" { ( 11 , 0 ) } else { ( 10 , 7 ) }
194
+ fn macos_default_deployment_target ( arch : Arch ) -> ( u32 , u32 ) {
195
+ // Note: Arm64_sim is not included since macOS has no simulator.
196
+ if matches ! ( arch, Arm64 | Arm64_macabi ) { ( 11 , 0 ) } else { ( 10 , 7 ) }
182
197
}
183
198
184
- fn macos_deployment_target ( arch : & str ) -> ( u32 , u32 ) {
199
+ fn macos_deployment_target ( arch : Arch ) -> ( u32 , u32 ) {
185
200
deployment_target ( "MACOSX_DEPLOYMENT_TARGET" )
186
201
. unwrap_or_else ( || macos_default_deployment_target ( arch) )
187
202
}
188
203
189
- fn macos_lld_platform_version ( arch : & str ) -> String {
204
+ fn macos_lld_platform_version ( arch : Arch ) -> String {
190
205
let ( major, minor) = macos_deployment_target ( arch) ;
191
206
format ! ( "{}.{}" , major, minor)
192
207
}
193
208
194
- pub fn macos_llvm_target ( arch : & str ) -> String {
209
+ pub fn macos_llvm_target ( arch : Arch ) -> String {
195
210
let ( major, minor) = macos_deployment_target ( arch) ;
196
- format ! ( "{}-apple-macosx{}.{}.0" , arch, major, minor)
211
+ format ! ( "{}-apple-macosx{}.{}.0" , arch. target_name ( ) , major, minor)
197
212
}
198
213
199
214
pub fn macos_link_env_remove ( ) -> Vec < StaticCow < str > > {
0 commit comments