几乎裸iOS8.4 – >如何获得一个链接器?

编辑2015-29-10。 II。 事实上-arch armv7代替-arch arm64而不降低优化,完美运行。

编辑2015-29-10。 我试图补充

 export CFLAGS="-O1" export CXXFLAGS="-O1" 

configure之前,并且具有相同的错误,这次有一个不同的文件丢失:

  "/usr/local/cctools-arm64-port/bin/ld" -demangle -dynamic -arch arm64 -iphoneos_version_min 5.0.0 -syslibroot /usr/local/iPhoneOS8.4.sdk -o testcpp /var/tmp/testcpp-4f79ac.o -lstdc++ -lSystem ld: file not found: N?L 

我也试过用-O0优化代替-01 ,结果相同。

编辑2015年2月10日。 II。 我做到了这一点:

 ./autogen.sh export CC="clang -arch arm64 -mios-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk" export CXX="clang++ -arch arm64 -mios-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.4.sdk" ./configure -v --host=arm-apple-darwin11 --prefix=/usr/local/lvm-cross/cctools-arm64-port unset CC CXX make && sudo make install 

然后我在iDevice上尝试了一个简单的hello world,其中包含testcpp.cpp:

 #include <iostream> int main() { std::cout << "oijo" << std::endl; return 0; } 

编译

 clang++ -v -isysroot /usr/local/iPhoneOS8.4.sdk -target arm64-apple-darwin11 testcpp.cpp -o testcpp 

这给了我:

 clang version 3.7.0 (tags/RELEASE_370/final) Target: arm64-apple-darwin11 Thread model: posix "/usr/local/llvm-ios/bin/clang++" -cc1 -triple arm64-apple-ios5.0.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name testcpp.cpp -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -target-cpu generic -target-feature +neon -target-abi darwinpcs -target-linker-version 253.3.3 -v -dwarf-column-info -resource-dir /usr/local/llvm-ios/bin/../lib/clang/3.7.0 -isysroot /usr/local/iPhoneOS8.4.sdk -fdeprecated-macro -fdebug-compilation-dir /var/mobile/Documents/CODING/MY/TESTS_0/CPP -ferror-limit 19 -fmessage-length 108 -stack-protector 1 -mstackrealign -fallow-half-arguments-and-returns -fblocks -fobjc-runtime=ios-5.0.0 -fencode-extended-block-signature -fcxx-exceptions -fexceptions -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/tmp/testcpp-f1de66.o -x c++ testcpp.cpp clang -cc1 version 3.7.0 based upon LLVM 3.7.0 default target arm-apple-darwin14.0.0 ignoring nonexistent directory "/usr/local/iPhoneOS8.4.sdk/usr/include/c++/4.2.1/arm64-apple-darwin10/" ignoring nonexistent directory "/usr/local/iPhoneOS8.4.sdk/usr/local/include" ignoring nonexistent directory "/usr/local/iPhoneOS8.4.sdk/Library/Frameworks" #include "..." search starts here: #include <...> search starts here: /usr/local/iPhoneOS8.4.sdk/usr/include/c++/4.2.1 /usr/local/iPhoneOS8.4.sdk/usr/include/c++/4.2.1/backward /usr/local/llvm-ios/bin/../lib/clang/3.7.0/include /usr/local/iPhoneOS8.4.sdk/usr/include /usr/local/iPhoneOS8.4.sdk/System/Library/Frameworks (framework directory) End of search list. "/usr/local/cctools-arm64-port/bin/ld" -demangle -dynamic -arch arm64 -iphoneos_version_min 5.0.0 -syslibroot /usr/local/iPhoneOS8.4.sdk -o testcpp /var/tmp/testcpp-f1de66.o -lstdc++ -lSystem ld: file not found: ?4 clang++: error: linker command failed with exit code 1 (use -v to see invocation) 

我也尝试没有未unset CC CXX ,与同样的“成功”…

编辑2015年2月10日。 一,使用cydia解决schemebuild议确实工作,但我一定要自己build立它,所以我遵循https://github.com/tpoechtrager/cctools-port方式。 因为这是太无聊得到/build立libtool的Mac OS,我切换到一个虚拟框Ubuntu的15.10 64位,我sudo apt-get install '编辑下列软件包: automakeautogenlibtoolclang-3.7uuid-devllvm-3.7-dev 。 然后,我cdcctools目录,然后:

 ./autogen.sh export CC="clang-3.7 -arch arm64" export CXX="clang++-3.7 -arch arm64" ./configure --prefix=/home/lvm-ubuntu/Desktop/iPad/cctools-produced/ --host=arm-apple-darwin11 make 

