From 0017742dd05c19a2bbbf56c87c8da55959df28d8 Mon Sep 17 00:00:00 2001 From: Michael Case Date: Fri, 10 Nov 2017 13:14:03 -0800 Subject: Clean up some redundant and unused build settings. --copts are passed to both c++ and c (so is redundent with --cxxopts). Configs passed to "bazel build" are inherited by "bazel run" and "bazel test". Also removed some unused configs. PiperOrigin-RevId: 175326697 --- configure.py | 19 ++++----------- tensorflow/tensorflow.bzl | 44 ++++++++++++++++++---------------- tensorflow/tools/ci_build/ci_sanity.sh | 2 +- tools/bazel.rc | 8 ------- 4 files changed, 30 insertions(+), 43 deletions(-) diff --git a/configure.py b/configure.py index 3c0df9475d..51d860812e 100644 --- a/configure.py +++ b/configure.py @@ -228,17 +228,9 @@ def setup_python(environ_cp): # Set-up env variables used by python_configure.bzl write_action_env_to_bazelrc('PYTHON_BIN_PATH', python_bin_path) write_action_env_to_bazelrc('PYTHON_LIB_PATH', python_lib_path) - write_to_bazelrc('build --define PYTHON_BIN_PATH="%s"' % python_bin_path) - write_to_bazelrc('build --define PYTHON_LIB_PATH="%s"' % python_lib_path) write_to_bazelrc('build --force_python=py%s' % python_major_version) write_to_bazelrc('build --host_force_python=py%s' % python_major_version) write_to_bazelrc('build --python_path=\"%s"' % python_bin_path) - write_to_bazelrc('test --force_python=py%s' % python_major_version) - write_to_bazelrc('test --host_force_python=py%s' % python_major_version) - write_to_bazelrc('test --define PYTHON_BIN_PATH="%s"' % python_bin_path) - write_to_bazelrc('test --define PYTHON_LIB_PATH="%s"' % python_lib_path) - write_to_bazelrc('run --define PYTHON_BIN_PATH="%s"' % python_bin_path) - write_to_bazelrc('run --define PYTHON_LIB_PATH="%s"' % python_lib_path) environ_cp['PYTHON_BIN_PATH'] = python_bin_path # Write tools/python_bin_path.sh @@ -487,11 +479,12 @@ def set_cc_opt_flags(environ_cp): cc_opt_flags = get_from_env_or_user_or_default(environ_cp, 'CC_OPT_FLAGS', question, default_cc_opt_flags) for opt in cc_opt_flags.split(): - write_to_bazelrc('build:opt --cxxopt=%s --copt=%s' % (opt, opt)) - host_opt = '-march=native' # It should be safe on the same build host. - write_to_bazelrc( - 'build:opt --host_cxxopt=%s --host_copt=%s' % (host_opt, host_opt)) + write_to_bazelrc('build:opt --copt=%s' % opt) + # It should be safe on the same build host. + write_to_bazelrc('build:opt --host_copt=-march=native') write_to_bazelrc('build:opt --define with_default_optimizations=true') + # TODO(mikecase): Remove these default defines once we are able to get + # TF Lite targets building without them. write_to_bazelrc('build --copt=-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK') write_to_bazelrc('build --host_copt=-DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK') @@ -949,7 +942,6 @@ def set_other_mpi_vars(environ_cp): def set_mkl(): write_to_bazelrc('build:mkl --define using_mkl=true') write_to_bazelrc('build:mkl -c opt') - write_to_bazelrc('build:mkl --copt="-DEIGEN_USE_VML"') print( 'Add "--config=mkl" to your bazel command to build with MKL ' 'support.\nPlease note that MKL on MacOS or windows is still not ' @@ -1002,7 +994,6 @@ def main(): environ_cp['TF_NEED_HDFS'] = '0' environ_cp['TF_NEED_JEMALLOC'] = '0' environ_cp['TF_NEED_OPENCL'] = '0' - environ_cp['TF_NEED_S3'] = '0' environ_cp['TF_CUDA_CLANG'] = '0' if is_macos(): diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl index 43ecb7f937..a3ba363469 100644 --- a/tensorflow/tensorflow.bzl +++ b/tensorflow/tensorflow.bzl @@ -168,26 +168,30 @@ WIN_COPTS = [ # LINT.IfChange def tf_copts(): - return (if_not_windows([ - "-DEIGEN_AVOID_STL_ARRAY", - "-Iexternal/gemmlowp", - "-Wno-sign-compare", - "-fno-exceptions", - "-ftemplate-depth=900", - ]) + if_cuda(["-DGOOGLE_CUDA=1"]) + if_mkl(["-DINTEL_MKL=1", "-fopenmp",]) + if_android_arm( - ["-mfpu=neon"]) + if_linux_x86_64(["-msse3"]) + select({ - clean_dep("//tensorflow:android"): [ - "-std=c++11", - "-DTF_LEAN_BINARY", - "-O2", - "-Wno-narrowing", - "-fomit-frame-pointer", - ], - clean_dep("//tensorflow:darwin"): [], - clean_dep("//tensorflow:windows"): WIN_COPTS, - clean_dep("//tensorflow:windows_msvc"): WIN_COPTS, - clean_dep("//tensorflow:ios"): ["-std=c++11"], - "//conditions:default": ["-pthread"] + return ( + if_not_windows([ + "-DEIGEN_AVOID_STL_ARRAY", + "-Iexternal/gemmlowp", + "-Wno-sign-compare", + "-fno-exceptions", + "-ftemplate-depth=900"]) + + if_cuda(["-DGOOGLE_CUDA=1"]) + + if_mkl(["-DINTEL_MKL=1", "-DEIGEN_USE_VML", "-fopenmp",]) + + if_android_arm(["-mfpu=neon"]) + + if_linux_x86_64(["-msse3"]) + + select({ + clean_dep("//tensorflow:android"): [ + "-std=c++11", + "-DTF_LEAN_BINARY", + "-O2", + "-Wno-narrowing", + "-fomit-frame-pointer", + ], + clean_dep("//tensorflow:darwin"): [], + clean_dep("//tensorflow:windows"): WIN_COPTS, + clean_dep("//tensorflow:windows_msvc"): WIN_COPTS, + clean_dep("//tensorflow:ios"): ["-std=c++11"], + "//conditions:default": ["-pthread"] })) diff --git a/tensorflow/tools/ci_build/ci_sanity.sh b/tensorflow/tools/ci_build/ci_sanity.sh index cff672c9df..404a9a6b62 100755 --- a/tensorflow/tools/ci_build/ci_sanity.sh +++ b/tensorflow/tools/ci_build/ci_sanity.sh @@ -403,7 +403,7 @@ cmd_status(){ # Run bazel build --nobuild to test the validity of the BUILD files # TODO(mikecase): Remove TF Lite exclusion from this list. Exclusion is # necessary since the @androidsdk WORKSPACE dependency is commented -# commented out by default in TF WORKSPACE file. +# out by default in TF WORKSPACE file. do_bazel_nobuild() { BUILD_TARGET="//tensorflow/..." BUILD_TARGET="${BUILD_TARGET} -//tensorflow/contrib/lite/java/demo/app/src/main/..." diff --git a/tools/bazel.rc b/tools/bazel.rc index 414ddf2e47..ac6766b11b 100644 --- a/tools/bazel.rc +++ b/tools/bazel.rc @@ -21,13 +21,5 @@ build --define=use_fast_cpp_protos=true build --define=allow_oversize_protos=true build --spawn_strategy=standalone -test --spawn_strategy=standalone -run --spawn_strategy=standalone - build --genrule_strategy=standalone -test --genrule_strategy=standalone -run --genrule_strategy=standalone - build -c opt -test -c opt -run -c opt -- cgit v1.2.3