New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable bitcode for OpenSSL dynamic framework #222

Closed
vixentael opened this Issue Aug 31, 2017 · 4 comments

Comments

Projects
None yet
1 participant
@vixentael
Member

vixentael commented Aug 31, 2017

...because bitcode is our future!

See discussion #219

https://github.com/levigroker/GRKOpenSSLFramework doesn't have enabled bitcode, Themis uses it as dependency.

Goal: find best option to re-build frameworks with bitcode

@vixentael vixentael added the ios label Aug 31, 2017

@vixentael vixentael self-assigned this Aug 31, 2017

@vixentael vixentael added this to the 0.9.5 milestone Aug 31, 2017

@vixentael

This comment has been minimized.

Member

vixentael commented Aug 31, 2017

checking pre-built openssl.framework from https://github.com/levigroker/GRKOpenSSLFramework shows no bitcode

(check for each architecture)

$ (otool -arch arm64 -l openssl.framework/openssl | grep LLVM) || echo "no bitcode"
no bitcode

$ (otool -arch armv7 -l openssl.framework/openssl | grep LLVM) || echo "no bitcode"
no bitcode

$ (otool -arch armv7s -l openssl.framework/openssl | grep LLVM) || echo "no bitcode"
no bitcode
@vixentael

This comment has been minimized.

Member

vixentael commented Aug 31, 2017

Okay, now I know a lot about bitcode.

Usually, xcode can generate dynamic frameworks with bitcode only using ARCHIVE action instead of BUILD action.

However, these resources show that we can changed xcode settings to make it generate bitcode during BUILD action as well.


I was able to generate openssl.framework with bitcode support. This is still work in progress, but sharing my steps now:

Current version of script
https://gist.github.com/vixentael/6bc6099e932ccec1a5e911c8e6694735

What I've changed in xcode project and script:

  • script unset TOOLCHAINS. Is it really needed?
    https://stackoverflow.com/a/36248115/2238082

  • script. If both options are needed?
    OTHER_CFLAGS="-fembed-bitcode" BITCODE_GENERATION_MODE=bitcode

  • xcodeproj: if ENABLE BITCODE=YES is needed

  • xcodeproj: if these user defined things are needed

screen shot 2017-08-31 at 4 29 29 pm

  • building log

screen shot 2017-08-31 at 4 29 16 pm

@vixentael

This comment has been minimized.

Member

vixentael commented Aug 31, 2017

How to check that framework contains bitcode:

  1. Check existing architecture
lipo -info openssl.framework/openssl 

Expected output:

Architectures in the fat file: openssl.framework/openssl are: i386 x86_64 armv7 armv7s arm64 
  1. Check architectures one by one
$ (otool -arch arm64 -l openssl.framework/openssl | grep LLVM) || echo "no bitcode"
  segname __LLVM
   segname __LLVM

screen shot 2017-08-31 at 4 38 28 pm

@vixentael

This comment has been minimized.

Member

vixentael commented Sep 1, 2017

Next steps:

  • check all these options one by one to minimize settings needed to build frameworks with bitcode
  • create PR in https://github.com/levigroker/GRKOpenSSLFramework
  • create local pod spec repository, pushed updated podspec GRKOpenSSLFramework there and make sure that ThemisTest project is running on device with enabled bitcode
  • update dependency in podspec, link Themis to new pod
  • remove disabling bitcode in Themis podspec
  • merge changes to branch_0.9.5
  • enjoy

List of final changes in script and xcode project is described here --> levigroker/GRKOpenSSLFramework#3

Script and xcode project were changed to contain these settings:

  • BITCODE_GENERATION_MODE=bitcode
  • ENABLE BITCODE=YES
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment