构建张量流单元测试的问题

时间:2018-06-14 08:09:02

标签: tensorflow build googletest position-independent-code

我需要对某些XLA传递运行测试,并使用bazel test --config=opt --config=cuda //tensorflow/compiler/xla/service执行相同的操作(来自here)。构建失败,显示以下消息,暗示缺少googletest依赖项。

/usr/lib/x86_64-linux-gnu/Scrt1.o: In function `_start':
(.text+0x20): undefined reference to `main'

依赖项libgtest.alibgtest_main.a是从googletest源构建的,并使用--linkopt=/path/to/file传递给链接器。

googletest/googletest/libgtest_main.a(gtest_main.cc.o): relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC

添加-DCMAKE_CXX_FLAGS=-fPIC没有帮助。如何更改cmake配置以使用-fPIC进行构建?

tensorflow(v1.8)配置为由本地构建的版本gcc(5.4)构建,因为系统的版本(5.5)无法构建张量流。这会是问题的原因吗?

1 个答案:

答案 0 :(得分:0)

链接到共享库而不是目标文件存档解决了这个问题,即

bazel test --linkopt="$GTEST_DIR/libgtest.so" --linkopt="GTEST_DIR/libgtest_main.so"

代替,

bazel test --linkopt="$GTEST_DIR/libgtest.a" --linkopt="GTEST_DIR/libgtest_main.a"

这仍然无助于运行tensorflow单元测试。根据单元测试存在构建错误,例如。 //tensorflow/...../absl/base/internal的编译失败。

相关问题