Skip to content

Doc building for ios

kud1ing edited this page Nov 1, 2013 · 77 revisions

This currently does not work.

Options

Option 1: Convert Rust's LLVM bitcode to C-code

rustc foo.rs -o foo.stage2 -O --save-temps
llc -march=c foo.bc -o foo.c

Option 2: Use Rust's Android-ARM assembler code

TODO: something using rustc --emit-llvm -S --target=arm-linux-androideabi

Option 3: Add native iOS-support to Rust

  1. add an arm-apple-darwin target triple to mk/platform.mk:
# arm-apple-darwin configuration
CFG_IOS_VERSION=7.0
CFG_IOS_TOOLS=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/
CFG_IOS_FLAGS = -target arm-apple-darwin -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(CFG_IOS_VERSION).sdk/ -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(CFG_IOS_VERSION).sdk/usr/include -I /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(CFG_IOS_VERSION).sdk/usr/include/c++/4.2.1 -I /usr/include
CC_arm-apple-darwin= $(CFG_IOS_TOOLS)/clang
CXX_arm-apple-darwin= $(CFG_IOS_TOOLS)/clang++
CPP_arm-apple-darwin= $(CFG_IOS_TOOLS)/clang++
AR_arm-apple-darwin= $(CFG_IOS_TOOLS)/ar
CFG_LIB_NAME_arm-apple-darwin=lib$(1).dylib
CFG_LIB_GLOB_arm-apple-darwin=lib$(1)-*.dylib
CFG_LIB_DSYM_GLOB_arm-apple-darwin=lib$(1)-*.dylib.dSYM
CFG_GCCISH_CFLAGS_arm-apple-darwin := -Wall -Werror -g -fPIC $(CFG_IOS_FLAGS)
CFG_GCCISH_CXXFLAGS_arm-apple-darwin := -fno-rtti $(CFG_IOS_FLAGS)
CFG_GCCISH_LINK_FLAGS_arm-apple-darwin := -dynamiclib -lpthread -framework CoreServices -Wl,-no_compact_unwind 
CFG_GCCISH_DEF_FLAG_arm-apple-darwin := -Wl,-exported_symbols_list,
CFG_GCCISH_PRE_LIB_FLAGS_arm-apple-darwin :=
CFG_GCCISH_POST_LIB_FLAGS_arm-apple-darwin :=
CFG_DEF_SUFFIX_arm-apple-darwin := .darwin.def
CFG_INSTALL_NAME_arm-apple-darwin = -Wl,-install_name,@rpath/$(1)
CFG_LIBUV_LINK_FLAGS_arm-apple-darwin =
CFG_EXE_SUFFIX_arm-apple-darwin :=
CFG_WINDOWSY_arm-apple-darwin :=
CFG_UNIXY_arm-apple-darwin := 1
CFG_PATH_MUNGE_arm-apple-darwin := true
CFG_LDPATH_arm-apple-darwin :=
CFG_RUN_arm-apple-darwin=$(2)
CFG_RUN_TARG_arm-apple-darwin=$(call CFG_RUN_arm-apple-darwin,,$(2))
  1. Adjust src/rt/rust_builtin.cpp:
#ifdef __APPLE__
    #include <TargetConditionals.h>
    #include <mach/mach_time.h>

    #if !defined(TARGET_OS_IPHONE)
        #include <crt_externs.h>
    #endif
#endif

and

rust_env_pairs() {
#ifdef __APPLE__
    #if !defined(TARGET_OS_IPHONE)
    char **environ = *_NSGetEnviron();
    #else
    char **environ = 0L;
    #endif
  1. Adjust src/rt/arch/arm/_context.S:
.align 2

TODO: this needs a guard which makes sures, this is affects only ARM and/or iOS

  1. Adjust src/rt/arch/arm/record_sp.S:
.align 2

TODO: this needs a guard which makes sures, this is affects only ARM and/or iOS

  1. Build Rust:
mkdir build; cd build
../configure --target-triples=arm-apple-darwin
make VERBOSE=1

Fails with

src/libuv/include/uv-errno.h:25:10: fatal error: 'errno.h' file not found
  1. Use Rust:
rustc --target=arm-apple-darwin foo.rs

Possible adjustments

Resources

All Categories:

Clone this wiki locally