From 9358451d34bab3e93234e5ab22f0bb78374655ce Mon Sep 17 00:00:00 2001 From: Dalmo Cirne Date: Fri, 14 Jul 2017 20:34:37 -0400 Subject: [PATCH] Enable bitcode compilation (#11198) In order to enable bitcode compilation it is necessary more than adding `-fembed-bitcode`. The `MACOSX_DEPLOYMENT_TARGET` variable must be defined and exported as well. In this commit the variable is defined grabbing the version of the underlying running macOS. --- tensorflow/contrib/makefile/build_all_ios.sh | 9 +++++---- tensorflow/contrib/makefile/compile_ios_protobuf.sh | 5 ++++- tensorflow/contrib/makefile/compile_ios_tensorflow.sh | 6 +++++- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/tensorflow/contrib/makefile/build_all_ios.sh b/tensorflow/contrib/makefile/build_all_ios.sh index 344bf49dcf0..a0f56528548 100755 --- a/tensorflow/contrib/makefile/build_all_ios.sh +++ b/tensorflow/contrib/makefile/build_all_ios.sh @@ -18,7 +18,7 @@ set -e # Make sure we're on OS X. if [[ $(uname) != "Darwin" ]]; then - echo "ERROR: This makefile build requires OS X, which the current system "\ + echo "ERROR: This makefile build requires macOS, which the current system "\ "is not." exit 1 fi @@ -37,7 +37,9 @@ rm -rf tensorflow/contrib/makefile/downloads # # ld: -bind_at_load and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together # -export MACOSX_DEPLOYMENT_TARGET="10.10" +if [[ -n MACOSX_DEPLOYMENT_TARGET ]]; then + export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) +fi # Pull down the required versions of the frameworks we need. tensorflow/contrib/makefile/download_dependencies.sh @@ -48,6 +50,5 @@ tensorflow/contrib/makefile/compile_ios_protobuf.sh # Build the iOS TensorFlow libraries. tensorflow/contrib/makefile/compile_ios_tensorflow.sh "-O3" -# Creates a static universal library in +# Creates a static universal library in # tensorflow/contrib/makefile/gen/lib/libtensorflow-core.a - diff --git a/tensorflow/contrib/makefile/compile_ios_protobuf.sh b/tensorflow/contrib/makefile/compile_ios_protobuf.sh index e8b9454e7e6..4056db18a76 100755 --- a/tensorflow/contrib/makefile/compile_ios_protobuf.sh +++ b/tensorflow/contrib/makefile/compile_ios_protobuf.sh @@ -15,9 +15,12 @@ # ============================================================================== # Builds protobuf 3 for iOS. -set -x set -e +if [[ -n MACOSX_DEPLOYMENT_TARGET ]]; then + export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) +fi + SCRIPT_DIR=$(dirname $0) source "${SCRIPT_DIR}/build_helper.subr" diff --git a/tensorflow/contrib/makefile/compile_ios_tensorflow.sh b/tensorflow/contrib/makefile/compile_ios_tensorflow.sh index bcf097b3031..5d1cc8b375b 100755 --- a/tensorflow/contrib/makefile/compile_ios_tensorflow.sh +++ b/tensorflow/contrib/makefile/compile_ios_tensorflow.sh @@ -31,6 +31,10 @@ function less_than_required_version() { ) } +if [[ -n MACOSX_DEPLOYMENT_TARGET ]]; then + export MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) +fi + ACTUAL_XCODE_VERSION=$(xcodebuild -version | head -n 1 | sed 's/Xcode //') REQUIRED_XCODE_VERSION=7.3.0 if less_than_required_version $ACTUAL_XCODE_VERSION 7 3 0 @@ -44,7 +48,7 @@ LIBDIR=${GENDIR}lib LIB_PREFIX=libtensorflow-core make -j"${JOB_COUNT}" -f tensorflow/contrib/makefile/Makefile \ -TARGET=IOS IOS_ARCH=ARMV7 LIB_NAME=${LIB_PREFIX}-armv7.a OPTFLAGS="$1" +TARGET=IOS IOS_ARCH=ARMV7 LIB_NAME=${LIB_PREFIX}-armv7.a OPTFLAGS="$1" if [ $? -ne 0 ] then echo "armv7 compilation failed."