diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 97ff7b5119..a027c69e05 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -202,6 +202,8 @@ if (onnxruntime_ENABLE_BITCODE) endif() set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE YES) set(CMAKE_XCODE_ATTRIBUTE_BITCODE_GENERATION_MODE "bitcode") +else() + set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE NO) endif() if (onnxruntime_ENABLE_MEMORY_PROFILE) diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 93061c0d52..fbae322a9a 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -331,6 +331,8 @@ def parse_arguments(): help="Specify the minimum version of the target platform " "(e.g. macOS or iOS)" "This is only supported on MacOS") + parser.add_argument("--apple_disable_bitcode", action='store_true', + help="Disable bitcode for iOS, bitcode is by default enabled for iOS.") # WebAssembly build parser.add_argument("--build_wasm", action='store_true', help="Build for WebAssembly") @@ -879,6 +881,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home "-DCMAKE_OSX_DEPLOYMENT_TARGET=" + args.apple_deploy_target, # we do not need protoc binary for ios cross build "-Dprotobuf_BUILD_PROTOC_BINARIES=OFF", + "-Donnxruntime_ENABLE_BITCODE=" + ("OFF" if args.apple_disable_bitcode else "ON"), "-DCMAKE_TOOLCHAIN_FILE=" + ( args.ios_toolchain_file if args.ios_toolchain_file else "../cmake/onnxruntime_ios.toolchain.cmake")