我正在尝试使用此命令在OSX上使用bazel构建一个tensorflow工具:
bazel build tensorflow/python/tools:freeze_graph
输出gcc -v:
gcc版本4.9.4(MacPorts gcc49 4.9.4_1)
bazel version
0.11.1
Xcode版本:
Xcode 9.2
但是,我收到错误:
ERROR: /private/var/tmp/_bazel_macuser/521cd0aef0e1f687906b0f761e1e0f08/external/protobuf_archive/BUILD:259:1:
Linking of rule '@protobuf_archive//:js_embed' failed (Exit 1): cc_wrapper.sh failed: error executing command
(cd /private/var/tmp/_bazel_macuser/521cd0aef0e1f687906b0f761e1e0f08/execroot/org_tensorflow && \
exec env - \
APPLE_SDK_PLATFORM='' \
APPLE_SDK_VERSION_OVERRIDE='' \
PATH=/anaconda/bin:/Users/macuser/anaconda2/bin:/Applications/google-cloud-sdk/bin:
/opt/local/bin:/opt/local/sbin:/Users/macuser/anaconda/bin:/usr/local/cuda/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:
/usr/bin:/bin:/usr/sbin:/sbin \
XCODE_VERSION_OVERRIDE=9.2.0 \
external/local_config_cc/cc_wrapper.sh -fobjc-link-runtime -Wl,-S -o `bazel-out/host/bin/external/protobuf_archive/js_embed bazel-
out/host/bin/external/protobuf_archive/_objs/
js_embed/external/protobuf_archive/src/google/protobuf/compiler/js/embed.o -headerpad_max_install_names -lc++ -no-canonical-prefixes)`
gcc: error: unrecognized command line option '-fobjc-link-runtime'
Target //tensorflow/python/tools:freeze_graph failed to build
INFO: Elapsed time: 17.640s, Critical Path: 3.74s
FAILED: Build did NOT complete successfully
如何正确编译?
答案 0 :(得分:1)
看起来你在某处设置了CC
环境变量? Bazel试图变得聪明并且检测哪个工具链最适合用户,并且在您的情况下,它看起来像检测到适用于C ++和ObjC的工具链,但随后使用gcc与该工具链。这很奇怪,可能是向bazel报告问题的理由。
您能否确保使用最新的bazel和tensorflow,运行bazel clean --expunge
,确保没有设置CC
环境变量(或者如果您想使用gcc set BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
env var),然后在tensorflow中运行./configure
,然后构建?