@@ -135,27 +135,64 @@ pub fn compiler_rt(build: &Build, target: &str) {
135135 let dst = build. compiler_rt_out ( target) ;
136136 let arch = target. split ( '-' ) . next ( ) . unwrap ( ) ;
137137 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+
138154 let ( dir, build_target, libname) = if target. contains ( "linux" ) ||
139155 target. contains ( "freebsd" ) ||
140156 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"
144159 } else {
145- arch
160+ ""
146161 } ;
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) ;
148169 ( "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+ } ;
151184 ( "builtins" . to_string ( ) , target. clone ( ) , target)
152185 } else if target. contains ( "windows-gnu" ) {
153186 let target = format ! ( "clang_rt.builtins-{}" , arch) ;
154187 ( "windows" . to_string ( ) , target. clone ( ) , target)
155188 } else if target. contains ( "windows-msvc" ) {
189+ let builtins_arch = match arch {
190+ "i586" | "i686" => "i386" ,
191+ _ => arch,
192+ } ;
156193 ( format ! ( "windows/{}" , mode) ,
157194 "lib/builtins/builtins" . to_string ( ) ,
158- format ! ( "clang_rt.builtins-{}" , arch . replace ( "i686" , "i386" ) ) )
195+ format ! ( "clang_rt.builtins-{}" , builtins_arch ) )
159196 } else {
160197 panic ! ( "can't get os from target: {}" , target)
161198 } ;
@@ -168,21 +205,7 @@ pub fn compiler_rt(build: &Build, target: &str) {
168205 }
169206 let _ = fs:: remove_dir_all ( & dst) ;
170207 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) ;
186209 cfg. build ( ) ;
187210}
188211
0 commit comments