]> git.lizzy.rs Git - rust.git/commitdiff
Fixes for compilation to iOS:
authorkud1ing <github@kudling.de>
Fri, 1 Nov 2013 18:39:35 +0000 (19:39 +0100)
committerkud1ing <github@kudling.de>
Wed, 6 Nov 2013 21:11:09 +0000 (22:11 +0100)
- remove /usr/include from the include path since the iOS SDK provides the correct version
- `_NSGetEnviron()` is private and not available on iOS
- `.align` without an argument is not allowed with the Apple tools. 2^2 should be the default alignment
- ignore error messages for XCode < 5
- pass include path to libuv

mk/platform.mk
mk/rt.mk
src/rt/arch/arm/_context.S
src/rt/arch/arm/record_sp.S
src/rt/rust_builtin.cpp

index e7c9a10bc63e2e4873a79afceb61bc0acdc97bb8..d9df4d42f5796c3031176c56133caa7eb750c9aa 100644 (file)
@@ -195,8 +195,8 @@ CFG_RUN_TARG_i686-unknown-linux-gnu=$(call CFG_RUN_i686-unknown-linux-gnu,,$(2))
 
 # arm-apple-darwin configuration
 ifeq ($(CFG_OSTYPE),apple-darwin)
-CFG_IOS_SDK = $(shell xcrun --show-sdk-path -sdk iphoneos)
-CFG_IOS_FLAGS = -target arm-apple-darwin -isysroot $(CFG_IOS_SDK) -I $(CFG_IOS_SDK)/usr/include -I $(CFG_IOS_SDK)/usr/include/c++/4.2.1 -I /usr/include
+CFG_IOS_SDK = $(shell xcrun --show-sdk-path -sdk iphoneos 2>/dev/null)
+CFG_IOS_FLAGS = -target arm-apple-darwin -isysroot $(CFG_IOS_SDK) -I$(CFG_IOS_SDK)/usr/include -I$(CFG_IOS_SDK)/usr/include/c++/4.2.1
 CC_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang)
 CXX_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang++)
 CPP_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang++)
index d8490230675b866ac815e778e078d4cfbc5a31a5..3f5f079d504fcbfc7e0e314f4f83d0e3f2f2eedf 100644 (file)
--- a/mk/rt.mk
+++ b/mk/rt.mk
@@ -28,6 +28,13 @@ LIBUV_FLAGS_i386 = -m32 -fPIC -I$(S)src/etc/mingw-fix-include
 LIBUV_FLAGS_x86_64 = -m64 -fPIC
 ifeq ($(OSTYPE_$(1)), linux-androideabi)
 LIBUV_FLAGS_arm = -fPIC -DANDROID -std=gnu99
+else ifeq ($(OSTYPE_$(1)), apple-darwin)
+  ifeq ($(HOST_$(1)), arm)
+    IOS_SDK := $(shell xcrun --show-sdk-path -sdk iphoneos 2>/dev/null)
+    LIBUV_FLAGS_arm := -fPIC -std=gnu99 -I$(IOS_SDK)/usr/include -I$(IOS_SDK)/usr/include/c++/4.2.1
+  else
+    LIBUV_FLAGS_arm := -fPIC -std=gnu99
+  endif
 else
 LIBUV_FLAGS_arm = -fPIC -std=gnu99
 endif
index 6441f59a4d30c4371021a1d542a26c4e5200a533..7227c15cc47e9803324a07e8e0d8a95f91fd0703 100644 (file)
@@ -6,8 +6,11 @@
 .text
 .code 32
 .arm
+#if defined(__APPLE__)
+.align 2
+#else
 .align
-
+#endif
 
 .globl swap_registers
 swap_registers:
index 6900444c0fe295f1b68b349f16966ab47ff2ebf0..cce14ed5a3ecf09f01ba2c2a1e9290d674a7a01d 100644 (file)
@@ -6,8 +6,11 @@
 .text
 .code 32
 .arm
+#if defined(__APPLE__)
+.align 2
+#else
 .align
-
+#endif
 
 .globl record_sp_limit
 .globl get_sp_limit
index 90cfd98bc485933ca93b3cfc5b9259e256b04727..f682c596addb3b74328692d90751cff0c612abd5 100644 (file)
 #include <time.h>
 
 #ifdef __APPLE__
-#include <crt_externs.h>
-#include <mach/mach_time.h>
+    #include <TargetConditionals.h>
+    #include <mach/mach_time.h>
+
+    #if (TARGET_OS_IPHONE)
+        extern char **environ;
+    #else
+        #include <crt_externs.h>
+    #endif
 #endif
 
 #if !defined(__WIN32__)
@@ -58,7 +64,7 @@ rust_env_pairs() {
 #else
 extern "C" CDECL char**
 rust_env_pairs() {
-#ifdef __APPLE__
+#if defined(__APPLE__) && !(TARGET_OS_IPHONE)
     char **environ = *_NSGetEnviron();
 #endif
     return environ;