(完整的输出在新的要点中。 )产生以下警告和错误:

 clang: warning: argument unused during compilation: '-arch arm64' ../include/foreign/libkern/arm/OSByteOrder.h:11:10: error: redefinition of '_OSSwapInt16' uint16_t _OSSwapInt16(uint16_t data) ^ ../include/foreign/libkern/i386/_OSByteOrder.h:46:1: note: previous definition is here _OSSwapInt16( ^ 

_OSSwapInt32_OSSwapInt64模拟错误…我必须确保做错了什么。


最初的问题。

我在一个越狱的iPad mini 3 wifi上成功交叉构build了iOS8.4的clang + llvm,主要得益于以下两个问题:

https://stackoverflow.com/questions/32808144/how-to-cross-compile-clang-llvm-3-7-0-for-ios8-x-on-ipad-mini-3/

https://stackoverflow.com/questions/23946851/how-to-cross-compile-clang-llvm-for-ios/

设置所有path等,并尝试了一个clang++ -v testcpp.cpp -o testcpp其中testcpp.cpp包含:

 int main() { return 0; } 

得到这个:

 clang++: error: unable to execute command: Executable "ld" doesn't exist! clang++: error: linker command failed with exit code 1 (use -v to see invocation) 

(整个详细的输出是在这个要点 。)

很明显,我没有GNU的ld也没有任何真正的“replacement”(通过llvm-clang),所以我在问自己:在这种情况下我的策略是什么? (没有链接器,我甚至不能尝试在iPad上构buildbinutils来使用它的ld )。

精确度 :我想在后台完成链接,这样我就可以继续执行clang++ -v testcpp.cpp -o testcpp ,也就是说,我不想在几个步骤中自己做“手动”链接。 (但是一个脚本也可以,即使我觉得更优雅的做一个真正的ldreplace…)

备注 :在llvm-clang bin文件夹中我有这个:

 XXXXs-iPad:/usr/local/llvm-ios/bin mobile$ ls -l total 274412 -rwxr-xr-x 1 root wheel 205456 Oct 18 12:49 FileCheck* -rwxr-xr-x 1 root wheel 7704096 Oct 18 12:48 bugpoint* -rwxr-xr-x 1 root wheel 122036 Oct 18 12:48 c-index-test* -rwxr-xr-x 1 root wheel 40802004 Oct 18 12:48 clang* -rwxr-xr-x 1 root wheel 40802004 Oct 18 12:49 clang++* -rwxr-xr-x 1 root wheel 31252792 Oct 18 12:49 clang-check* -rwxr-xr-x 1 root wheel 1225352 Oct 18 12:49 clang-format* -rwxr-xr-x 1 root wheel 671500 Oct 18 12:49 clang-tblgen* -rwxr-xr-x 1 root wheel 49684 Oct 18 12:49 count* -rwxr-xr-x 1 root wheel 22439396 Oct 18 12:49 llc* -rwxr-xr-x 1 root wheel 10351388 Oct 18 12:49 lli* -rwxr-xr-x 1 root wheel 208140 Oct 18 12:49 lli-child-target* -rwxr-xr-x 1 root wheel 9144692 Oct 18 12:49 llvm-ar* -rwxr-xr-x 1 root wheel 1619592 Oct 18 12:49 llvm-as* -rwxr-xr-x 1 root wheel 155080 Oct 18 12:49 llvm-bcanalyzer* -rwxr-xr-x 1 root wheel 120864 Oct 18 12:49 llvm-config* -rwxr-xr-x 1 root wheel 92232 Oct 18 12:49 llvm-config-host* -rwxr-xr-x 1 root wheel 1604600 Oct 18 12:49 llvm-cov* -rwxr-xr-x 1 root wheel 1472656 Oct 18 12:49 llvm-cxxdump* -rwxr-xr-x 1 root wheel 1471516 Oct 18 12:49 llvm-diff* -rwxr-xr-x 1 root wheel 1225632 Oct 18 12:49 llvm-dis* -rwxr-xr-x 1 root wheel 18342488 Oct 18 12:49 llvm-dsymutil* -rwxr-xr-x 1 root wheel 419892 Oct 18 12:49 llvm-dwarfdump* -rwxr-xr-x 1 root wheel 1686496 Oct 18 12:49 llvm-extract* -rwxr-xr-x 1 root wheel 1800856 Oct 18 12:49 llvm-link* -rwxr-xr-x 1 root wheel 10140692 Oct 18 12:49 llvm-mc* -rwxr-xr-x 1 root wheel 138552 Oct 18 12:49 llvm-mcmarkup* -rwxr-xr-x 1 root wheel 9144172 Oct 18 12:49 llvm-nm* -rwxr-xr-x 1 root wheel 11554352 Oct 18 12:49 llvm-objdump* -rwxr-xr-x 1 root wheel 220840 Oct 18 12:49 llvm-pdbdump* -rwxr-xr-x 1 root wheel 469920 Oct 18 12:49 llvm-profdata* -rwxr-xr-x 1 root wheel 9144692 Oct 18 12:49 llvm-ranlib* -rwxr-xr-x 1 root wheel 1768528 Oct 18 12:49 llvm-readobj* -rwxr-xr-x 1 root wheel 8388100 Oct 18 12:50 llvm-rtdyld* -rwxr-xr-x 1 root wheel 1489124 Oct 18 12:50 llvm-size* -rwxr-xr-x 1 root wheel 2106052 Oct 18 12:50 llvm-stress* -rwxr-xr-x 1 root wheel 1610176 Oct 18 12:50 llvm-symbolizer* -rwxr-xr-x 1 root wheel 1422732 Oct 18 12:50 llvm-tblgen* -rwxr-xr-x 1 root wheel 1455516 Oct 18 12:50 macho-dump* -rwxr-xr-x 1 root wheel 71184 Oct 18 12:50 not* -rwxr-xr-x 1 root wheel 1620520 Oct 18 12:50 obj2yaml* -rwxr-xr-x 1 root wheel 23007212 Oct 18 12:50 opt* -rwxr-xr-x 1 root wheel 1768416 Oct 18 12:50 verify-uselistorder* -rwxr-xr-x 1 root wheel 402360 Oct 18 12:50 yaml2obj* 

通过Cydia安装org.coolstar.cctoolsorg.coolstar.ld64

或者,也可以手动构buildhttps://github.com/tpoechtrager/cctools-port 。

CXX="clang++ -arch arm64" CC="clang -arch arm64" ./configure --host=arm-apple-darwin11