Search code examples
iosgcccompilationopensslcompiler-flags

how to compile openssl with fvisibility=hidden flag for iOS


I need to compile the openssl code with -fvisibility=hidden to hide the large number of symbols and then use in Xcode. Using below GitHub link.. I'm able get the libssl.a and libcrypto.a but there is no option I can see the build-libssl.sh (shell script) to add option "-fvisibility=hidden".

https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh

I did try adding "-fvisibility=hidden" in "Other C Flags" in Build Settings in Xcode but does not seem to work. Hence please suggest for this issue.


Solution

  • as per the GitHub link mentioned, go to scripts folder -> build-loop-archs.sh and then edit this file "build-loop-archs.sh" and replace the "-fembed-bitcode" with "-fvisibility=hidden" and then save it and run the script. It will work.

    Embed bitcode for SDK >= 9

     if [ "${CONFIG_DISABLE_BITCODE}" != "true" ]; then
        if [[ "${SDKVERSION}" == 9.* || "${SDKVERSION}" == [0-9][0-9].* ]]; then
          LOCAL_CONFIG_OPTIONS="${LOCAL_CONFIG_OPTIONS} -fvisibility=hidden"
        fi
      fi
    

    https://github.com/x2on/OpenSSL-for-iPhone/blob/master/build-libssl.sh