Skip to content
This repository was archived by the owner on Jan 22, 2019. It is now read-only.
This repository was archived by the owner on Jan 22, 2019. It is now read-only.

Linking problem #20

@ddresser

Description

@ddresser

Hello,
I am trying to cross compile for armv7 using a custom toolchain. I am using bazel 0.8.1 and trying to compile tensorflow HEAD. (30b64a8d78b32db8f30957294efc9cac902b9fd3)

I made a small change to 'tf-crosscompile.patch' to make it patch successfully and used the following command ./cross-compile.sh /home/ddresser/.gradle/var/idexx/compilers/acadia arm-linux-gnueabihf HEAD

I also updated the cross-compile.sh script with '-march=armv7'

Here is the beginning of the build:

using gcc : /home/ddresser/.gradle/var/idexx/compilers/acadia/bin/arm-linux-gnueabihf-gcc version 6.3.1
Cloning into 'tensorflow'...
remote: Counting objects: 281972, done.
remote: Compressing objects: 100% (20/20), done.
remote: Total 281972 (delta 7), reused 9 (delta 2), pack-reused 281950
Receiving objects: 100% (281972/281972), 139.08 MiB | 1.18 MiB/s, done.
Resolving deltas: 100% (220740/220740), done.
Checking connectivity... done.
Your branch is up-to-date with 'origin/master'.
Extracting Bazel installation...
You have bazel 0.8.1 installed.
Please specify the location of python. [Default is /usr/bin/python]:

Found possible Python library paths:
/usr/local/lib/python2.7/dist-packages
/usr/lib/python2.7/dist-packages
Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages]
Do you wish to build TensorFlow with jemalloc as malloc support? [Y/n]: jemalloc as malloc support will be enabled for TensorFlow.

Do you wish to build TensorFlow with Google Cloud Platform support? [Y/n]: Google Cloud Platform support will be enabled for TensorFlow.

Do you wish to build TensorFlow with Hadoop File System support? [Y/n]: Hadoop File System support will be enabled for TensorFlow.

Do you wish to build TensorFlow with Amazon S3 File System support? [Y/n]: Amazon S3 File System support will be enabled for TensorFlow.

Do you wish to build TensorFlow with XLA JIT support? [y/N]: No XLA JIT support will be enabled for TensorFlow.

Do you wish to build TensorFlow with GDR support? [y/N]: No GDR support will be enabled for TensorFlow.

Do you wish to build TensorFlow with VERBS support? [y/N]: No VERBS support will be enabled for TensorFlow.

Do you wish to build TensorFlow with OpenCL SYCL support? [y/N]: No OpenCL SYCL support will be enabled for TensorFlow.

Do you wish to build TensorFlow with CUDA support? [y/N]: No CUDA support will be enabled for TensorFlow.

Do you wish to build TensorFlow with MPI support? [y/N]: No MPI support will be enabled for TensorFlow.

Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]:

Add "--config=mkl" to your bazel command to build with MKL support.
Please note that MKL on MacOS or windows is still not supported.
If you would like to use a local MKL instead of downloading, please set the environment variable "TF_MKL_ROOT" every time before build.

Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: Not configuring the WORKSPACE for Android builds.

Configuration finished
launching bazel with flags ''
........
Analyzing: target //tensorflow:libtensorflow.so (16 packages loaded)

Everything seems to compile fine, but I get this error when it tries to link:

