Skip to content

Commit 2a333ed

Browse files
author
kud1ing
committed
Fixes for compilation to iOS:
- 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
1 parent 3a15482 commit 2a333ed

File tree

5 files changed

+26
-7
lines changed

5 files changed

+26
-7
lines changed

mk/platform.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ CFG_RUN_TARG_i686-unknown-linux-gnu=$(call CFG_RUN_i686-unknown-linux-gnu,,$(2))
195195

196196
# arm-apple-darwin configuration
197197
ifeq ($(CFG_OSTYPE),apple-darwin)
198-
CFG_IOS_SDK = $(shell xcrun --show-sdk-path -sdk iphoneos)
199-
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
198+
CFG_IOS_SDK = $(shell xcrun --show-sdk-path -sdk iphoneos 2>/dev/null)
199+
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
200200
CC_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang)
201201
CXX_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang++)
202202
CPP_arm-apple-darwin = $(shell xcrun -find -sdk iphoneos clang++)

mk/rt.mk

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ LIBUV_FLAGS_i386 = -m32 -fPIC -I$(S)src/etc/mingw-fix-include
2828
LIBUV_FLAGS_x86_64 = -m64 -fPIC
2929
ifeq ($(OSTYPE_$(1)), linux-androideabi)
3030
LIBUV_FLAGS_arm = -fPIC -DANDROID -std=gnu99
31+
else ifeq ($(OSTYPE_$(1)), apple-darwin)
32+
ifeq ($(HOST_$(1)), arm)
33+
IOS_SDK := $(shell xcrun --show-sdk-path -sdk iphoneos 2>/dev/null)
34+
LIBUV_FLAGS_arm := -fPIC -std=gnu99 -I$(IOS_SDK)/usr/include -I$(IOS_SDK)/usr/include/c++/4.2.1
35+
else
36+
LIBUV_FLAGS_arm := -fPIC -std=gnu99
37+
endif
3138
else
3239
LIBUV_FLAGS_arm = -fPIC -std=gnu99
3340
endif

src/rt/arch/arm/_context.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
.text
77
.code 32
88
.arm
9+
#if defined(__APPLE__)
10+
.align 2
11+
#else
912
.align
10-
13+
#endif
1114

1215
.globl swap_registers
1316
swap_registers:

src/rt/arch/arm/record_sp.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
.text
77
.code 32
88
.arm
9+
#if defined(__APPLE__)
10+
.align 2
11+
#else
912
.align
10-
13+
#endif
1114

1215
.globl record_sp_limit
1316
.globl get_sp_limit

src/rt/rust_builtin.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@
1818
#include <time.h>
1919

2020
#ifdef __APPLE__
21-
#include <crt_externs.h>
22-
#include <mach/mach_time.h>
21+
#include <TargetConditionals.h>
22+
#include <mach/mach_time.h>
23+
24+
#if (TARGET_OS_IPHONE)
25+
extern char **environ;
26+
#else
27+
#include <crt_externs.h>
28+
#endif
2329
#endif
2430

2531
#if !defined(__WIN32__)
@@ -58,7 +64,7 @@ rust_env_pairs() {
5864
#else
5965
extern "C" CDECL char**
6066
rust_env_pairs() {
61-
#ifdef __APPLE__
67+
#if defined(__APPLE__) && !(TARGET_OS_IPHONE)
6268
char **environ = *_NSGetEnviron();
6369
#endif
6470
return environ;

0 commit comments

Comments
 (0)