6

We are trying to build a TensorFlow test case with debug flag:

bazel build -c dbg //tensorflow/python/kernel_tests:sparse_matmul_op_test

However the build is failing with below error:

/usr/include/features.h:330:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
warning _FORTIFY_SOURCE requires compiling with optimization (-O)

cc1: all warnings being treated as errors

Target //tensorflow/python/kernel_tests:sparse_matmul_op_test failed to build

We have tried below options to resolve this:

  1. built by exporting export CFLAGS and CXXFLAGS to "-Wno-error"

  2. bazel build -c dbg --cxxopt="-Wno-all" --cxxopt="-Wno-error" //tensorflow/python/kernel_tests:sparse_matmul_op_test

  3. Tried commenting compiler_flag from third_party/gpus/crosstool/CROSSTOOL.tpl

What is the correct way to suppress these warnings for the build to proceed?

We are using gcc v5.4.0.

2 Answers 2

2

I've had the same issue recently. It got solved by adding --copt=-O and -c opt to the build command.

Example:

bazel build --copt=-O -c dbg -c opt //tensorflow/python/kernel_tests:sparse_matmul_op_test
Sign up to request clarification or add additional context in comments.

Comments

2

Solution by @BernardoGO does not work when CUDA build is enabled:

$ bazel build --copt=-O -c opt --config cuda -c dbg --strip=never //tensorflow/tools/pip_package:build_pip_package -s

/usr/include/c++/6/bits/stl_pair.h(327): error: calling a __host__ function("std::_Rb_tree_const_iterator< ::tensorflow::NcclManager::NcclStream *> ::_Rb_tree_const_iterator") from a __device__ function("std::pair< ::std::_Rb_tree_const_iterator< ::tensorflow::NcclManager::NcclStream *> , bool> ::pair< ::std::_Rb_tree_iterator< ::tensorflow::NcclManager::NcclStream *>  &, bool &, (bool)1> ") is not allowed

/usr/include/c++/6/bits/stl_pair.h(327): error: identifier "std::_Rb_tree_const_iterator< ::tensorflow::NcclManager::NcclStream *> ::_Rb_tree_const_iterator" is undefined in device code

/usr/include/c++/6/bits/stl_algobase.h(1009): error: calling a __host__ function("__builtin_clzl") from a __device__ function("std::__lg") is not allowed

3 errors detected in the compilation of "/tmp/tmpxft_00007abb_00000000-6_nccl_manager.cpp1.ii".

Works only if --copt=-O is replaced with --copt=-O1, but -O1 is too much for comfortable debugging.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.