tensorflow: Build fails with messages including "undefined reference to symbol 'acos@@GLIBC_2.2.5' ", "Linking of rule '@flatbuffers//:flatc' failed"

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 18.04
  • TensorFlow installed from (source or binary): Attempting to build from source
  • TensorFlow version: 2.1.0 (attempting to build from master)
  • Python version: 3.8.0
  • Installed using virtualenv? pip? conda?: virtualenv
  • Bazel version (if compiling from source): 1.2.1
  • GCC/Compiler version (if compiling from source): 7.4.0
  • CUDA/cuDNN version: CUDA 10.1 / cuDNN 7.6.5
  • GPU model and memory: NVidia RTX 2080 Ti

Describe the problem

I am trying to build for python 3.8.0 since issues relating to python 3.8.0 should now be fixed (see #34433 ). There is also no pip package that you can install with “pip install tensorflow” for python 3.8.0.

Build fails with the following messages:

INFO: Analyzed target //tensorflow/tools/pip_package:build_pip_package (345 packages loaded, 27926 targets configured).
INFO: Found 1 target...
INFO: Deleting stale sandbox base /home/daniel/.cache/bazel/_bazel_daniel/79db702fc9f94af7d11e11c5d64854d0/sandbox
INFO: From Compiling tensorflow/core/platform/default/logging.cc [for host]:
tensorflow/core/platform/default/logging.cc: In member function ‘bool tensorflow::internal::LogFirstNState::ShouldLog(int)’:
tensorflow/core/platform/default/logging.cc:369:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (counter_value < n) {
       ~~~~~~~~~~~~~~^~~
INFO: From Compiling external/snappy/snappy-sinksource.cc [for host]:
cc1plus: warning: command line option ‘-Wno-implicit-function-declaration’ is valid for C/ObjC but not for C++
INFO: From Compiling external/snappy/snappy-stubs-internal.cc [for host]:
cc1plus: warning: command line option ‘-Wno-implicit-function-declaration’ is valid for C/ObjC but not for C++
INFO: From Compiling external/snappy/snappy.cc [for host]:
cc1plus: warning: command line option ‘-Wno-implicit-function-declaration’ is valid for C/ObjC but not for C++
INFO: From Compiling tensorflow/core/platform/protobuf.cc [for host]:
tensorflow/core/platform/protobuf.cc: In member function ‘virtual bool tensorflow::TStringOutputStream::Next(void**, int*)’:
tensorflow/core/platform/protobuf.cc:30:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if (old_size < target_->capacity()) {
       ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
INFO: From Compiling tensorflow/core/platform/numbers.cc [for host]:
tensorflow/core/platform/numbers.cc: In instantiation of ‘T tensorflow::{anonymous}::locale_independent_strtonum(const char*, const char**) [with T = double]’:
tensorflow/core/platform/numbers.cc:197:60:   required from here
tensorflow/core/platform/numbers.cc:65:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int i = 0; i < special_num_str.length(); ++i) {
                   ~~^~~~~~~~~~~~~~~~~~~~~~~~~~
tensorflow/core/platform/numbers.cc: In function ‘std::__cxx11::string tensorflow::strings::HumanReadableNumBytes(tensorflow::int64)’:
tensorflow/core/platform/numbers.cc:459:8: warning: ‘%lld’ directive output may be truncated writing between 1 and 19 bytes into a region of size between 7 and 8 [-Wformat-truncation=]
 string HumanReadableNumBytes(int64 num_bytes) {
        ^~~~~~~~~~~~~~~~~~~~~
tensorflow/core/platform/numbers.cc:459:8: note: directive argument in the range [0, 9223372036854775807]
In file included from /usr/include/stdio.h:862:0,
                 from /usr/include/c++/7/cstdio:42,
                 from /usr/include/c++/7/ext/string_conversions.h:43,
                 from /usr/include/c++/7/bits/basic_string.h:6361,
                 from /usr/include/c++/7/string:52,
                 from ./tensorflow/core/platform/numbers.h:19,
                 from tensorflow/core/platform/numbers.cc:15:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:65:44: note: ‘__builtin_snprintf’ output between 3 and 22 bytes into a destination of size 8
        __bos (__s), __fmt, __va_arg_pack ());
                                            ^
INFO: From Compiling external/llvm-project/llvm/lib/Support/APFloat.cpp [for host]:
external/llvm-project/llvm/lib/Support/APFloat.cpp: In member function ‘llvm::Expected<llvm::APFloatBase::opStatus> llvm::detail::IEEEFloat::convertFromDecimalString(llvm::StringRef, llvm::APFloatBase::roundingMode)’:
external/llvm-project/llvm/lib/Support/APFloat.cpp:2625:38: warning: ‘D.llvm::decimalInfo::exponent’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     fs = roundSignificandWithExponent(decSignificand, partCount,
          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                       D.exponent, rounding_mode);
                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~
external/llvm-project/llvm/lib/Support/APFloat.cpp:2561:36: warning: ‘D.llvm::decimalInfo::normalizedExponent’ may be used uninitialized in this function [-Wmaybe-uninitialized]
              (D.normalizedExponent + 1) * 28738 <=
              ~~~~~~~~~~~~~~~~~~~~~~^~~~
external/llvm-project/llvm/lib/Support/APFloat.cpp:2622:16: warning: ‘D.llvm::decimalInfo::lastSigDigit’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     } while (p <= D.lastSigDigit);
              ~~^~~~~~~~~~~~~~~~~
external/llvm-project/llvm/lib/Support/APFloat.cpp:2581:58: warning: ‘D.llvm::decimalInfo::firstSigDigit’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     partCount = static_cast<unsigned int>(D.lastSigDigit - D.firstSigDigit) + 1;
                                           ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
INFO: From Compiling external/llvm-project/llvm/lib/Support/UnicodeCaseFold.cpp [for host]:
external/llvm-project/llvm/lib/Support/UnicodeCaseFold.cpp:8:1: warning: multi-line comment [-Wcomment]
 //   utils/unicode-case-fold.py \
 ^
INFO: From Compiling external/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp [for host]:
external/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp: In member function ‘std::unique_ptr<llvm::vfs::RedirectingFileSystem::Entry> llvm::vfs::RedirectingFileSystemParser::parseEntry(llvm::yaml::Node*, llvm::vfs::RedirectingFileSystem*, bool)’:
external/llvm-project/llvm/lib/Support/VirtualFileSystem.cpp:1471:5: warning: ‘Kind’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     switch (Kind) {
     ^~~~~~
INFO: From Compiling external/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp [for host]:
external/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp: In function ‘uint64_t {anonymous}::ELFWriter::writeObject(llvm::MCAssembler&, const llvm::MCAsmLayout&)’:
external/llvm-project/llvm/lib/MC/ELFObjectWriter.cpp:1193:36: warning: ‘AddrsigSection’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       SectionOffsets[AddrsigSection] = std::make_pair(SecStart, SecEnd);
                                    ^
INFO: From Compiling external/llvm-project/llvm/lib/MC/MachObjectWriter.cpp [for host]:
external/llvm-project/llvm/lib/MC/MachObjectWriter.cpp: In member function ‘void llvm::MachObjectWriter::writeNlist(llvm::MachObjectWriter::MachSymbolData&, const llvm::MCAsmLayout&)’:
external/llvm-project/llvm/lib/MC/MachObjectWriter.cpp:381:13: warning: ‘AliaseeInfo’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     Address = AliaseeInfo->StringIndex;
     ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: /home/daniel/.cache/bazel/_bazel_daniel/79db702fc9f94af7d11e11c5d64854d0/external/flatbuffers/BUILD.bazel:51:1: Linking of rule '@flatbuffers//:flatc' failed (Exit 1)
/usr/bin/ld: bazel-out/host/bin/external/flatbuffers/src/libflatbuffers.a(idl_parser.o): undefined reference to symbol 'acos@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
ERROR: /home/daniel/tensorflow/tensorflow/python/tools/BUILD:141:1 Linking of rule '@flatbuffers//:flatc' failed (Exit 1)
INFO: Elapsed time: 103.160s, Critical Path: 25.44s
INFO: 1225 processes: 1225 local.
FAILED: Build did NOT complete successfully

Provide the exact sequence of commands / steps that you executed before running into the problem

git clone https://github.com/tensorflow/tensorflow.git
cd tensorflow
./configure
You have bazel 1.2.1 installed.
Please specify the location of python. [Default is /home/daniel/tf38/bin/python]: Default accepted
Python library path to use.  Default is [/home/daniel/tf38/lib/python3.8/site-packages]: Default accepted
Do you wish to build TensorFlow with XLA JIT support? [Y/n]: Y
XLA JIT support will be enabled for TensorFlow.
Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: N
No OpenCL SYCL support will be enabled for TensorFlow.
Do you wish to build TensorFlow with ROCm support? [y/N]: N
No ROCm support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: y
CUDA support will be enabled for TensorFlow.
Do you wish to build TensorFlow with TensorRT support? [y/N]: y
TensorRT support will be enabled for TensorFlow.
Found CUDA 10.1 in:
    /usr/local/cuda/lib64
    /usr/local/cuda/include
Found cuDNN 7 in:
    /usr/lib/x86_64-linux-gnu
    /usr/include
Found TensorRT 6 in:
    /usr/lib/x86_64-linux-gnu
    /usr/include/x86_64-linux-gnu
CUDA compute capabilities [Default is: 3.5,7.0]: 7.5
Do you want to use clang as CUDA compiler? [y/N]: N
nvcc will be used as CUDA compiler.
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: Default accepted
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native -Wno-sign-compare]: Default accepted
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: N
Not configuring the WORKSPACE for Android builds.
Configuration finished.
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

Build fails with the above messages.

Any other info / logs Include any logs or source code that would be helpful to diagnose the problem. If including tracebacks, please include the full traceback. Large logs and files should be attached.

I have noticed in the past that builds can sometimes build with different bazel versions. I tried bazel 0.26.1, 1.0.0 and 2.0.0. However the build still fails with all these bazel versions.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 3
  • Comments: 16 (4 by maintainers)

Most upvoted comments

--host_linkopt=-lm should work.

@dbonner this is not an issue for 2.1. Try build from master a couple of days ago.

Ping @petewarden; seems the CL adf6e22e4af83afd55e0da3caa7e7959def1e6b6 breaks Linux builds.

Specifying --linkopt=-lm in bazel build does not fix this issue.

the workaround mentioned above doesn’t work at my side.

for those who are still struggling with this problem and using centos-7 with “scl enable devtoolset-7”, I figured out you can workaournd this issue by adding “BAZEL_LINKLIBS=-l%:libstdc++.a” before “bazel build”. you can have a try if other workaround doesn’t work

Gently ping @smit-hinsu as well.

Seems adf6e22e4af83afd55e0da3caa7e7959def1e6b6 breaks MacOS builds as well and got a band-aid fix with db7795727c1025759aa8c584ac433f6a010f7dcb.

I was able to get the build to continue by doing the following:

nano third_party/flatbuffers/BUILD.bazel

After the line “linkstatic = 1”, add this line:

    linkopts = ["-lm","-lpthread"],

@Saduf2019 please let me know if this is the right thing to do. All the best, Dan