gcc – TensorFlow不使用调试模式构建

我们正在尝试使用debug标志构建TensorFlow测试用例:

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

但是,构建失败并出现以下错误:

/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

我们尝试过以下选项来解决此问题:

>通过将导出CFLAGS和CXXFLAGS导出为“-Wno-error”构建
> bazel build -c dbg –cxxopt =“ – Wno-all”–cxxopt =“ – Wno-error”// tensorflow / python / kernel_tests:sparse_matmul_op_test
>尝试从third_party / gpus / crosstool / CROSSTOOL.tpl评论compiler_flag

抑制这些警告以使构建继续进行的正确方法是什么?

我们正在使用gcc v5.4.0.

最佳答案 我最近遇到了同样的问题.它通过在构建命令中添加–copt = -O和-c opt来解决.

例:

bazel build --copt=-O -c dbg -c opt //tensorflow/python/kernel_tests:sparse_matmul_op_test
点赞