我與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構建的。我將在原文中更新我的解決方案。 –