0

I need to run tests on some XLA passes and used bazel test --config=opt --config=cuda //tensorflow/compiler/xla/service to do the same (from here). The build failed with the following message, hinting at the missing googletest dependency.

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

The dependences libgtest.a and libgtest_main.a were built from the googletest source and passed to the linker using --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

Adding -DCMAKE_CXX_FLAGS=-fPIC didn't help. How can I change the cmake config to build with -fPIC ?

tensorflow (v1.8) is configured to be built by a locally built version gcc (5.4), since the system's version (5.5) fails to build tensorflow. Would that be the cause of the problem ?

kesari
  • 536
  • 1
  • 6
  • 16

1 Answers1

0

Linking to the shared libraries instead of the object file archive solved this problem, i.e.,

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

instead of,

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

This still doesn't help run tensorflow unit tests. There are build errors in dependences of the unit tests, eg. the compilation of //tensorflow/...../absl/base/internal fails.

kesari
  • 536
  • 1
  • 6
  • 16