Skip to content

Commit

Permalink
Fixes for compilation to iOS:
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
kud1ing committed Nov 6, 2013
1 parent 3a15482 commit 2a333ed
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions mk/platform.mk
Expand Up @@ -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++)
Expand Down
7 changes: 7 additions & 0 deletions mk/rt.mk
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/rt/arch/arm/_context.S
Expand Up @@ -6,8 +6,11 @@
.text
.code 32
.arm
#if defined(__APPLE__)
.align 2
#else
.align

#endif

.globl swap_registers
swap_registers:
Expand Down
5 changes: 4 additions & 1 deletion src/rt/arch/arm/record_sp.S
Expand Up @@ -6,8 +6,11 @@
.text
.code 32
.arm
#if defined(__APPLE__)
.align 2
#else
.align

#endif

.globl record_sp_limit
.globl get_sp_limit
Expand Down
12 changes: 9 additions & 3 deletions src/rt/rust_builtin.cpp
Expand Up @@ -18,8 +18,14 @@
#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__)
Expand Down Expand Up @@ -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;
Expand Down

5 comments on commit 2a333ed

@bors
Copy link
Contributor

@bors bors commented on 2a333ed Nov 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 2a333ed Nov 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging kud1ing/rust/ios = 2a333ed into auto

@bors
Copy link
Contributor

@bors bors commented on 2a333ed Nov 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kud1ing/rust/ios = 2a333ed merged ok, testing candidate = 22eb11c

@bors
Copy link
Contributor

@bors bors commented on 2a333ed Nov 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on 2a333ed Nov 6, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 22eb11c

Please sign in to comment.