我与Tensorflow 1.1.0工作用gcc 5.2.0和0.4.5巴泽勒 当我这样做:tensorflow linker_flag
./configure bazel build --verbose_failures --config=opt //tensorflow/tools/pip_package:build_pip_package
我得到了以下错误消息:
ERROR: /remote/us03home4/rogerlo/.cache/bazel/_bazel_rogerlo/c6e718933b1d81ab029d890c5eecbc01/external/protobuf/BUILD:67 9:1: null failed: protoc failed: error executing command (cd /remote/us03home4/rogerlo/.cache/bazel/_bazel_rogerlo/c6e718933b1d81ab029d890c5eecbc01/execroot/tensorflow && \ exec env - \ bazel-out/host/bin/external/protobuf/protoc '--python_out=bazel-out/local-opt/genfiles/external/protobuf/python' -Iexternal/protobuf/python -Ibazel-out/local-opt/genfiles/external/protobuf/python bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/any.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/api.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/compiler/plugin.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/descriptor.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/duration.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/empty.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/field_mask.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/source_context.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/struct.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/timestamp.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/type.proto bazel-out/local-opt/genfiles/external/protobuf/python/google/protobuf/wrappers.proto): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1. bazel-out/host/bin/external/protobuf/protoc: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by bazel-out/host/bin/external/protobuf/protoc) bazel-out/host/bin/external/protobuf/protoc: /usr/lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by bazel-out/host/bin/external/protobuf/protoc) bazel-out/host/bin/external/protobuf/protoc: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.18' not found (required by bazel-out/host/bin/external/protobuf/protoc) bazel-out/host/bin/external/protobuf/protoc: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by bazel-out/host/bin/external/protobuf/protoc) ____Building complete. Target //tensorflow/tools/pip_package:build_pip_package failed to build ____Elapsed time: 101.992s, Critical Path: 54.24s make: *** [tensorflow] Error 1
但如果我加入这一行:
linker_flag: "-Wl,-rpath,/depot/gcc-5.2.0/lib64"
到文件
$TENSORFLOW_ROOT/bazel-tensorflow/external/local_config_cc/CROSSTOOL
构建将通过。
我想知道我是否可以从配置文件或其他地方配置linker_flag?
我没有将它添加到生成选项,但它不起作用。
bazel build --verbose_failures --config=opt --linkopt="-Wl,-rpath,/depot/gcc-5.2.0/lib6 4" //tensorflow/tools/pip_package:build_pip_package
编辑:添加巴泽勒版本
SOLUTION:
- 链接器选项添加到巴泽尔的配置。
- 重新编译巴泽尔。
- 编译Tensorflow与重新编译的Bazel将通过。
调查
目标是通过外部的crosstool建成,所以--linkopt将无法正常工作。根据Bazel官员blog,自动检测外部交叉工具(C++)的配置。它指向C++ configuration file。
linker_flag rpath由$ LD_LIBRARY_PATH计算。也就是说,如果您在$ LD_LIBRARY_PATH中定义了一些库路径,Bazel将在linker_flag中生成它们的路径。
但是依赖是因为[问题#2099](github.com/bazelbuild/bazel/issues/2099)
所以设置$ LD_LIBRARY_PATH在[v0.4.5](github上不起作用删除。 com/bazelbuild/bazel/blob/0.4.5/tools/cpp/cc_configure.bzl#L250)
但是,我还没有弄清楚如何正确地执行它(设置env_action或其他)。所以快速解决方案是在配置文件中对其进行硬编码。
(请原谅我对上面的丑陋链接我的名声是不够的,在后超过2个链接。)
添加为--linkopt不起作用的标志?它应该(并且在我的小测试案例中)。该标志是否添加到链接命令行?您可以使用-s标志检查Bazel发出的单个命令行。 – mhlopko
@mhlopko,no --linkopt不适用于我,因为目标是由外部crosstool构建的。我将在原文中更新我的解决方案。 –