clementfarabet / torch-ios

Torch7 for iOS.
Other
196 stars 42 forks source link

BitCode Support #21

Open loretoparisi opened 8 years ago

loretoparisi commented 8 years ago

Getting this XCode error when compiling the example ios app

ld: '/Volumes/MacHDD2/Developmemt/AI/torch-ios/Torch.framework/Torch(THStorage.c.o)' does not contain bitcode. You must rebuild it with bitcode enabled (Xcode setting ENABLE_BITCODE), obtain an updated library from the vendor, or disable bitcode for this target. for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The Torch.framework should be compiled using the C compiler flag -fembed-bitcode in order to enable bitcode.

kurtjacobsdev commented 8 years ago

@loretoparisi Added support for BitCode, will push to the repo. Thanks for the heads up.

loretoparisi commented 8 years ago

Great, thank you :+1: To double check you can then run

$otool -l Mylib.framework/Versions/Current/Mylib | grep __LLVM

and if you see LLVM segments like

segname __LLVM
segname __LLVM
segname __LLVM

then we have the bitcode done!

sagarwaghmare69 commented 8 years ago

Hi Guys, I get following error while compile. clang: error: unknown argument: '-fembed-bitcode' If I remove -fembed-bitcode option from EXTRA_FLAGS in generate_ios_framework it compiles fine. Here is the full log

./generate_ios_framework 
generating torch
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/usr/bin/xcrun
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/usr/bin/xcrun -- broken
CMake Error at /usr/local/Cellar/cmake/3.1.3/share/cmake/Modules/CMakeTestCCompiler.cmake:61 (message):
  The C compiler "/Applications/Xcode.app/Contents/Developer/usr/bin/xcrun"
  is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: /Users/ElementInc/repositories/torch-ios/build/CMakeFiles/CMakeTmp

  Run Build Command:"/Applications/Xcode.app/Contents/Developer/usr/bin/make"
  "cmTryCompileExec3243808459/fast"

  /Applications/Xcode.app/Contents/Developer/usr/bin/make -f
  CMakeFiles/cmTryCompileExec3243808459.dir/build.make
  CMakeFiles/cmTryCompileExec3243808459.dir/build

  /usr/local/Cellar/cmake/3.1.3/bin/cmake -E cmake_progress_report
  /Users/ElementInc/repositories/torch-ios/build/CMakeFiles/CMakeTmp/CMakeFiles
  1

  Building C object
  CMakeFiles/cmTryCompileExec3243808459.dir/testCCompiler.c.o

  /Applications/Xcode.app/Contents/Developer/usr/bin/xcrun --sdk iphoneos
  clang -arch armv7 -miphoneos-version-min=6.0 -fembed-bitcode -D__NEON__
  -mfpu=neon -o CMakeFiles/cmTryCompileExec3243808459.dir/testCCompiler.c.o
  -c
  /Users/ElementInc/repositories/torch-ios/build/CMakeFiles/CMakeTmp/testCCompiler.c

  clang: error: unknown argument: '-fembed-bitcode'

  make[1]: *** [CMakeFiles/cmTryCompileExec3243808459.dir/testCCompiler.c.o]
  Error 1

  make: *** [cmTryCompileExec3243808459/fast] Error 2
loretoparisi commented 8 years ago

@sagarwaghmare69 if you run

$ cd /Applications/Xcode/Xcode.app/Contents/Developer/usr/bin/
$ ./xcodebuild -version 

which version you get?