bazel: Cannot make tensorflow to use a local gcc installation?

Hi, I am bound to an old installation on a machine. I had to install a local gcc 4.8.1 and thanks to the community I managed to compile bazel (https://github.com/bazelbuild/bazel/issues/629) . However, now I am unable to compile tensorflow. This is the error I get:

gcc: unrecognized option '-no-canonical-prefixes'
cc1plus: error: unrecognized command line option "-std=c++11"
cc1plus: warning: unrecognized command line option "-Wno-free-nonheap-object"
ERROR: $HOME/tensorflow/google/protobuf/BUILD:29:1: C++ compilation of rule '//google/protobuf:protobuf_lite' failed: crosstool_wrapper_driver_is_not_gcc failed: error executing command third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object ... : com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.

I guess it is not getting the correct gcc, since if I run :

/path/to/local/gcc.4.8.1/bin/gcc -std=c++11  example.cc 

All is ok, but if I run

/usr/bin/gcc  -std=c++11 example.cc

I get the same error"

cc1plus: error: unrecognized command line option "-std=c++11"

If I add the --verbose_failures option, I get this additional information:

(cd $HOME/.cache/bazel/_bazel_$USER/2d4cdeea5be55811d371414ca0f7bd15/tensorflow && \
  exec env - \
    PATH=$HOME/jdk1.8.0_65/bin/:$HOME/local.gcc-4.8.1/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:$HOME/bin \
  third_party/gpus/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections '-std=c++11' -iquote . -iquote bazel-out/local_linux-opt/genfiles -iquote external/bazel_tools -iquote bazel-out/local_linux-opt/genfiles/external/bazel_tools -isystem google/protobuf/src -isystem bazel-out/local_linux-opt/genfiles/google/protobuf/src -isystem external/bazel_tools/tools/cpp/gcc3 -DHAVE_PTHREAD -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare '-Wno-error=unused-function' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' '-frandom-seed=bazel-out/local_linux-opt/bin/google/protobuf/_objs/protobuf_lite/google/protobuf/src/google/protobuf/wire_format_lite.o' -MD -MF bazel-out/local_linux-opt/bin/google/protobuf/_objs/protobuf_lite/google/protobuf/src/google/protobuf/wire_format_lite.d -c google/protobuf/src/google/protobuf/wire_format_lite.cc -o bazel-out/local_linux-opt/bin/google/protobuf/_objs/protobuf_lite/google/protobuf/src/google/protobuf/wire_format_lite.o)

How can I make it use the correct gcc ? Tensorflow comunity redirected me to bazel comunity : https://github.com/tensorflow/tensorflow/issues/336

Thanks,

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 22 (6 by maintainers)

Most upvoted comments

Hi, I solved the runtime linking problem by simply adding

   linker_flag: "-L/home/user/clibs/lib64"
   linker_flag: "-lstdc++"
   linker_flag: "-Wl,-rpath,/home/user/clibs/lib64"

to third_party/gpus/crosstool/CROSSTOOL, hope it helps.