Igor Gomon via llvm-dev
2020-Mar-30 21:37 UTC
[llvm-dev] Trying to compile LLVM/Clang for iOS iPhoneSimulator gives errors
Hello, I am trying to compile LLVM/Clang(10.0) for iOS Simulator (SDK 13.4) and to do that I have made the following changes to the codebase: 1) I added the following line to CMakeLists.txt under llvm-project/clang: set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk -miphoneos-version-min=13.4") 2) I set CMAKE_OSX_SYSROOT to: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk. Then recompiling the code gives me errors like below: [ 21%] Building AttributesCompatFunc.inc... dyld: attempt to run simulator program outside simulator (DYLD_ROOT_PATH not set) dyld: attempt to run simulator program outside simulator (DYLD_ROOT_PATH not set) dyld: attempt to run simulator program outside simulator (DYLD_ROOT_PATH not set) /bin/sh: line 1: 24864 Abort trap: 6 ../../bin/llvm-tblgen -gen-attrs -I /Users/igorgomon/dev/third-party/llvm-project/llvm/lib/IR -I /Users/igorgomon/dev/third-party/llvm-project/llvm/include /Users/igorgomon/dev/third-party/llvm-project/llvm/lib/IR/AttributesCompatFunc.td --write-if-changed -o /Users/igorgomon/dev/third-party/llvm-project/llvm/cmake-build-debug/lib/IR/AttributesCompatFunc.inc /bin/sh: line 1: 24863 Abort trap: 6 ../../../../../bin/llvm-tblgen -gen-opt-parser-defs -I /Users/igorgomon/dev/third-party/llvm-project/clang/include/clang/Driver -I /Users/igorgomon/dev/third-party/llvm-project/llvm/include /Users/igorgomon/dev/third-party/llvm-project/clang/include/clang/Driver/Options.td --write-if-changed -o /Users/igorgomon/dev/third-party/llvm-project/llvm/cmake-build-debug/tools/clang/include/clang/Driver/Options.inc /bin/sh: line 1: 24862 Abort trap: 6 ../../../bin/llvm-tblgen -gen-searchable-tables -I /Users/igorgomon/dev/third-party/llvm-project/llvm/lib/Transforms/InstCombine -I /Users/igorgomon/dev/third-party/llvm-project/llvm/include /Users/igorgomon/dev/third-party/llvm-project/llvm/lib/Transforms/InstCombine/InstCombineTables.td --write-if-changed -o /Users/igorgomon/dev/third-party/llvm-project/llvm/cmake-build-debug/lib/Transforms/InstCombine/InstCombineTables.inc make[3]: *** [lib/IR/AttributesCompatFunc.inc] Error 134 make[3]: *** [tools/clang/include/clang/Driver/Options.inc] Error 134 make[3]: *** [lib/Transforms/InstCombine/InstCombineTables.inc] Error 134 make[2]: *** [lib/IR/CMakeFiles/AttributeCompatFuncTableGen.dir/all] Error 2 [ 21%] Building IntrinsicsAMDGPU.h... dyld: attempt to run simulator program outside simulator (DYLD_ROOT_PATH not set) /bin/sh: line 1: 24873 Abort trap: 6 ../../../bin/llvm-tblgen -gen-intrinsic-impl -I /Users/igorgomon/dev/third-party/llvm-project/llvm/include/llvm/IR -I /Users/igorgomon/dev/third-party/llvm-project/llvm/include /Users/igorgomon/dev/third-party/llvm-project/llvm/include/llvm/IR/Intrinsics.td --write-if-changed -o /Users/igorgomon/dev/third-party/llvm-project/llvm/cmake-build-debug/include/llvm/IR/IntrinsicImpl.inc make[3]: *** [include/llvm/IR/IntrinsicImpl.inc] Error 134 make[3]: *** Waiting for unfinished jobs.... Could someone explain what those errors mean and how to resolve them? I did set DYLD_ROOT_PATH to the location of the Simulator executable but that didn't help. Also if there is any guide on how to compile LLVM/Clang for iOS simulator I would greatly appreciate if anyone shared it with me. Any help is greatly appreciated. -- Thanks, Igor -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200330/ef0fd9a6/attachment-0001.html>
Jacob Carlborg via llvm-dev
2020-Mar-31 12:03 UTC
[llvm-dev] Trying to compile LLVM/Clang for iOS iPhoneSimulator gives errors
On 2020-03-30 23:37, Igor Gomon via llvm-dev wrote:> I am trying to compile LLVM/Clang(10.0) for iOS Simulator (SDK 13.4)The way code is compiled for iOS (simulator or native device) is to cross-compile it. As far as I know, it's not possible to run a compiler on the simulator or device. You're not allowed to invoke the "fork" system call, that means you cannot create a new process. That means, if you do have a compiler for iOS, there's no way to run it. BTW, the proper way to cross-compile for iOS using cmake is to set the following cmake variables: CMAKE_SYSTEM_NAME=iOS CMAKE_OSX_ARCHITECTURES=arm64 # architecture CMAKE_OSX_DEPLOYMENT_TARGET=12.0 # minimum deployment target The above are examples for targeting the native device. Not sure of the exact values for the simulator. For more information, see: https://cmake.org/cmake/help/v3.14/manual/cmake-toolchains.7.html#cross-compiling-for-ios-tvos-or-watchos -- /Jacob Carlborg