Use .bazelrc to configure optional dependencies (#8218)
Rather than having ./configure mutate one of our .bzl files, which dirties the git repository, this change has ./configure put the options for jemalloc, GCS, HDFS, and XLA inside a .bazelrc at the root of the TensorFlow repository. This file is listed in .gitignore. Therefore, running ./configure will no longer cause the git repository to be in a modified state. Fixes #8202
This commit is contained in:
parent
9daae39fbf
commit
bce77b91f9
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,6 +1,7 @@
|
||||
.DS_Store
|
||||
.ipynb_checkpoints
|
||||
node_modules
|
||||
/.bazelrc
|
||||
/bazel-*
|
||||
/third_party/py/numpy/numpy_include
|
||||
/tools/bazel.rc
|
||||
@ -13,4 +14,4 @@ node_modules
|
||||
*.pyc
|
||||
__pycache__
|
||||
*.swp
|
||||
.vscode/
|
||||
.vscode/
|
||||
|
51
configure
vendored
51
configure
vendored
@ -8,6 +8,9 @@ pushd `dirname $0` > /dev/null
|
||||
SOURCE_BASE_DIR=`pwd -P`
|
||||
popd > /dev/null
|
||||
|
||||
# This file contains customized config settings.
|
||||
touch .bazelrc
|
||||
|
||||
PLATFORM="$(uname -s | tr 'A-Z' 'a-z')"
|
||||
|
||||
function is_linux() {
|
||||
@ -182,13 +185,12 @@ else
|
||||
TF_NEED_JEMALLOC=0
|
||||
fi
|
||||
|
||||
if [ "$TF_NEED_JEMALLOC" == "1" ]; then
|
||||
sed_hyphen_i -e "s/WITH_JEMALLOC = False/WITH_JEMALLOC = True/" tensorflow/core/platform/default/build_config.bzl
|
||||
else
|
||||
sed_hyphen_i -e "s/WITH_JEMALLOC = True/WITH_JEMALLOC = False/" tensorflow/core/platform/default/build_config.bzl
|
||||
sed_hyphen_i -e "/with_jemalloc/d" .bazelrc
|
||||
if [[ "$TF_NEED_JEMALLOC" == "1" ]]; then
|
||||
echo 'build --define with_jemalloc=true' >>.bazelrc
|
||||
fi
|
||||
|
||||
while [ "$TF_NEED_GCP" == "" ]; do
|
||||
while [[ "$TF_NEED_GCP" == "" ]]; do
|
||||
read -p "Do you wish to build TensorFlow with "\
|
||||
"Google Cloud Platform support? [y/N] " INPUT
|
||||
case $INPUT in
|
||||
@ -202,23 +204,12 @@ while [ "$TF_NEED_GCP" == "" ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$TF_NEED_GCP" == "1" ]; then
|
||||
## Verify that libcurl header files are available.
|
||||
# Only check Linux, since on MacOS the header files are installed with XCode.
|
||||
if is_linux && [[ ! -f "/usr/include/curl/curl.h" ]]; then
|
||||
echo "ERROR: It appears that the development version of libcurl is not "\
|
||||
"available. Please install the libcurl3-dev package."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Update Bazel build configuration.
|
||||
sed_hyphen_i -e "s/WITH_GCP_SUPPORT = False/WITH_GCP_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl
|
||||
else
|
||||
# Update Bazel build configuration.
|
||||
sed_hyphen_i -e "s/WITH_GCP_SUPPORT = True/WITH_GCP_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
|
||||
sed_hyphen_i -e "/with_gcp_support/d" .bazelrc
|
||||
if [[ "$TF_NEED_GCP" == "1" ]]; then
|
||||
echo 'build --define with_gcp_support=true' >>.bazelrc
|
||||
fi
|
||||
|
||||
while [ "$TF_NEED_HDFS" == "" ]; do
|
||||
while [[ "$TF_NEED_HDFS" == "" ]]; do
|
||||
read -p "Do you wish to build TensorFlow with "\
|
||||
"Hadoop File System support? [y/N] " INPUT
|
||||
case $INPUT in
|
||||
@ -232,16 +223,13 @@ while [ "$TF_NEED_HDFS" == "" ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$TF_NEED_HDFS" == "1" ]; then
|
||||
# Update Bazel build configuration.
|
||||
sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = False/WITH_HDFS_SUPPORT = True/" tensorflow/core/platform/default/build_config.bzl
|
||||
else
|
||||
# Update Bazel build configuration.
|
||||
sed_hyphen_i -e "s/WITH_HDFS_SUPPORT = True/WITH_HDFS_SUPPORT = False/" tensorflow/core/platform/default/build_config.bzl
|
||||
sed_hyphen_i -e "/with_hdfs_support/d" .bazelrc
|
||||
if [[ "$TF_NEED_HDFS" == "1" ]]; then
|
||||
echo 'build --define with_hdfs_support=true' >>.bazelrc
|
||||
fi
|
||||
|
||||
## Enable XLA.
|
||||
while [ "$TF_ENABLE_XLA" == "" ]; do
|
||||
while [[ "$TF_ENABLE_XLA" == "" ]]; do
|
||||
read -p "Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] " INPUT
|
||||
case $INPUT in
|
||||
[Yy]* ) echo "XLA JIT support will be enabled for TensorFlow"; TF_ENABLE_XLA=1;;
|
||||
@ -251,12 +239,9 @@ while [ "$TF_ENABLE_XLA" == "" ]; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "$TF_ENABLE_XLA" == "1" ]; then
|
||||
# Update Bazel build configuration.
|
||||
sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = True/" tensorflow/core/platform/default/build_config_root.bzl
|
||||
else
|
||||
# Update Bazel build configuration.
|
||||
sed_hyphen_i -e "s/^WITH_XLA_SUPPORT = [FT].*/WITH_XLA_SUPPORT = False/" tensorflow/core/platform/default/build_config_root.bzl
|
||||
sed_hyphen_i -e "/with_xla_support/d" .bazelrc
|
||||
if [[ "$TF_ENABLE_XLA" == "1" ]]; then
|
||||
echo 'build --define with_xla_support=true' >>.bazelrc
|
||||
fi
|
||||
|
||||
|
||||
|
@ -110,6 +110,34 @@ config_setting(
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
# TODO(jhseu): Enable on other platforms other than Linux.
|
||||
config_setting(
|
||||
name = "with_jemalloc",
|
||||
values = {
|
||||
"cpu": "k8",
|
||||
"define": "with_jemalloc=true",
|
||||
},
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "with_gcp_support",
|
||||
values = {"define": "with_gcp_support=true"},
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "with_hdfs_support",
|
||||
values = {"define": "with_hdfs_support=true"},
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
config_setting(
|
||||
name = "with_xla_support",
|
||||
values = {"define": "with_xla_support=true"},
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
package_group(
|
||||
name = "internal",
|
||||
packages = ["//tensorflow/..."],
|
||||
|
@ -4,11 +4,6 @@ load("@protobuf//:protobuf.bzl", "cc_proto_library")
|
||||
load("@protobuf//:protobuf.bzl", "py_proto_library")
|
||||
load("//tensorflow:tensorflow.bzl", "if_not_mobile")
|
||||
|
||||
# configure may change the following lines
|
||||
WITH_GCP_SUPPORT = False
|
||||
WITH_HDFS_SUPPORT = False
|
||||
WITH_JEMALLOC = False
|
||||
|
||||
# Appends a suffix to a list of deps.
|
||||
def tf_deps(deps, suffix):
|
||||
tf_deps = []
|
||||
@ -194,35 +189,30 @@ def tf_additional_test_srcs():
|
||||
def tf_kernel_tests_linkstatic():
|
||||
return 0
|
||||
|
||||
# jemalloc only enabled on Linux for now.
|
||||
# TODO(jhseu): Enable on other platforms.
|
||||
def tf_additional_lib_defines():
|
||||
defines = []
|
||||
if WITH_JEMALLOC:
|
||||
defines += select({
|
||||
"//tensorflow:linux_x86_64": [
|
||||
"TENSORFLOW_USE_JEMALLOC"
|
||||
],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
return defines
|
||||
return select({
|
||||
"//tensorflow:with_jemalloc": ["TENSORFLOW_USE_JEMALLOC"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
def tf_additional_lib_deps():
|
||||
deps = []
|
||||
if WITH_JEMALLOC:
|
||||
deps += select({
|
||||
"//tensorflow:linux_x86_64": ["@jemalloc"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
return deps
|
||||
return select({
|
||||
"//tensorflow:with_jemalloc": ["@jemalloc"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
def tf_additional_core_deps():
|
||||
deps = []
|
||||
if WITH_GCP_SUPPORT:
|
||||
deps.append("//tensorflow/core/platform/cloud:gcs_file_system")
|
||||
if WITH_HDFS_SUPPORT:
|
||||
deps.append("//tensorflow/core/platform/hadoop:hadoop_file_system")
|
||||
return deps
|
||||
return select({
|
||||
"//tensorflow:with_gcp_support": [
|
||||
"//tensorflow/core/platform/cloud:gcs_file_system",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}) + select({
|
||||
"//tensorflow:with_hdfs_support": [
|
||||
"//tensorflow/core/platform/hadoop:hadoop_file_system",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
# TODO(jart, jhseu): Delete when GCP is default on.
|
||||
def tf_additional_cloud_op_deps():
|
||||
|
@ -2,8 +2,6 @@
|
||||
# The functions in this file might be referred by tensorflow.bzl. They have to
|
||||
# be separate to avoid cyclic references.
|
||||
|
||||
WITH_XLA_SUPPORT = False
|
||||
|
||||
def tf_cuda_tests_tags():
|
||||
return ["local"]
|
||||
|
||||
@ -11,16 +9,16 @@ def tf_sycl_tests_tags():
|
||||
return ["local"]
|
||||
|
||||
def tf_additional_plugin_deps():
|
||||
deps = []
|
||||
if WITH_XLA_SUPPORT:
|
||||
deps.append("//tensorflow/compiler/jit")
|
||||
return deps
|
||||
return select({
|
||||
"//tensorflow:with_xla_support": ["//tensorflow/compiler/jit"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
||||
def tf_additional_xla_deps_py():
|
||||
return []
|
||||
|
||||
def tf_additional_license_deps():
|
||||
licenses = []
|
||||
if WITH_XLA_SUPPORT:
|
||||
licenses.append("@llvm//:LICENSE.TXT")
|
||||
return licenses
|
||||
return select({
|
||||
"//tensorflow:with_xla_support": ["@llvm//:LICENSE.TXT"],
|
||||
"//conditions:default": [],
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user