Linux for iOS上的交叉编译

时间:2016-05-28 20:05:48

标签: ios linux gcc llvm

我正在尝试交叉编译Ruby for iOS设备。我有一个相当冗长的脚本,下载Ruby的最新源代码,解压缩并编译它。

脚本如下:

#!/bin/bash
rm -rf ~/built/ruby
AR=~/toolchain/armv7-apple-darwin11-ar
AS=~/toolchain/armv7-apple-darwin11-as
CC=~/toolchain/armv7-apple-darwin11-clang
CXX=~/toolchain/armv7-apple-darwin11-clang++
LD=~/toolchain/armv7-apple-darwin11-ld
NM=~/toolchain/armv7-apple-darwin11-nm
OBJDUMP=~/toolchain/armv7-apple-darwin11-objdump
RANLIB=~/toolchain/armv7-apple-darwin11-ranlib
STRIP=~/toolchain/armv7-apple-darwin11-strip
SDK=/home/citrusui/sdks/iPhoneOS9.3.sdk
CFLAGS="-arch armv7 -arch arm64 -isysroot $SDK"
LDFLAGS="-Wl,-segalign,4000"
DESTDIR=~/built/ruby/var/stash 
apt install autoconf bison clang jq xutils-dev
curl https://api.github.com/repos/ruby/ruby/tags -o ruby.json
URL=`jq -r 'map(select(.name != "yarv_migration_base"))[0].tarball_url' ruby.json`
TAG=`jq -r 'map(select(.name != "yarv_migration_base"))[0].name' ruby.json`
echo "Downloading from $URL"...
if [ -f ruby_$TAG.tar.gz ] && [ -d ruby-ruby* ]; then
echo "Already downloaded."
cd ruby-ruby*
autoconf
./configure --host=armv7-apple-darwin11 -target=armv7-apple-darwin11 CC="$CC" CXX="$CXX" CXXFLAGS="$CFLAGS" CFLAGS="$CFLAGS" STRIP=$STRIP RANLIB=$RANLIB NM=$NM AR=$AR AS=$AS LD=$LD OBJDUMP=$OBJDUMP LDFLAGS="$LDFLAGS" DESTDIR="$DESTDIR" 
make install -j4
cd ~/built/ruby
lndir var/stash
exit 0
fi
curl -L $URL -o ruby_$TAG.tar.gz
tar -xvzf ruby_$TAG.tar.gz
cd ruby-ruby*
autoconf
./configure --host=armv7-apple-darwin11 -target=armv7-apple-darwin11 CC="$CC" CXX="$CXX" CXXFLAGS="$CFLAGS" CFLAGS="$CFLAGS" STRIP=$STRIP RANLIB=$RANLIB NM=$NM AR=$AR AS=$AS LD=$LD OBJDUMP=$OBJDUMP LDFLAGS="$LDFLAGS" DESTDIR="$DESTDIR" 
make install -j4
cd ~/built/ruby
lndir var/stash

现在,我还从Xcode下载了iOS 9.3 SDK并将其放入我的〜/ sdks /文件夹中。但是,编译过程仍然会生成ELF格式的二进制文件。

我还有一个从here下载的工具链(在〜/ toolchain /中)。我假设这将允许LLVM / Clang生成arm(64)二进制文件,但我不知道如何告诉clang处理这个工具链。在./configure中指定$ TOOLCHAIN也无济于事。

0 个答案:

没有答案