Almost naked iOS8.4 --> 如何获得链接器?
Almost naked iOS8.4 --> how to get a linker?
编辑 2015-29-10。 II. 事实上 -arch armv7
而不是 -arch arm64
并且在不降低优化的情况下,工作得很好。
编辑 2015-29-10。 I. 我试着加
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-28-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
,使用相同的 "success"...
编辑 2015-28-10。 I. 按照建议使用 cydia 解决方案确实有效,但我肯定想自己构建它,所以我遵循了 https://github.com/tpoechtrager/cctools-port 方式。由于 get/build libtool
对于 mac os 来说太无聊了,我切换到一个 vitual box ubuntu 15.10 64 位,我 sudo apt-get install
编辑了以下包:automake
、autogen
、libtool
、clang-3.7
、uuid-dev
和 llvm-3.7-dev
。然后我 cd
进入 cctools
目录并执行 :
./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
(完整的输出在 new following gist. 中)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 上为 iOS8.4 成功构建了 cross-building clang+llvm,主要归功于以下两个问题:
和
设置所有路径等,并尝试 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)
(整个动词ose输出在这个gist中。)
显然我没有 GNU 的 ld
也没有任何真正的 "remplacement"(通过 llvm-clang),所以我问自己:在这种情况下我的策略是什么? (没有链接器,我什至不能尝试在我的 iPad 上构建 binutils
来使用它的 ld
)。
Precision : 我希望链接在幕后完成,这样我就可以继续做 clang++ -v testcpp.cpp -o testcpp
,也就是说,我不想自己分几步链接 "manually"。 (但是脚本可能没问题,即使我发现有一个真正的 ld
替换更优雅......)
备注:在 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.cctools
和 org.coolstar.ld64
。
或者,手动构建 https://github.com/tpoechtrager/cctools-port。
CXX="clang++ -arch arm64" CC="clang -arch arm64" ./configure --host=arm-apple-darwin11
编辑 2015-29-10。 II. 事实上 -arch armv7
而不是 -arch arm64
并且在不降低优化的情况下,工作得很好。
编辑 2015-29-10。 I. 我试着加
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-28-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
,使用相同的 "success"...
编辑 2015-28-10。 I. 按照建议使用 cydia 解决方案确实有效,但我肯定想自己构建它,所以我遵循了 https://github.com/tpoechtrager/cctools-port 方式。由于 get/build libtool
对于 mac os 来说太无聊了,我切换到一个 vitual box ubuntu 15.10 64 位,我 sudo apt-get install
编辑了以下包:automake
、autogen
、libtool
、clang-3.7
、uuid-dev
和 llvm-3.7-dev
。然后我 cd
进入 cctools
目录并执行 :
./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
(完整的输出在 new following gist. 中)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 上为 iOS8.4 成功构建了 cross-building clang+llvm,主要归功于以下两个问题:
和
设置所有路径等,并尝试 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)
(整个动词ose输出在这个gist中。)
显然我没有 GNU 的 ld
也没有任何真正的 "remplacement"(通过 llvm-clang),所以我问自己:在这种情况下我的策略是什么? (没有链接器,我什至不能尝试在我的 iPad 上构建 binutils
来使用它的 ld
)。
Precision : 我希望链接在幕后完成,这样我就可以继续做 clang++ -v testcpp.cpp -o testcpp
,也就是说,我不想自己分几步链接 "manually"。 (但是脚本可能没问题,即使我发现有一个真正的 ld
替换更优雅......)
备注:在 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.cctools
和 org.coolstar.ld64
。
或者,手动构建 https://github.com/tpoechtrager/cctools-port。
CXX="clang++ -arch arm64" CC="clang -arch arm64" ./configure --host=arm-apple-darwin11