@@ -114,6 +114,13 @@ pub mod write {
114114 // which are *far* more efficient. This is obviously undesirable in some
115115 // cases, so if any sort of target feature is specified we don't append v7
116116 // to the feature list.
117+ //
118+ // On iOS only armv7 and newer are supported. So it is useful to
119+ // get all hardware potential via VFP3 (hardware floating point)
120+ // and NEON (SIMD) instructions supported by LLVM.
121+ // Note that without those flags various linking errors might
122+ // arise as some of intrinsicts are converted into function calls
123+ // and nobody provides implementations those functions
117124 fn target_feature < ' a > ( sess : & ' a Session ) -> & ' a str {
118125 match sess. targ_cfg . os {
119126 abi:: OsAndroid => {
@@ -122,7 +129,10 @@ pub mod write {
122129 } else {
123130 sess. opts . cg . target_feature . as_slice ( )
124131 }
125- }
132+ } ,
133+ abi:: OsiOS if sess. targ_cfg . arch == abi:: Arm => {
134+ "+v7,+thumb2,+vfp3,+neon"
135+ } ,
126136 _ => sess. opts . cg . target_feature . as_slice ( )
127137 }
128138 }
@@ -827,15 +837,23 @@ pub fn filename_for_input(sess: &Session, crate_type: config::CrateType,
827837 out_filename. with_filename ( format ! ( "lib{}.rlib" , libname) )
828838 }
829839 config:: CrateTypeDylib => {
830- let ( prefix, suffix) = match sess. targ_cfg . os {
831- abi:: OsWin32 => ( loader:: WIN32_DLL_PREFIX , loader:: WIN32_DLL_SUFFIX ) ,
832- abi:: OsMacos => ( loader:: MACOS_DLL_PREFIX , loader:: MACOS_DLL_SUFFIX ) ,
833- abi:: OsLinux => ( loader:: LINUX_DLL_PREFIX , loader:: LINUX_DLL_SUFFIX ) ,
834- abi:: OsAndroid => ( loader:: ANDROID_DLL_PREFIX , loader:: ANDROID_DLL_SUFFIX ) ,
835- abi:: OsFreebsd => ( loader:: FREEBSD_DLL_PREFIX , loader:: FREEBSD_DLL_SUFFIX ) ,
836- } ;
837- out_filename. with_filename ( format ! ( "{}{}{}" , prefix, libname,
838- suffix) )
840+ // There is no support of DyLibs on iOS
841+ if sess. targ_cfg . os == abi:: OsiOS {
842+ out_filename. with_filename ( format ! ( "lib{}.a" , libname) )
843+ } else {
844+ let ( prefix, suffix) = match sess. targ_cfg . os {
845+ abi:: OsWin32 => ( loader:: WIN32_DLL_PREFIX , loader:: WIN32_DLL_SUFFIX ) ,
846+ abi:: OsMacos => ( loader:: MACOS_DLL_PREFIX , loader:: MACOS_DLL_SUFFIX ) ,
847+ abi:: OsLinux => ( loader:: LINUX_DLL_PREFIX , loader:: LINUX_DLL_SUFFIX ) ,
848+ abi:: OsAndroid => ( loader:: ANDROID_DLL_PREFIX , loader:: ANDROID_DLL_SUFFIX ) ,
849+ abi:: OsFreebsd => ( loader:: FREEBSD_DLL_PREFIX , loader:: FREEBSD_DLL_SUFFIX ) ,
850+ abi:: OsiOS => unreachable ! ( ) ,
851+ } ;
852+ out_filename. with_filename ( format ! ( "{}{}{}" ,
853+ prefix,
854+ libname,
855+ suffix) )
856+ }
839857 }
840858 config:: CrateTypeStaticlib => {
841859 out_filename. with_filename ( format ! ( "lib{}.a" , libname) )
@@ -886,7 +904,14 @@ fn link_binary_output(sess: &Session,
886904 link_natively ( sess, trans, false , & obj_filename, & out_filename) ;
887905 }
888906 config:: CrateTypeDylib => {
889- link_natively ( sess, trans, true , & obj_filename, & out_filename) ;
907+ if sess. targ_cfg . os == abi:: OsiOS {
908+ sess. warn ( format ! ( "No dylib for iOS -> saving static library {} to {}" ,
909+ obj_filename. display( ) , out_filename. display( ) ) . as_slice ( ) ) ;
910+ link_staticlib ( sess, & obj_filename, & out_filename) ;
911+ }
912+ else {
913+ link_natively ( sess, trans, true , & obj_filename, & out_filename) ;
914+ }
890915 }
891916 }
892917
@@ -991,7 +1016,7 @@ fn link_rlib<'a>(sess: &'a Session,
9911016 // symbol table of the archive. This currently dies on OSX (see
9921017 // #11162), and isn't necessary there anyway
9931018 match sess. targ_cfg . os {
994- abi:: OsMacos => { }
1019+ abi:: OsMacos | abi :: OsiOS => { }
9951020 _ => { a. update_symbols ( ) ; }
9961021 }
9971022 }
@@ -1104,15 +1129,16 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
11041129
11051130 // On OSX, debuggers need this utility to get run to do some munging of
11061131 // the symbols
1107- if sess. targ_cfg . os == abi:: OsMacos && ( sess. opts . debuginfo != NoDebugInfo ) {
1108- match Command :: new ( "dsymutil" ) . arg ( out_filename) . status ( ) {
1109- Ok ( ..) => { }
1110- Err ( e) => {
1111- sess. err ( format ! ( "failed to run dsymutil: {}" , e) . as_slice ( ) ) ;
1112- sess. abort_if_errors ( ) ;
1132+ if ( sess. targ_cfg . os == abi:: OsMacos || sess. targ_cfg . os == abi:: OsiOS )
1133+ && ( sess. opts . debuginfo != NoDebugInfo ) {
1134+ match Command :: new ( "dsymutil" ) . arg ( out_filename) . status ( ) {
1135+ Ok ( ..) => { }
1136+ Err ( e) => {
1137+ sess. err ( format ! ( "failed to run dsymutil: {}" , e) . as_slice ( ) ) ;
1138+ sess. abort_if_errors ( ) ;
1139+ }
11131140 }
11141141 }
1115- }
11161142}
11171143
11181144fn link_args ( cmd : & mut Command ,
@@ -1169,7 +1195,7 @@ fn link_args(cmd: &mut Command,
11691195 // already done the best it can do, and we also don't want to eliminate the
11701196 // metadata. If we're building an executable, however, --gc-sections drops
11711197 // the size of hello world from 1.8MB to 597K, a 67% reduction.
1172- if !dylib && sess. targ_cfg . os != abi:: OsMacos {
1198+ if !dylib && sess. targ_cfg . os != abi:: OsMacos && sess . targ_cfg . os != abi :: OsiOS {
11731199 cmd. arg ( "-Wl,--gc-sections" ) ;
11741200 }
11751201
@@ -1185,7 +1211,7 @@ fn link_args(cmd: &mut Command,
11851211 sess. opts . optimize == config:: Aggressive {
11861212 cmd. arg ( "-Wl,-O1" ) ;
11871213 }
1188- } else if sess. targ_cfg . os == abi:: OsMacos {
1214+ } else if sess. targ_cfg . os == abi:: OsMacos || sess . targ_cfg . os == abi :: OsiOS {
11891215 // The dead_strip option to the linker specifies that functions and data
11901216 // unreachable by the entry point will be removed. This is quite useful
11911217 // with Rust's compilation model of compiling libraries at a time into
@@ -1348,7 +1374,7 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
13481374 // For those that support this, we ensure we pass the option if the library
13491375 // was flagged "static" (most defaults are dynamic) to ensure that if
13501376 // libfoo.a and libfoo.so both exist that the right one is chosen.
1351- let takes_hints = sess. targ_cfg . os != abi:: OsMacos ;
1377+ let takes_hints = sess. targ_cfg . os != abi:: OsMacos && sess . targ_cfg . os != abi :: OsiOS ;
13521378
13531379 for & ( ref l, kind) in sess. cstore . get_used_libraries ( ) . borrow ( ) . iter ( ) {
13541380 match kind {
0 commit comments