Merge pull request #45404 from meteorcloudy:apple_silicon_build
PiperOrigin-RevId: 351822115 Change-Id: I423db3385e0b80709fc442d8c2991211186e4bcc
This commit is contained in:
commit
e687cab616
9
.bazelrc
9
.bazelrc
@ -17,6 +17,9 @@
|
|||||||
# ios_x86_64:
|
# ios_x86_64:
|
||||||
# ios_fat:
|
# ios_fat:
|
||||||
#
|
#
|
||||||
|
# Macosx options
|
||||||
|
# darwin_arm64:
|
||||||
|
#
|
||||||
# Compiler options:
|
# Compiler options:
|
||||||
# cuda_clang: Use clang when building CUDA code.
|
# cuda_clang: Use clang when building CUDA code.
|
||||||
# c++17: Build with C++17 options (links with libc++)
|
# c++17: Build with C++17 options (links with libc++)
|
||||||
@ -134,6 +137,11 @@ build:ios_x86_64 --cpu=ios_x86_64
|
|||||||
build:ios_fat --config=ios
|
build:ios_fat --config=ios
|
||||||
build:ios_fat --ios_multi_cpus=armv7,arm64,i386,x86_64
|
build:ios_fat --ios_multi_cpus=armv7,arm64,i386,x86_64
|
||||||
|
|
||||||
|
# Enables all the macos config options for macos_arm64
|
||||||
|
build:macos_arm64 --config=macos
|
||||||
|
build:macos_arm64 --apple_platform_type=macos
|
||||||
|
build:macos_arm64 --cpu=darwin_arm64
|
||||||
|
|
||||||
# Config to use a mostly-static build and disable modular op registration
|
# Config to use a mostly-static build and disable modular op registration
|
||||||
# support (this will revert to loading TensorFlow with RTLD_GLOBAL in Python).
|
# support (this will revert to loading TensorFlow with RTLD_GLOBAL in Python).
|
||||||
# By default, TensorFlow will build with a dependence on
|
# By default, TensorFlow will build with a dependence on
|
||||||
@ -272,6 +280,7 @@ build:c++1z_gcc --config=c++17_gcc
|
|||||||
build --enable_platform_specific_config
|
build --enable_platform_specific_config
|
||||||
build:android --noenable_platform_specific_config
|
build:android --noenable_platform_specific_config
|
||||||
build:ios --noenable_platform_specific_config
|
build:ios --noenable_platform_specific_config
|
||||||
|
build:macos_arm64 --noenable_platform_specific_config
|
||||||
|
|
||||||
# Suppress C++ compiler warnings, otherwise build logs become 10s of MBs.
|
# Suppress C++ compiler warnings, otherwise build logs become 10s of MBs.
|
||||||
build:android --copt=-w
|
build:android --copt=-w
|
||||||
|
@ -178,7 +178,7 @@ config_setting(
|
|||||||
)
|
)
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "macos",
|
name = "macos_x86_64",
|
||||||
values = {
|
values = {
|
||||||
"apple_platform_type": "macos",
|
"apple_platform_type": "macos",
|
||||||
"cpu": "darwin",
|
"cpu": "darwin",
|
||||||
@ -186,6 +186,23 @@ config_setting(
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "macos_arm64",
|
||||||
|
values = {
|
||||||
|
"apple_platform_type": "macos",
|
||||||
|
"cpu": "darwin_arm64",
|
||||||
|
},
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
selects.config_setting_group(
|
||||||
|
name = "macos",
|
||||||
|
match_any = [
|
||||||
|
":macos_x86_64",
|
||||||
|
":macos_arm64",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "ios",
|
name = "ios",
|
||||||
values = {"apple_platform_type": "ios"},
|
values = {"apple_platform_type": "ios"},
|
||||||
@ -385,7 +402,7 @@ config_setting(
|
|||||||
)
|
)
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "macos_with_framework_shared_object",
|
name = "macos_x86_64_with_framework_shared_object",
|
||||||
define_values = {
|
define_values = {
|
||||||
"framework_shared_object": "true",
|
"framework_shared_object": "true",
|
||||||
},
|
},
|
||||||
@ -396,6 +413,26 @@ config_setting(
|
|||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "macos_arm64_with_framework_shared_object",
|
||||||
|
define_values = {
|
||||||
|
"framework_shared_object": "true",
|
||||||
|
},
|
||||||
|
values = {
|
||||||
|
"apple_platform_type": "macos",
|
||||||
|
"cpu": "darwin_arm64",
|
||||||
|
},
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
selects.config_setting_group(
|
||||||
|
name = "macos_with_framework_shared_object",
|
||||||
|
match_any = [
|
||||||
|
":macos_x86_64_with_framework_shared_object",
|
||||||
|
":macos_arm64_with_framework_shared_object",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "using_cuda_clang",
|
name = "using_cuda_clang",
|
||||||
define_values = {"using_cuda_clang": "true"},
|
define_values = {"using_cuda_clang": "true"},
|
||||||
@ -719,7 +756,9 @@ tf_cc_shared_object(
|
|||||||
name = "tensorflow_framework",
|
name = "tensorflow_framework",
|
||||||
framework_so = [],
|
framework_so = [],
|
||||||
linkopts = select({
|
linkopts = select({
|
||||||
"//tensorflow:macos": [],
|
"//tensorflow:macos": [
|
||||||
|
"-Wl,-rename_section,__TEXT,text_env,__TEXT,__text",
|
||||||
|
],
|
||||||
"//tensorflow:windows": [],
|
"//tensorflow:windows": [],
|
||||||
"//tensorflow:freebsd": [
|
"//tensorflow:freebsd": [
|
||||||
"-Wl,--version-script,$(location //tensorflow:tf_framework_version_script.lds)",
|
"-Wl,--version-script,$(location //tensorflow:tf_framework_version_script.lds)",
|
||||||
|
@ -432,7 +432,8 @@ def target_llvm_triple():
|
|||||||
"//tensorflow:ios": "arm64-none-ios",
|
"//tensorflow:ios": "arm64-none-ios",
|
||||||
"//tensorflow:ios_x86_64": "x86_64-apple-ios",
|
"//tensorflow:ios_x86_64": "x86_64-apple-ios",
|
||||||
"//tensorflow:linux_ppc64le": "ppc64le-ibm-linux-gnu",
|
"//tensorflow:linux_ppc64le": "ppc64le-ibm-linux-gnu",
|
||||||
"//tensorflow:macos": "x86_64-none-darwin",
|
"//tensorflow:macos_x86_64": "x86_64-none-darwin",
|
||||||
|
"//tensorflow:macos_arm64": "aarch64-none-darwin",
|
||||||
"//tensorflow:windows": "x86_64-none-windows",
|
"//tensorflow:windows": "x86_64-none-windows",
|
||||||
"//tensorflow:linux_s390x": "systemz-none-linux-gnu",
|
"//tensorflow:linux_s390x": "systemz-none-linux-gnu",
|
||||||
"//conditions:default": "x86_64-pc-linux",
|
"//conditions:default": "x86_64-pc-linux",
|
||||||
|
@ -186,6 +186,13 @@ config_setting(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "darwin_arm64",
|
||||||
|
values = {
|
||||||
|
"cpu": "darwin_arm64",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "freebsd",
|
name = "freebsd",
|
||||||
values = {
|
values = {
|
||||||
@ -810,6 +817,7 @@ cc_library(
|
|||||||
":ios_armv7",
|
":ios_armv7",
|
||||||
":ios_arm64",
|
":ios_arm64",
|
||||||
":ios_arm64e",
|
":ios_arm64e",
|
||||||
|
":darwin_arm64",
|
||||||
":raspberry_pi_with_neon",
|
":raspberry_pi_with_neon",
|
||||||
): [":neon_tensor_utils"],
|
): [":neon_tensor_utils"],
|
||||||
(
|
(
|
||||||
|
@ -446,6 +446,7 @@ def _rpath_linkopts(name):
|
|||||||
return select({
|
return select({
|
||||||
clean_dep("//tensorflow:macos"): [
|
clean_dep("//tensorflow:macos"): [
|
||||||
"-Wl,%s" % (_make_search_paths("@loader_path", levels_to_root),),
|
"-Wl,%s" % (_make_search_paths("@loader_path", levels_to_root),),
|
||||||
|
"-Wl,-rename_section,__TEXT,text_env,__TEXT,__text",
|
||||||
],
|
],
|
||||||
clean_dep("//tensorflow:windows"): [],
|
clean_dep("//tensorflow:windows"): [],
|
||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
@ -1928,21 +1929,24 @@ def pywrap_tensorflow_macro(
|
|||||||
|
|
||||||
if not version_script:
|
if not version_script:
|
||||||
version_script = select({
|
version_script = select({
|
||||||
"@local_config_cuda//cuda:darwin": clean_dep("//tensorflow:tf_exported_symbols.lds"),
|
"//tensorflow:macos": clean_dep("//tensorflow:tf_exported_symbols.lds"),
|
||||||
"//conditions:default": clean_dep("//tensorflow:tf_version_script.lds"),
|
"//conditions:default": clean_dep("//tensorflow:tf_version_script.lds"),
|
||||||
})
|
})
|
||||||
vscriptname = name + "_versionscript"
|
vscriptname = name + "_versionscript"
|
||||||
_append_init_to_versionscript(
|
_append_init_to_versionscript(
|
||||||
name = vscriptname,
|
name = vscriptname,
|
||||||
is_version_script = select({
|
is_version_script = select({
|
||||||
"@local_config_cuda//cuda:darwin": False,
|
"//tensorflow:macos": False,
|
||||||
"//conditions:default": True,
|
"//conditions:default": True,
|
||||||
}),
|
}),
|
||||||
module_name = module_name,
|
module_name = module_name,
|
||||||
template_file = version_script,
|
template_file = version_script,
|
||||||
)
|
)
|
||||||
extra_linkopts = select({
|
extra_linkopts = select({
|
||||||
"@local_config_cuda//cuda:darwin": [
|
clean_dep("//tensorflow:macos"): [
|
||||||
|
# TODO: the -w suppresses a wall of harmless warnings about hidden typeinfo symbols
|
||||||
|
# not being exported. There should be a better way to deal with this.
|
||||||
|
"-Wl,-w",
|
||||||
"-Wl,-exported_symbols_list,$(location %s.lds)" % vscriptname,
|
"-Wl,-exported_symbols_list,$(location %s.lds)" % vscriptname,
|
||||||
],
|
],
|
||||||
clean_dep("//tensorflow:windows"): [],
|
clean_dep("//tensorflow:windows"): [],
|
||||||
@ -1952,9 +1956,6 @@ def pywrap_tensorflow_macro(
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
extra_deps += select({
|
extra_deps += select({
|
||||||
"@local_config_cuda//cuda:darwin": [
|
|
||||||
"%s.lds" % vscriptname,
|
|
||||||
],
|
|
||||||
clean_dep("//tensorflow:windows"): [],
|
clean_dep("//tensorflow:windows"): [],
|
||||||
"//conditions:default": [
|
"//conditions:default": [
|
||||||
"%s.lds" % vscriptname,
|
"%s.lds" % vscriptname,
|
||||||
@ -2586,7 +2587,10 @@ def pybind_extension(
|
|||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
linkopts = linkopts + _rpath_linkopts(name) + select({
|
linkopts = linkopts + _rpath_linkopts(name) + select({
|
||||||
"@local_config_cuda//cuda:darwin": [
|
clean_dep("//tensorflow:macos"): [
|
||||||
|
# TODO: the -w suppresses a wall of harmless warnings about hidden typeinfo symbols
|
||||||
|
# not being exported. There should be a better way to deal with this.
|
||||||
|
"-Wl,-w",
|
||||||
"-Wl,-exported_symbols_list,$(location %s)" % exported_symbols_file,
|
"-Wl,-exported_symbols_list,$(location %s)" % exported_symbols_file,
|
||||||
],
|
],
|
||||||
clean_dep("//tensorflow:windows"): [],
|
clean_dep("//tensorflow:windows"): [],
|
||||||
|
@ -216,10 +216,10 @@ function prepare_src() {
|
|||||||
if [ -d "${TMPDIR}/tensorflow/_api/v1/" ]
|
if [ -d "${TMPDIR}/tensorflow/_api/v1/" ]
|
||||||
then
|
then
|
||||||
cp -r ${TMPDIR}/tensorflow/python/keras/api/_v1/keras/ ${TMPDIR}/tensorflow/keras/
|
cp -r ${TMPDIR}/tensorflow/python/keras/api/_v1/keras/ ${TMPDIR}/tensorflow/keras/
|
||||||
sed -i'.original' -e 's/.python.keras.api._v1/tensorflow/g' ${TMPDIR}/tensorflow/__init__.py
|
find . -type f -maxdepth 0 -exec sed -i'.original' -e 's/.python.keras.api._v1/tensorflow/g' ${TMPDIR}/tensorflow/__init__.py {} +
|
||||||
else
|
else
|
||||||
cp -r ${TMPDIR}/tensorflow/python/keras/api/_v2/keras/ ${TMPDIR}/tensorflow/keras/
|
cp -r ${TMPDIR}/tensorflow/python/keras/api/_v2/keras/ ${TMPDIR}/tensorflow/keras/
|
||||||
sed -i'.original' -e 's/.python.keras.api._v2/tensorflow/g' ${TMPDIR}/tensorflow/__init__.py
|
find . -type f -maxdepth 0 -exec sed -i'.original' -e 's/.python.keras.api._v2/tensorflow/g' ${TMPDIR}/tensorflow/__init__.py {} +
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
9
third_party/cpuinfo/BUILD.bazel
vendored
9
third_party/cpuinfo/BUILD.bazel
vendored
@ -105,6 +105,7 @@ cc_library(
|
|||||||
":linux_mips64": COMMON_SRCS + LINUX_SRCS,
|
":linux_mips64": COMMON_SRCS + LINUX_SRCS,
|
||||||
":linux_s390x": COMMON_SRCS + LINUX_SRCS,
|
":linux_s390x": COMMON_SRCS + LINUX_SRCS,
|
||||||
":macos_x86_64": COMMON_SRCS + X86_SRCS + MACH_SRCS + MACH_X86_SRCS,
|
":macos_x86_64": COMMON_SRCS + X86_SRCS + MACH_SRCS + MACH_X86_SRCS,
|
||||||
|
":macos_arm64": COMMON_SRCS + MACH_SRCS + MACH_ARM_SRCS,
|
||||||
":windows_x86_64": COMMON_SRCS + X86_SRCS + WINDOWS_X86_SRCS,
|
":windows_x86_64": COMMON_SRCS + X86_SRCS + WINDOWS_X86_SRCS,
|
||||||
":android_armv7": COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM32_SRCS + ANDROID_ARM_SRCS,
|
":android_armv7": COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM32_SRCS + ANDROID_ARM_SRCS,
|
||||||
":android_arm64": COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM64_SRCS + ANDROID_ARM_SRCS,
|
":android_arm64": COMMON_SRCS + ARM_SRCS + LINUX_SRCS + LINUX_ARM64_SRCS + ANDROID_ARM_SRCS,
|
||||||
@ -293,6 +294,14 @@ config_setting(
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "macos_arm64",
|
||||||
|
values = {
|
||||||
|
"apple_platform_type": "macos",
|
||||||
|
"cpu": "darwin_arm64",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "ios_x86",
|
name = "ios_x86",
|
||||||
values = {
|
values = {
|
||||||
|
10
third_party/llvm/llvm.bzl
vendored
10
third_party/llvm/llvm.bzl
vendored
@ -299,7 +299,7 @@ win32_cmake_vars = {
|
|||||||
# TODO(phawkins): use a better method to select the right host triple, rather
|
# TODO(phawkins): use a better method to select the right host triple, rather
|
||||||
# than hardcoding x86_64.
|
# than hardcoding x86_64.
|
||||||
llvm_all_cmake_vars = select({
|
llvm_all_cmake_vars = select({
|
||||||
"@org_tensorflow//tensorflow:macos": cmake_var_string(
|
"@org_tensorflow//tensorflow:macos_x86_64": cmake_var_string(
|
||||||
_dict_add(
|
_dict_add(
|
||||||
cmake_vars,
|
cmake_vars,
|
||||||
llvm_target_cmake_vars("X86", "x86_64-apple-darwin"),
|
llvm_target_cmake_vars("X86", "x86_64-apple-darwin"),
|
||||||
@ -307,6 +307,14 @@ llvm_all_cmake_vars = select({
|
|||||||
darwin_cmake_vars,
|
darwin_cmake_vars,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
"@org_tensorflow//tensorflow:macos_arm64": cmake_var_string(
|
||||||
|
_dict_add(
|
||||||
|
cmake_vars,
|
||||||
|
llvm_target_cmake_vars("AArch64", "arm64-apple-darwin"),
|
||||||
|
posix_cmake_vars,
|
||||||
|
darwin_cmake_vars,
|
||||||
|
),
|
||||||
|
),
|
||||||
"@org_tensorflow//tensorflow:linux_ppc64le": cmake_var_string(
|
"@org_tensorflow//tensorflow:linux_ppc64le": cmake_var_string(
|
||||||
_dict_add(
|
_dict_add(
|
||||||
cmake_vars,
|
cmake_vars,
|
||||||
|
5
third_party/nccl/archive.BUILD
vendored
5
third_party/nccl/archive.BUILD
vendored
@ -89,7 +89,10 @@ cc_library(
|
|||||||
],
|
],
|
||||||
hdrs = ["src/nccl.h"],
|
hdrs = ["src/nccl.h"],
|
||||||
include_prefix = "third_party/nccl",
|
include_prefix = "third_party/nccl",
|
||||||
linkopts = ["-lrt"],
|
linkopts = select({
|
||||||
|
"@org_tensorflow//tensorflow:macos": [],
|
||||||
|
"//conditions:default": ["-lrt"],
|
||||||
|
}),
|
||||||
strip_include_prefix = "src",
|
strip_include_prefix = "src",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
|
@ -20,6 +20,8 @@ def _remote_platform_configure_impl(repository_ctx):
|
|||||||
cpu = "s390x"
|
cpu = "s390x"
|
||||||
elif machine_type.startswith("aarch64"):
|
elif machine_type.startswith("aarch64"):
|
||||||
cpu = "aarch64"
|
cpu = "aarch64"
|
||||||
|
elif machine_type.startswith("arm64"):
|
||||||
|
cpu = "aarch64"
|
||||||
elif machine_type.startswith("arm"):
|
elif machine_type.startswith("arm"):
|
||||||
cpu = "arm"
|
cpu = "arm"
|
||||||
elif machine_type.startswith("mips64"):
|
elif machine_type.startswith("mips64"):
|
||||||
|
Loading…
Reference in New Issue
Block a user