EDIT 2015-29-10. II. In fact -arch armv7
instead of -arch arm64
and without lowering optimization, worked perfectly.
EDIT 2015-29-10. I. I tried to add
export CFLAGS="-O1"
export CXXFLAGS="-O1"
before configure
, and had the same error, with a different file missing this time :
"/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
I also tried with -O0
optimization instead of -01
, same result.
EDIT 2015-28-10. II. I did this :
./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
Then I tried a simple hello world on iDevice, with testcpp.cpp containing :
#include <iostream>
int main()
{
std::cout << "oijo" << std::endl;
return 0;
}
compiled with
clang++ -v -isysroot /usr/local/iPhoneOS8.4.sdk -target arm64-apple-darwin11 testcpp.cpp -o testcpp
which gave me :
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)
I also tried without the unset CC CXX
, with the same "success"...
EDIT 2015-28-10. I. Using cydia solutions as suggested indeed worked, but I definitely want to build it myself, so I followed the https://github.com/tpoechtrager/cctools-port way. As it is way too boring to get/build libtool
for mac os, I switched to a vitual box ubuntu 15.10 64 bits, where I sudo apt-get install
'ed the following packages : automake
, autogen
, libtool
, clang-3.7
, uuid-dev
and llvm-3.7-dev
. Then I cd
'ed to the cctools
directory and did :
./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
(The complete output is in the new following gist.) make
produced the following warnings and errors :
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(
^
and analogue errors for _OSSwapInt32
and _OSSwapInt64
... I must be for sure doing something wrong.
Initial question.
I succeed in cross-building clang+llvm for iOS8.4 on a jailbroken iPad mini 3 wifi, mainly thanks to the two following questions :
https://stackoverflow.com/questions/32808144/how-to-cross-compile-clang-llvm-3-7-0-for-ios8-x-on-ipad-mini-3/
and
https://stackoverflow.com/questions/23946851/how-to-cross-compile-clang-llvm-for-ios/
Set all paths etc, and tried a clang++ -v testcpp.cpp -o testcpp
where testcpp.cpp
contains :
int main()
{
return 0;
}
and got this :
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)
(the whole verbose output is in this gist.)
Obviously I don't have GNU's ld
nor any real "remplacement" of it (by llvm-clang), so that I am asking myself : what is my strategy in this case ? (Having no linker, I can't even try to build binutils
on my iPad to use its ld
).
Precision : I would like the linking to be done behind the scene, so that I could keep doing clang++ -v testcpp.cpp -o testcpp
, that is, I don't want to do the linking "manually" myself in several steps. (But a script could be ok, even if I find more elegant to have a real ld
replacement...)
Remark : in llvm-clang bin
folder I have this :
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*