ERROR: /home/ddresser/src/tensorflow-build/target/tensorflow/tensorflow/cc/BUILD:422:1: Linking of rule '//tensorflow/cc:ops/logging_ops_gen_cc' failed (Exit 1): gcc failed: error executing command
(cd /home/ddresser/.cache/bazel/_bazel_ddresser/07218640e155d2003dbb6761ed58c2d0/execroot/org_tensorflow &&
exec env -
PATH=/home/ddresser/bin:/home/ddresser/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
PWD=/proc/self/cwd
/usr/bin/gcc -o bazel-out/host/bin/tensorflow/cc/ops/logging_ops_gen_cc '-Wl,-rpath,$ORIGIN/../../../_solib_local/_U_S_Stensorflow_Scc_Cops_Slogging_Uops_Ugen_Ucc___Utensorflow' -Lbazel-out/host/bin/_solib_local/_U_S_Stensorflow_Scc_Cops_Slogging_Uops_Ugen_Ucc___Utensorflow '-Wl,-rpath,$ORIGIN/,-rpath,$ORIGIN/..,-rpath,$ORIGIN/../..' -pthread -B/usr/bin/ -Wl,-z,relro,-z,now -no-canonical-prefixes -pass-exit-codes '-Wl,--build-id=md5' '-Wl,--hash-style=gnu' -Wl,--gc-sections -Wl,-S -Wl,@bazel-out/host/bin/tensorflow/cc/ops/logging_ops_gen_cc-2.params)
bazel-out/host/bin/tensorflow/cc/libcc_op_gen_main.a(cc_op_gen_main.o): In function main': cc_op_gen_main.cc:(.text.startup.main+0x45): undefined reference to tensorflow::port::InitMain(char const*, int*, char***)'
cc_op_gen_main.cc:(.text.startup.main+0x130): undefined reference to tensorflow::StringPiece::find(char, unsigned long) const' cc_op_gen_main.cc:(.text.startup.main+0x137): undefined reference to tensorflow::StringPiece::npos'
cc_op_gen_main.cc:(.text.startup.main+0x24b): undefined reference to tensorflow::OpList::OpList()' cc_op_gen_main.cc:(.text.startup.main+0x250): undefined reference to tensorflow::OpRegistry::Global()'
cc_op_gen_main.cc:(.text.startup.main+0x265): undefined reference to tensorflow::OpRegistry::Export(bool, tensorflow::OpList*) const' cc_op_gen_main.cc:(.text.startup.main+0x291): undefined reference to tensorflow::Env::Default()'
cc_op_gen_main.cc:(.text.startup.main+0x496): undefined reference to tensorflow::io::internal::JoinPathImpl[abi:cxx11](std::initializer_list<tensorflow::StringPiece>)' cc_op_gen_main.cc:(.text.startup.main+0x4dd): undefined reference to tensorflow::Env::FileExists(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'
cc_op_gen_main.cc:(.text.startup.main+0x52d): undefined reference to tensorflow::TfCheckOpHelperOutOfLine[abi:cxx11](tensorflow::Status const&, char const*)' cc_op_gen_main.cc:(.text.startup.main+0x575): undefined reference to tensorflow::internal::LogMessageFatal::LogMessageFatal(char const*, int)'
cc_op_gen_main.cc:(.text.startup.main+0x595): undefined reference to tensorflow::internal::LogMessageFatal::~LogMessageFatal()' cc_op_gen_main.cc:(.text.startup.main+0x624): undefined reference to tensorflow::OpList::~OpList()'
bazel-out/host/bin/tensorflow/cc/libcc_op_gen_main.a(cc_op_gen.o): In function tensorflow::(anonymous namespace)::MakeComment(tensorflow::StringPiece, tensorflow::StringPiece)': cc_op_gen.cc:(.text._ZN10tensorflow12_GLOBAL__N_111MakeCommentENS_11StringPieceES1_+0xd7): undefined reference to tensorflow::StringPiece::substr(unsigned long, unsigned long) const'
cc_op_gen.cc:(.text.ZN10tensorflow12_GLOBAL__N_111MakeCommentENS_11StringPieceES1+0x12a): undefined reference to tensorflow::strings::StrAppend(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >*, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&)' cc_op_gen.cc:(.text._ZN10tensorflow12_GLOBAL__N_111MakeCommentENS_11StringPieceES1_+0x1b8): undefined reference to tensorflow::strings::StrAppend(std::__cxx11::basic_string<char, std::char_traits, std::allocator >, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&)'
bazel-out/host/bin/tensorflow/cc/libcc_op_gen_main.a(cc_op_gen.o): In function tensorflow::(anonymous namespace)::PrintString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': cc_op_gen.cc:(.text._ZN10tensorflow12_GLOBAL__N_111PrintStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x40): undefined reference to tensorflow::str_util::CEscapeabi:cxx11'
cc_op_gen.cc:(.text._ZN10tensorflow12_GLOBAL__N_111PrintStringERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x83): undefined reference to tensorflow::strings::StrCat[abi:cxx11](tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&)' bazel-out/host/bin/tensorflow/cc/libcc_op_gen_main.a(cc_op_gen.o): In function tensorflow::(anonymous namespace)::OpInfo::GetConstructorDecl(tensorflow::StringPiece, bool) const':
cc_op_gen.cc:(.text._ZNK10tensorflow12_GLOBAL__N_16OpInfo18GetConstructorDeclENS_11StringPieceEb+0x77): undefined reference to tensorflow::strings::StrCat[abi:cxx11](tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&)' cc_op_gen.cc:(.text._ZNK10tensorflow12_GLOBAL__N_16OpInfo18GetConstructorDeclENS_11StringPieceEb+0x129): undefined reference to tensorflow::strings::StrAppend(std::__cxx11::basic_string<char, std::char_traits, std::allocator >
, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&, tensorflow::strings::AlphaNum const&)'
cc_op_gen.cc:(.text._ZNK10tensorflow12_GLOBAL__N_16OpInfo18GetConstructorDeclENS_11StringPieceEb+0x166): undefined reference to `tensorflow::strings::StrAppend(std::__cxx11::basic_string<char, std::char_traits, std::allocator >*, tensorflow::strings::AlphaNum const&)'

It is curious to me that it is using /usr/bin/gcc to try to link when I have specified another toolchain. I have confirmed that the .o files that are created are ARM binaries. for example:

file /home/ddresser/.cache/bazel/_bazel_ddresser/07218640e155d2003dbb6761ed58c2d0/execroot/org_tensorflow/bazel-out/armeabi-opt/bin/tensorflow/core/_objs/framework_internal_impl/tensorflow/core/util/tensor_format.pic.o
/home/ddresser/.cache/bazel/_bazel_ddresser/07218640e155d2003dbb6761ed58c2d0/execroot/org_tensorflow/bazel-out/armeabi-opt/bin/tensorflow/core/_objs/framework_internal_impl/tensorflow/core/util/tensor_format.pic.o: ELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV), not stripped

However, the .so file I see in the build output seems to be for x86_64:

file /home/ddresser/.cache/bazel/_bazel_ddresser/07218640e155d2003dbb6761ed58c2d0/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/libtensorflow_framework.so

/home/ddresser/.cache/bazel/_bazel_ddresser/07218640e155d2003dbb6761ed58c2d0/execroot/org_tensorflow/bazel-out/host/bin/tensorflow/libtensorflow_framework.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[md5/uuid]=ae5ad2a42b549582f28457f02a1d5932, not stripped

Any ideas on this error an next steps?

Thanks,
Derek

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions