Skip to content

Commit

Permalink
chore: upgrade tensorflow-cc portfile (#24861)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyYin committed Sep 22, 2022
1 parent 72fa4d4 commit 81c45c2
Show file tree
Hide file tree
Showing 13 changed files with 170 additions and 30 deletions.
12 changes: 8 additions & 4 deletions ports/tensorflow-cc/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "tensorflow-cc",
"version-semver": "2.7.0",
"port-version": 2,
"version-semver": "2.10.0",
"description": "Library for computation using data flow graphs for scalable machine learning (C++ API version)",
"homepage": "https://github.com/tensorflow/tensorflow",
"supports": "!(x86 | arm | uwp)",
"license": "Apache-2.0",
"supports": "!(x86 | arm | uwp) | (arm64 & osx)",
"dependencies": [
"tensorflow-common"
"tensorflow-common",
{
"name": "vcpkg-tool-bazel",
"host": true
}
]
}
2 changes: 1 addition & 1 deletion ports/tensorflow-common/fix-build-error.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
diff --git a/tensorflow/core/platform/default/logging.h b/tensorflow/core/platform/default/logging.h
--- a/tensorflow/core/platform/default/logging.h
+++ b/tensorflow/core/platform/default/logging.h
@@ -104,13 +104,13 @@ class LogMessageFatal : public LogMessage {
@@ -104,13 +104,13 @@ class LogMessageNull : public std::basic_ostringstream<char> {
};

#define _TF_LOG_INFO \
Expand Down
2 changes: 1 addition & 1 deletion ports/tensorflow-common/generate_static_link_cmd_linux.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
with open(sys.argv[1], "r") as f_in:
with open("static_link.sh", "w") as f_out:
p_cd = re.compile(r"^\((cd .*) && \\$")
p_linker = re.compile(fr"^\s*(.+)gcc.+(@bazel-out\S+libtensorflow{lib_suffix}\.so\.\d\.\d\.\d-2\.params).*")
p_linker = re.compile(fr"^\s*(.+)gcc.+(@bazel-out\S+libtensorflow{lib_suffix}\.so\.\d+\.\d+\.\d+-2\.params).*")
f_out.write("#!/bin/bash\n# note: ar/binutils version 2.27 required to support output files > 4GB\n")
env = []
for line in f_in:
Expand Down
54 changes: 43 additions & 11 deletions ports/tensorflow-common/tensorflow-common.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
set(TF_VERSION 2.7.0)
set(TF_VERSION_SHORT 2.7)
set(TF_VERSION 2.10.0)
set(TF_VERSION_SHORT 2.10)

vcpkg_find_acquire_program(BAZEL)
find_program(BAZEL bazel PATHS "${CURRENT_HOST_INSTALLED_DIR}/tools" REQUIRED)
get_filename_component(BAZEL_DIR "${BAZEL}" DIRECTORY)
vcpkg_add_to_path(PREPEND ${BAZEL_DIR})
set(ENV{BAZEL_BIN_PATH} "${BAZEL}")
vcpkg_add_to_path(PREPEND "${BAZEL_DIR}")
set(ENV{BAZEL_BIN_PATH} "${BAZEL_DIR}")

function(tensorflow_try_remove_recurse_wait PATH_TO_REMOVE)
file(REMOVE_RECURSE ${PATH_TO_REMOVE})
Expand Down Expand Up @@ -43,6 +43,19 @@ if(CMAKE_HOST_WIN32)
else()
vcpkg_find_acquire_program(PYTHON3)

# on macos arm64 use conda miniforge
if (VCPKG_HOST_IS_OSX)
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE HOST_ARCH)
if(HOST_ARCH STREQUAL "arm64")
message(STATUS "Using python from miniforge3 ")

if (NOT EXISTS ${CURRENT_BUILDTREES_DIR}/miniforge3)
vcpkg_execute_required_process(COMMAND curl -fsSLo Miniforge3.sh "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-MacOSX-arm64.sh" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequisites-miniforge3-${TARGET_TRIPLET})
vcpkg_execute_required_process(COMMAND bash ./Miniforge3.sh -p ${CURRENT_BUILDTREES_DIR}/miniforge3 -b WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequisites-miniforge3-${TARGET_TRIPLET})
SET(PYTHON3 ${CURRENT_BUILDTREES_DIR}/miniforge3/bin/python3)
endif()
endif()
endif()
vcpkg_execute_required_process(COMMAND ${PYTHON3} -m venv --symlinks "${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-venv" WORKING_DIRECTORY ${CURRENT_BUILDTREES_DIR} LOGNAME prerequisites-venv-${TARGET_TRIPLET})
vcpkg_add_to_path(PREPEND ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-venv/bin)
set(PYTHON3 ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-venv/bin/python3)
Expand Down Expand Up @@ -88,9 +101,15 @@ set(ENV{TF_SET_ANDROID_WORKSPACE} 0)
set(ENV{TF_DOWNLOAD_CLANG} 0)
set(ENV{TF_NCCL_VERSION} ${TF_VERSION_SHORT})
set(ENV{NCCL_INSTALL_PATH} "")
set(ENV{CC_OPT_FLAGS} "/arch:AVX")
set(ENV{TF_NEED_CUDA} 0)
set(ENV{TF_CONFIGURE_IOS} 0)
set(ENV{CC_OPT_FLAGS} "-Wno-sign-compare")

if(VCPKG_TARGET_IS_WINDOWS)
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86" OR VCPKG_TARGET_ARCHITECTURE STREQUAL "x64" )
set(ENV{CC_OPT_FLAGS} "/arch:AVX")
endif()
endif()

if(VCPKG_TARGET_IS_WINDOWS)
set(BAZEL_LIB_NAME tensorflow${TF_LIB_SUFFIX}.dll)
Expand Down Expand Up @@ -152,7 +171,7 @@ foreach(BUILD_TYPE IN LISTS PORT_BUILD_CONFIGS)
OUT_SOURCE_PATH SOURCE_PATH
REPO tensorflow/tensorflow
REF "v${TF_VERSION}"
SHA512 f1e892583c7b3a73d4d39ec65dc135a5b02c789b357d57414ad2b6d05ad9fbfc8ef81918ba6410e314abd6928b76f764e6ef64c0b0c84b58b50796634be03f39
SHA512 bf8a6f16393499c227fc70f27bcfb6d44ada53325aee2b217599309940f60db8ee00dd90e3d82b87d9c309f5621c404edab55e97ab8bfa09e4fc67859b9e3967
HEAD_REF master
PATCHES
"${CMAKE_CURRENT_LIST_DIR}/fix-build-error.patch" # Fix namespace error
Expand Down Expand Up @@ -191,18 +210,24 @@ foreach(BUILD_TYPE IN LISTS PORT_BUILD_CONFIGS)
set(COPTS)
set(CXXOPTS)
set(LINKOPTS)
set(BUILD_OPTS --jobs ${VCPKG_CONCURRENCY})
message(STATUS "Build Tensorflow with concurrent level: ${VCPKG_CONCURRENCY}")
if(VCPKG_TARGET_IS_WINDOWS)
set(PLATFORM_COMMAND WINDOWS_COMMAND)
else()
set(PLATFORM_COMMAND UNIX_COMMAND)
endif()
if(BUILD_TYPE STREQUAL dbg)
if(VCPKG_TARGET_IS_WINDOWS)
set(BUILD_OPTS "--compilation_mode=dbg --features=fastbuild") # link with /DEBUG:FASTLINK instead of /DEBUG:FULL to avoid .pdb >4GB error
list(APPEND BUILD_OPTS "--compilation_mode=dbg --features=fastbuild") # link with /DEBUG:FASTLINK instead of /DEBUG:FULL to avoid .pdb >4GB error
elseif(VCPKG_TARGET_IS_OSX)
set(BUILD_OPTS --compilation_mode=fastbuild) # debug build on macOS currently broken
if (VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
list(APPEND BUILD_OPTS --compilation_mode=opt) # debug & fastbuild build on macOS arm64 currently broken
else()
list(APPEND BUILD_OPTS --compilation_mode=fastbuild) # debug build on macOS x86_64 currently broken
endif()
else()
set(BUILD_OPTS --compilation_mode=dbg)
list(APPEND BUILD_OPTS --compilation_mode=dbg)
endif()

separate_arguments(VCPKG_C_FLAGS ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS})
Expand All @@ -221,7 +246,7 @@ foreach(BUILD_TYPE IN LISTS PORT_BUILD_CONFIGS)
list(APPEND LINKOPTS "--linkopt=${OPT}")
endforeach()
else()
set(BUILD_OPTS --compilation_mode=opt)
list(APPEND BUILD_OPTS --compilation_mode=opt)

separate_arguments(VCPKG_C_FLAGS ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS})
separate_arguments(VCPKG_C_FLAGS_RELEASE ${PLATFORM_COMMAND} ${VCPKG_C_FLAGS_RELEASE})
Expand All @@ -240,6 +265,13 @@ foreach(BUILD_TYPE IN LISTS PORT_BUILD_CONFIGS)
endforeach()
endif()

if(VCPKG_TARGET_IS_OSX AND VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
# tensorflow supports 10.12.6 (Sierra) or higher (64-bit)
# but actually does not compile with < 10.14
# https://www.tensorflow.org/install/pip#macos
list(APPEND BUILD_OPTS --macos_minimum_os=10.14)
endif()

if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
if(VCPKG_TARGET_IS_WINDOWS)
list(JOIN COPTS " " COPTS)
Expand Down
6 changes: 3 additions & 3 deletions ports/tensorflow-common/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tensorflow-common",
"version-semver": "2.7.0",
"port-version": 2,
"version-semver": "2.10.0",
"description": "This meta package holds common files for the C [tensorflow] and the C++ [tensorflow-cc] API version of TensorFlow but is not installable on its own.",
"homepage": "https://github.com/tensorflow/tensorflow"
"homepage": "https://github.com/tensorflow/tensorflow",
"license": "Apache-2.0"
}
12 changes: 8 additions & 4 deletions ports/tensorflow/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
{
"name": "tensorflow",
"version-semver": "2.7.0",
"port-version": 2,
"version-semver": "2.10.0",
"description": "Library for computation using data flow graphs for scalable machine learning (C API version)",
"homepage": "https://github.com/tensorflow/tensorflow",
"supports": "!(x86 | arm | uwp)",
"license": "Apache-2.0",
"supports": "!(x86 | arm | uwp) | (arm64 & osx)",
"dependencies": [
"tensorflow-common"
"tensorflow-common",
{
"name": "vcpkg-tool-bazel",
"host": true
}
]
}
64 changes: 64 additions & 0 deletions ports/vcpkg-tool-bazel/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)

set(program bazel)
set(program_version 5.2.0)

if(VCPKG_CROSSCOMPILING)
message(FATAL_ERROR "This is a host only port!")
endif()

if(VCPKG_TARGET_IS_LINUX)
set(tool_subdirectory "${program_version}-linux")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(download_urls "https://github.com/bazelbuild/bazel/releases/download/${program_version}/bazel-${tool_subdirectory}-arm64")
set(download_filename "bazel-${tool_subdirectory}-arm64")
set(raw_executable ON)
set(download_sha512 11e953717f0edd599053a9c6ab849c266f6b34cd6f39dd99301a138aeb9d10113d055f7a2452f6ae601a9e9c19c816d22732958bb147e493dae9c63b13e0f1e0)
else()
set(download_urls "https://github.com/bazelbuild/bazel/releases/download/${program_version}/bazel-${tool_subdirectory}-x86_64")
set(download_filename "bazel-${tool_subdirectory}-x86_64")
set(raw_executable ON)
set(download_sha512 c9f117414f31bc85a1f6a91f3d1c0a4884a4bb346bb60b00599c2da8225d085f67bc865f1429c897681cb99471767171aed148c77ce80d9525841c873d9cc912)
endif()
elseif(VCPKG_TARGET_IS_OSX)
set(tool_subdirectory "${program_version}-darwin")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(download_urls "https://github.com/bazelbuild/bazel/releases/download/${program_version}/bazel-${tool_subdirectory}-arm64")
set(download_filename "bazel-${tool_subdirectory}-arm64")
set(raw_executable ON)
set(download_sha512 303b5c897eab93fb164dda53ecf6294fd3376a5de17a752388f4e7f612a8a537acc7d99a021ca616c1d7989d10c3c14cd87689dad60b9f654bf75ecc606bb23e)
else()
set(download_urls "https://github.com/bazelbuild/bazel/releases/download/${program_version}/bazel-${tool_subdirectory}-x86_64")
set(download_filename "bazel-${tool_subdirectory}-x86_64")
set(raw_executable ON)
set(download_sha512 609db0a2f9d6eab292271b44acf08978159ca43a90f3228e32afe430e830f5418a041480d75e5b502be192897693f6b80a9ab9e7ce549e3655e188c39d29baaf)
endif()
elseif(VCPKG_TARGET_IS_WINDOWS)
set(tool_subdirectory "${program_version}-windows")
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
set(download_urls "https://github.com/bazelbuild/bazel/releases/download/${program_version}/bazel-${tool_subdirectory}-arm64.exe")
set(download_filename "bazel-${tool_subdirectory}-arm64.exe")
set(download_sha512 02c8f331daa3ea37319cf06d96618f433e297f749a1a6de863d243e2b826bfb12c058696cd6216afe38d35177f52cc1c66af98a8bcb191e198f436a44f2c2a1a)
else()
set(download_urls "https://github.com/bazelbuild/bazel/releases/download/${program_version}/bazel-${tool_subdirectory}-x86_64.exe")
set(download_filename "bazel-${tool_subdirectory}-x86_64.exe")
set(download_sha512 4917dd714345359c24e40451e20862b2ed705824ceffe536d42e56ffcd66fcea581317857dfb5339b56534b0681efd8376e8eebdcf9daff0d087444b060bdc53)
endif()
endif()

vcpkg_download_distfile(archive_path
URLS ${download_urls}
SHA512 "${download_sha512}"
FILENAME "${download_filename}"
)
message(STATUS "archive_path: '${archive_path}'")

file(MAKE_DIRECTORY "${CURRENT_PACKAGES_DIR}/tools")
file(INSTALL "${archive_path}"
DESTINATION "${CURRENT_PACKAGES_DIR}/tools"
RENAME "${program}"
FILE_PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
8 changes: 8 additions & 0 deletions ports/vcpkg-tool-bazel/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "vcpkg-tool-bazel",
"version": "5.2.0",
"description": "Bazel build system",
"homepage": "https://github.com/bazelbuild/bazel",
"license": "Apache-2.0",
"supports": "native"
}
16 changes: 10 additions & 6 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6941,16 +6941,16 @@
"port-version": 1
},
"tensorflow": {
"baseline": "2.7.0",
"port-version": 2
"baseline": "2.10.0",
"port-version": 0
},
"tensorflow-cc": {
"baseline": "2.7.0",
"port-version": 2
"baseline": "2.10.0",
"port-version": 0
},
"tensorflow-common": {
"baseline": "2.7.0",
"port-version": 2
"baseline": "2.10.0",
"port-version": 0
},
"tensorpipe": {
"baseline": "2022-03-16",
Expand Down Expand Up @@ -7428,6 +7428,10 @@
"baseline": "2.7.18",
"port-version": 0
},
"vcpkg-tool-bazel": {
"baseline": "5.2.0",
"port-version": 0
},
"vectorclass": {
"baseline": "2.00.01",
"port-version": 2
Expand Down
5 changes: 5 additions & 0 deletions versions/t-/tensorflow-cc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0bec9080305d95ca6559f088d425d47ba44cc12c",
"version-semver": "2.10.0",
"port-version": 0
},
{
"git-tree": "c0b8bf99d3056c5b117dd2eabba3125f1d867442",
"version-semver": "2.7.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/t-/tensorflow-common.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "958295999ce648940c11c6671f0897f38944841a",
"version-semver": "2.10.0",
"port-version": 0
},
{
"git-tree": "1f37cd68d08ecbb0ca6c2d630598d3f568f1fcc4",
"version-semver": "2.7.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/t-/tensorflow.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "87372cfe6baffa73e3dd20d50fda320ff2f1f023",
"version-semver": "2.10.0",
"port-version": 0
},
{
"git-tree": "07b6bd8bae65b448a163db4e720c46afd605a1cc",
"version-semver": "2.7.0",
Expand Down
9 changes: 9 additions & 0 deletions versions/v-/vcpkg-tool-bazel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "2594b8f7c3cb557af7882e87fee900f76fe895a8",
"version": "5.2.0",
"port-version": 0
}
]
}

0 comments on commit 81c45c2

Please sign in to comment.