@@ -135,27 +135,64 @@ pub fn compiler_rt(build: &Build, target: &str) {
135
135
let dst = build. compiler_rt_out ( target) ;
136
136
let arch = target. split ( '-' ) . next ( ) . unwrap ( ) ;
137
137
let mode = if build. config . rust_optimize { "Release" } else { "Debug" } ;
138
+
139
+ let build_llvm_config = build. llvm_config ( & build. config . build ) ;
140
+ let mut cfg = cmake:: Config :: new ( build. src . join ( "src/compiler-rt" ) ) ;
141
+ cfg. target ( target)
142
+ . host ( & build. config . build )
143
+ . out_dir ( & dst)
144
+ . profile ( mode)
145
+ . define ( "LLVM_CONFIG_PATH" , build_llvm_config)
146
+ . define ( "COMPILER_RT_DEFAULT_TARGET_TRIPLE" , target)
147
+ . define ( "COMPILER_RT_BUILD_SANITIZERS" , "OFF" )
148
+ . define ( "COMPILER_RT_BUILD_EMUTLS" , "OFF" )
149
+ // inform about c/c++ compilers, the c++ compiler isn't actually used but
150
+ // it's needed to get the initial configure to work on all platforms.
151
+ . define ( "CMAKE_C_COMPILER" , build. cc ( target) )
152
+ . define ( "CMAKE_CXX_COMPILER" , build. cc ( target) ) ;
153
+
138
154
let ( dir, build_target, libname) = if target. contains ( "linux" ) ||
139
155
target. contains ( "freebsd" ) ||
140
156
target. contains ( "netbsd" ) {
141
- let os = if target. contains ( "android" ) { "-android" } else { "" } ;
142
- let arch = if arch. starts_with ( "arm" ) && target. contains ( "eabihf" ) {
143
- "armhf"
157
+ let os_extra = if target. contains ( "android" ) && target. contains ( "arm" ) {
158
+ "-android"
144
159
} else {
145
- arch
160
+ ""
146
161
} ;
147
- let target = format ! ( "clang_rt.builtins-{}{}" , arch, os) ;
162
+ let builtins_arch = match arch {
163
+ "i586" => "i386" ,
164
+ "arm" | "armv7" if target. contains ( "android" ) => "armhf" ,
165
+ "arm" if target. contains ( "eabihf" ) => "armhf" ,
166
+ _ => arch,
167
+ } ;
168
+ let target = format ! ( "clang_rt.builtins-{}{}" , builtins_arch, os_extra) ;
148
169
( "linux" . to_string ( ) , target. clone ( ) , target)
149
- } else if target. contains ( "darwin" ) {
150
- let target = format ! ( "clang_rt.builtins_{}_osx" , arch) ;
170
+ } else if target. contains ( "apple-darwin" ) {
171
+ let builtins_arch = match arch {
172
+ "i686" => "i386" ,
173
+ _ => arch,
174
+ } ;
175
+ let target = format ! ( "clang_rt.builtins_{}_osx" , builtins_arch) ;
176
+ ( "builtins" . to_string ( ) , target. clone ( ) , target)
177
+ } else if target. contains ( "apple-ios" ) {
178
+ cfg. define ( "COMPILER_RT_ENABLE_IOS" , "ON" ) ;
179
+ let target = match arch {
180
+ "armv7s" => "hard_pic_armv7em_macho_embedded" . to_string ( ) ,
181
+ "aarch64" => "builtins_arm64_ios" . to_string ( ) ,
182
+ _ => format ! ( "hard_pic_{}_macho_embedded" , arch) ,
183
+ } ;
151
184
( "builtins" . to_string ( ) , target. clone ( ) , target)
152
185
} else if target. contains ( "windows-gnu" ) {
153
186
let target = format ! ( "clang_rt.builtins-{}" , arch) ;
154
187
( "windows" . to_string ( ) , target. clone ( ) , target)
155
188
} else if target. contains ( "windows-msvc" ) {
189
+ let builtins_arch = match arch {
190
+ "i586" | "i686" => "i386" ,
191
+ _ => arch,
192
+ } ;
156
193
( format ! ( "windows/{}" , mode) ,
157
194
"lib/builtins/builtins" . to_string ( ) ,
158
- format ! ( "clang_rt.builtins-{}" , arch . replace ( "i686" , "i386" ) ) )
195
+ format ! ( "clang_rt.builtins-{}" , builtins_arch ) )
159
196
} else {
160
197
panic ! ( "can't get os from target: {}" , target)
161
198
} ;
@@ -168,21 +205,7 @@ pub fn compiler_rt(build: &Build, target: &str) {
168
205
}
169
206
let _ = fs:: remove_dir_all ( & dst) ;
170
207
t ! ( fs:: create_dir_all( & dst) ) ;
171
- let build_llvm_config = build. llvm_config ( & build. config . build ) ;
172
- let mut cfg = cmake:: Config :: new ( build. src . join ( "src/compiler-rt" ) ) ;
173
- cfg. target ( target)
174
- . host ( & build. config . build )
175
- . out_dir ( & dst)
176
- . profile ( mode)
177
- . define ( "LLVM_CONFIG_PATH" , build_llvm_config)
178
- . define ( "COMPILER_RT_DEFAULT_TARGET_TRIPLE" , target)
179
- . define ( "COMPILER_RT_BUILD_SANITIZERS" , "OFF" )
180
- . define ( "COMPILER_RT_BUILD_EMUTLS" , "OFF" )
181
- // inform about c/c++ compilers, the c++ compiler isn't actually used but
182
- // it's needed to get the initial configure to work on all platforms.
183
- . define ( "CMAKE_C_COMPILER" , build. cc ( target) )
184
- . define ( "CMAKE_CXX_COMPILER" , build. cc ( target) )
185
- . build_target ( & build_target) ;
208
+ cfg. build_target ( & build_target) ;
186
209
cfg. build ( ) ;
187
210
}
188
211
0 commit comments