Trying to compile LLVM/Clang for iOS iPhoneSimulator gives errors

Thank you Jacob for your answer. It is quite helpful.
Sorry for not responding sooner - I wasn’t getting messages from llvm-dev for awhile for some reason and had to re-subscribe from a different e-mail address.

So I followed the link at the bottom of your response and I am now using the following command to cross-compile for iOS:


And with that I was able to compile some 61% of LLVM.
Now I am stuck here:

[ 61%] Built target yaml-bench
[ 61%] Built target LTO_exports
[ 61%] Linking CXX shared library …/…/lib/libLTO.dylib
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libLTO.dylib] Error 1
make[1]: *** [tools/lto/CMakeFiles/LTO.dir/all] Error 2
make: *** [all] Error 2

I am now going through the CMake scripts trying to figure out where that option is set and how to remove it.
Honestly, I am not even sure what that options means. I tried ignoring libLTO target but it had snowballing effect as that target is referenced in a number of other places it seems.

As for your remark about not being able to invoke the “fork” system call: my hope was to interpret C++ code on the target platform - the way lli tool does or JIT-compiling it when possible.
I am not sure about that, though - so wanted to give that a try to see how that goes.