tensorflow: gcc: error: unrecognized command line option '-fcolor-diagnostics'
The issue is similar to #1192
I am trying build Tensorflow from source on UBUNTU machine (16.04 LTS) I am using following version of gcc and bazel
- gcc (Ubuntu 5.4.0-6ubuntu1~16.04.5) 5.4.0 20160609
- bazel Build label: 0.9.0
Problem Description
I get a number of build errors during the bazel build phase. All errors are similar to one below (I used --verbose_failures option for bazel build):
ERROR: /home/murthy/tensorflow/tensorflow/core/BUILD:1656:1: Couldn't build file tensorflow/core/_objs/version_lib/tensorflow/core/util/version_info.pic.o: C++ compilation of rule '//tensorflow/core:version_lib' failed (Exit 1): gcc failed: error executing command (cd /home/murthy/.cache/bazel/_bazel_murthy/72b24eaacfd1d73bef6a8acb540b8c44/execroot/org_tensorflow && \ exec env - \ PWD=/proc/self/cwd \ PYTHON_BIN_PATH=/home/murthy/.virtualenvs/dl4cv/bin/python \ PYTHON_LIB_PATH=/home/murthy/.virtualenvs/dl4cv/lib/python3.5 \ TF_NEED_CUDA=0 \ TF_NEED_OPENCL_SYCL=0 \ /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fcolor-diagnostics -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections -DGEMMLOWP_ALLOW_SLOW_SCALAR_FALLBACK '-march=native' -mssse3 -mfma -mcx16 -msse4.1 -msse4.2 -mpopcnt -mavx '-std=c++0x' -MD -MF bazel-out/k8-py3-opt/bin/tensorflow/core/_objs/version_lib/tensorflow/core/util/version_info.pic.d '-frandom-seed=bazel-out/k8-py3-opt/bin/tensorflow/core/_objs/version_lib/tensorflow/core/util/version_info.pic.o' -fPIC -iquote . -iquote bazel-out/k8-py3-opt/genfiles -iquote external/bazel_tools -iquote bazel-out/k8-py3-opt/genfiles/external/bazel_tools -isystem external/bazel_tools/tools/cpp/gcc3 -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare -fno-exceptions '-ftemplate-depth=900' -msse3 -pthread -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c bazel-out/k8-py3-opt/genfiles/tensorflow/core/util/version_info.cc -o bazel-out/k8-py3-opt/bin/tensorflow/core/_objs/version_lib/tensorflow/core/util/version_info.pic.o) gcc: error: unrecognized command line option '-fcolor-diagnostics' Target //tensorflow/tools/pip_package:build_pip_package failed to build
What did I do?
I manually removed the -fcolor-diagnostics flag and gcc did not give an error.
further I looked up the man pages for gcc and was surprised to find
Language Independent Options -fmessage-length=n -fdiagnostics-show-location=[once|every-line] -fdiagnostics-color=[auto|never|always] -fno-diagnostics-show-option -fno-diagnostics-show-caret
Note: the interchange in the words ‘diagnostics’ and ‘color’ in the man pages as compared to that in flags for bazel build
I am not sure if this is Tensorflow issue or bazel issue but am looking for a way to suppress the -fcolor-diagnostics' flag or change it to -fdiagnostics-color`
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (9 by maintainers)
It’s coming from bazel autodetected crosstool, but this option should be only added when the compiler understands given flag. So it’s very weird that bazel autodetected this flag for you. The only explanation I could find is that you had a symlink from gcc -> clang, then bazel autodetected the toolchain, and then you removed the symlink and installed gcc. Bazel would not notice the change in the system and would not regenerate the toolchain. You can test if smth similar is happening by running
bazel clean --expungeand then building again. If the problem persists, it must be something else.