Reputation: 325
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:
built by exporting export CFLAGS and CXXFLAGS to "-Wno-error"
bazel build -c dbg --cxxopt="-Wno-all" --cxxopt="-Wno-error" //tensorflow/python/kernel_tests:sparse_matmul_op_test
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.
Upvotes: 6
Views: 3182
Reputation: 1923
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.
Upvotes: 2
Reputation: 1856
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
Upvotes: 2