Cross-compiling Coqui + TFLite for armv7ahf in Yocto: R_ARM_TLS_LE32 relocation not permitted in shared object - tensorflow

I'm trying to do a Yocto build of libstt.so from the Coqui project, with TFLite as the backend, for the Snapdragon 210 which has an armv7ahf processor. I've been using the meta-tensorflow OpenEmbedded layer as a starting point.
Getting Bazel compiled and working with the Yocto cross-compilation toolchain was heinously complicated, but that's happily behind me now, and my layer has progressed to building libstt.so itself.
However, towards the end of the build in the linking phase I get this R_ARM_TLS_LE32 relocation not permitted in shared object error:
ld: bazel-out/arm-opt/bin/tensorflow/lite/kernels/libeigen_support.pic.a(eigen_support.pic.o)(.text._ZNK6tflite13eigen_support12_GLOBAL__N_122EigenThreadPoolWrapper15CurrentThreadIdEv+0x2c): R_ARM_TLS_LE32 relocation not permitted in shared object
bazel-out/arm-opt/bin/tensorflow/lite/kernels/libeigen_support.pic.a(eigen_support.pic.o): In function `tflite::eigen_support::(anonymous namespace)::EigenThreadPoolWrapper::CurrentThreadId() const':
eigen_support.cc:(.text._ZNK6tflite13eigen_support12_GLOBAL__N_122EigenThreadPoolWrapper15CurrentThreadIdEv+0x2c): dangerous relocation: unsupported relocation
I gather that R_ARM_TLS_LE32 is an ELF static Thread Local Storage relocation code, and that eigen_support is incorrectly being compiled with static code that the linker won't accept? But I'm definitely out of my depth here.
The build is being initiated with:
bazel build \
--config=monolithic \
--verbose_explanations --verbose_failures \
--action_env ANDROID_NDK_API_LEVEL=21 \
--config=android \
--config=android_arm \
--define runtime=tflite \
--cxxopt="-fpermissive" \
--cxxopt="-std=c++14" \
--cpu="${BAZEL_TARGET_CPU}" \
-c opt \
--copt="-D_GLIBCXX_USE_CXX11_ABI=0" \
--copt=-fvisibility=hidden \
--copt=-O3 \
--copt=-D_GLIBCXX_USE_C99 \
--crosstool_top=#local_config_yocto_compiler//:toolchain \
--host_crosstool_top=#bazel_tools//tools/cpp:toolchain \
--subcommands --explain=${T}/explain.log \
//native_client:libstt.so
}
eigen_support.pic.o itself is built with the following command (from the error log, formatted for ease of reading). Can you help me figure out why it's compiling wrong?
arm-oe-linux-gnueabi-gcc
-fstack-protector
-g0
-O2
-DNDEBUG
-ffunction-sections
-fdata-sections
-D_PYTHON_INCLUDE_TARGET
-MD
-MF bazel-out/arm-opt/bin/tensorflow/lite/kernels/_objs/eigen_support/eigen_support.pic.d
'-frandom-seed=bazel-out/arm-opt/bin/tensorflow/lite/kernels/_objs/eigen_support/eigen_support.pic.o'
-fPIC
-DEIGEN_MPL2_ONLY
'-DEIGEN_MAX_ALIGN_BYTES=64'
'-DEIGEN_HAS_TYPE_TRAITS=0'
-iquote .
-iquote bazel-out/arm-opt/bin
-iquote external/gemmlowp
-iquote bazel-out/arm-opt/bin/external/gemmlowp
-iquote external/eigen_archive
-iquote bazel-out/arm-opt/bin/external/eigen_archive
-iquote external/local_config_sycl
-iquote bazel-out/arm-opt/bin/external/local_config_sycl
-iquote external/ruy
-iquote bazel-out/arm-opt/bin/external/ruy
-iquote external/cpuinfo
-iquote bazel-out/arm-opt/bin/external/cpuinfo
-iquote external/clog
-iquote bazel-out/arm-opt/bin/external/clog
-Ibazel-out/arm-opt/bin/external/clog/_virtual_includes/clog
-isystem external/eigen_archive
-isystem bazel-out/arm-opt/bin/external/eigen_archive
-DTFLITE_WITH_RUY_GEMV
-w
-w
-fPIC
-D_GLIBCXX_USE_C99
-D_PYTHON_INCLUDE_TARGET
'-march=armv7-a'
'-mfpu=neon'
'-mfloat-abi=hard'
-Wl,-O1
'-Wl,--hash-style=gnu'
-Wl,--as-needed
-Wl,-z,relro,-z,now,-z,noexecstack
-fstack-protector-strong
-pie -fPIE '-D_FORTIFY_SOURCE=2'
-Wa,--noexecstack
-Wformat -Wformat-security '-Werror=format-security'
'--sysroot=/home/gbw/sc20_linux/poky/build/tmp-glibc/work/armv7ahf-neon-oe-linux-gnueabi/coqui/v0.10.0-alpha.9-r0/bazel/output_base/external/yocto_compiler/recipe-sysroot'
-O2
-Wa,--noexecstack
-fexpensive-optimizations
-frename-registers
-fomit-frame-pointer
-ftree-vectorize
-finline-functions
'-finline-limit=64'
'-Wno-error=maybe-uninitialized'
'-Wno-error=unused-result'
-fvisibility-inlines-hidden
'-std=c++14'
'-std=c++14' -fpermissive
'-std=c++14'
-DFARMHASH_NO_CXX_STRING
-Wno-sign-compare
-O3
-fno-exceptions
'-Wno-error=reorder'
-Wno-builtin-macro-redefined
'-D__DATE__="redacted"'
'-D__TIMESTAMP__="redacted"'
'-D__TIME__="redacted"'
-no-canonical-prefixes
-fno-canonical-system-headers
-c tensorflow/lite/kernels/eigen_support.cc
-o bazel-out/arm-opt/bin/tensorflow/lite/kernels/_objs/eigen_support/eigen_support.pic.o)

The issue was due to the -fPIE compiler flag being added by a bazelrc file that I didn't notice. Removing -fPIE fixed the error.

Related

Building TensorFlow: import MPI headers from outside of the Bazel root

I want to build TensorFlow 1.3 (not 1.13) on Ubuntu 16.04, with support for MPI (instead of the default gRPC). I installed the package libopenmpi-dev from the Ubuntu repos. I have supplied /usr/lib/openmpi as the MPI toolkit directory when running the configure script.
I use this command to launch the build:
$ bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
But there is a header inclusion problem:
The file tensorflow/contrib/mpi/mpi_utils.cc includes tensorflow/contrib/mpi/mpi_utils.h
This mpi_utils.h includes third_party/mpi/mpi.h
This mpi.h is a symlink to /usr/lib/openmpi/include/mpi.h
This actual mpi.h contains this line:
#include "openmpi/ompi/mpi/cxx/mpicxx.h"
And mpicxx.h is in the folder /usr/lib/openmpi/include/openmpi/ompi/mpi/cxx/, which is not in the include path.
I have "fixed" this by creating a symlink to the right folder:
$ ln -s /usr/lib/openmpi/include/openmpi third_party/mpi/openmpi
Now mpicxx.h is found, but it wants to include mpi.h, which fails since mpi.h is not in the same folder:
$ bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
WARNING: /home/arno/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
WARNING: /home/arno/tensorflow/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
INFO: Found 1 target...
ERROR: /home/arno/tensorflow/tensorflow/contrib/mpi/BUILD:60:1: C++ compilation of rule '//tensorflow/contrib/mpi:mpi_rendezvous_mgr' failed: crosstool_wrapper_driver_is_not_gcc failed: error executing command external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter ... (remaining 151 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from ./third_party/mpi/mpi.h:2673:0,
from ./tensorflow/contrib/mpi/mpi_utils.h:27,
from ./tensorflow/contrib/mpi/mpi_rendezvous_mgr.h:33,
from tensorflow/contrib/mpi/mpi_rendezvous_mgr.cc:18:
./third_party/mpi/openmpi/ompi/mpi/cxx/mpicxx.h:35:17: fatal error: mpi.h: No such file or directory
compilation terminated.
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/arno/tensorflow/tensorflow/tools/pip_package/BUILD:134:1 C++ compilation of rule '//tensorflow/contrib/mpi:mpi_rendezvous_mgr' failed: crosstool_wrapper_driver_is_not_gcc failed: error executing command external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter ... (remaining 151 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
INFO: Elapsed time: 6.668s, Critical Path: 4.98s
I have tried to manually add the headers' path to GCC's include path with this command:
$ bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package --copt='-I/usr/lib/openmpi/include'
...but then I get errors because the headers included from /usr/lib/openmpi/include/openmpi/ompi/mpi/cxx are not declared in Bazel's configuration files. And I can't declare them to Bazel since it doesn't accept absolute paths.
I can't find the right way to make this build work. I am new to Bazel, and from what I have read, the build directory should be "self-contained", that is, contain all the headers and source files necessary, but the TensorFlow repository violates this by adding symlinks to /usr/lib/... in third_party/mpi. Changing TensorFlow versions is not an option.
How can I build TensorFlow 1.3 with OpenMPI support?
Edit: adding the -s option to the Bazel build command, like suggested in the comments, gives a more detailed output, but I can't discern which compilator is used. I think these are the relevant lines:
>>>>> # //tensorflow/core/kernels:transpose_functor [action 'Compiling tensorflow/core/kernels/transpose_functor_cpu.cc']
(cd /home/arno/.cache/bazel/_bazel_arno/e7d941e3336cbc1a05a122432422a066/execroot/tensorflow && \
exec env - \
CUDA_TOOLKIT_PATH=/usr/local/cuda \
CUDNN_INSTALL_PATH=/usr/local/lib \
GCC_HOST_COMPILER_PATH=/usr/bin/gcc \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/arno/bin \
PYTHON_BIN_PATH=/usr/bin/python3 \
PYTHON_LIB_PATH=/usr/lib/python3/dist-packages \
TF_CUDA_CLANG=0 \
TF_CUDA_COMPUTE_CAPABILITIES=6.2 \
TF_CUDA_VERSION=8.0 \
TF_CUDNN_VERSION=6 \
TF_NEED_CUDA=1 \
TF_NEED_OPENCL=0 \
external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 -DNDEBUG -ffunction-sections -fdata-sections '-march=native' '-std=c++11' '-march=native' -MD -MF bazel-out/local_linux-py3-opt/bin/tensorflow/core/kernels/_objs/transpose_functor/tensorflow/core/kernels/transpose_functor_cpu.pic.d '-frandom-seed=bazel-out/local_linux-py3-opt/bin/tensorflow/core/kernels/_objs/transpose_functor/tensorflow/core/kernels/transpose_functor_cpu.pic.o' -fPIC -DEIGEN_MPL2_ONLY -DTENSORFLOW_USE_JEMALLOC -DSNAPPY -DTENSORFLOW_USE_MPI -iquote . -iquote bazel-out/local_linux-py3-opt/genfiles -iquote external/jemalloc -iquote bazel-out/local_linux-py3-opt/genfiles/external/jemalloc -iquote external/bazel_tools -iquote bazel-out/local_linux-py3-opt/genfiles/external/bazel_tools -iquote external/protobuf -iquote bazel-out/local_linux-py3-opt/genfiles/external/protobuf -iquote external/eigen_archive -iquote bazel-out/local_linux-py3-opt/genfiles/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/local_linux-py3-opt/genfiles/external/local_config_sycl -iquote external/gif_archive -iquote bazel-out/local_linux-py3-opt/genfiles/external/gif_archive -iquote external/jpeg -iquote bazel-out/local_linux-py3-opt/genfiles/external/jpeg -iquote external/com_googlesource_code_re2 -iquote bazel-out/local_linux-py3-opt/genfiles/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/local_linux-py3-opt/genfiles/external/farmhash_archive -iquote external/fft2d -iquote bazel-out/local_linux-py3-opt/genfiles/external/fft2d -iquote external/highwayhash -iquote bazel-out/local_linux-py3-opt/genfiles/external/highwayhash -iquote external/png_archive -iquote bazel-out/local_linux-py3-opt/genfiles/external/png_archive -iquote external/zlib_archive -iquote bazel-out/local_linux-py3-opt/genfiles/external/zlib_archive -iquote external/snappy -iquote bazel-out/local_linux-py3-opt/genfiles/external/snappy -iquote external/local_config_cuda -iquote bazel-out/local_linux-py3-opt/genfiles/external/local_config_cuda -isystem external/jemalloc/include -isystem bazel-out/local_linux-py3-opt/genfiles/external/jemalloc/include -isystem external/bazel_tools/tools/cpp/gcc3 -isystem external/protobuf/src -isystem bazel-out/local_linux-py3-opt/genfiles/external/protobuf/src -isystem external/eigen_archive -isystem bazel-out/local_linux-py3-opt/genfiles/external/eigen_archive -isystem external/gif_archive/lib -isystem bazel-out/local_linux-py3-opt/genfiles/external/gif_archive/lib -isystem external/farmhash_archive/src -isystem bazel-out/local_linux-py3-opt/genfiles/external/farmhash_archive/src -isystem external/png_archive -isystem bazel-out/local_linux-py3-opt/genfiles/external/png_archive -isystem external/zlib_archive -isystem bazel-out/local_linux-py3-opt/genfiles/external/zlib_archive -isystem external/local_config_cuda/cuda -isystem bazel-out/local_linux-py3-opt/genfiles/external/local_config_cuda/cuda -isystem external/local_config_cuda/cuda/cuda/include -isystem bazel-out/local_linux-py3-opt/genfiles/external/local_config_cuda/cuda/cuda/include -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare -fno-exceptions '-DGOOGLE_CUDA=1' -msse3 -pthread '-DGOOGLE_CUDA=1' -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -fno-canonical-system-headers -c tensorflow/core/kernels/transpose_functor_cpu.cc -o bazel-out/local_linux-py3-opt/bin/tensorflow/core/kernels/_objs/transpose_functor/tensorflow/core/kernels/transpose_functor_cpu.pic.o)
ERROR: /home/arno/tensorflow/tensorflow/contrib/mpi/BUILD:48:1: C++ compilation of rule '//tensorflow/contrib/mpi:mpi_utils' failed: crosstool_wrapper_driver_is_n
ot_gcc failed: error executing command external/local_config_cuda/crosstool/clang/bin/crosstool_wrapper_driver_is_not_gcc -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -fPIE -Wall -Wunused-but-set-parameter ... (remaining 131 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
In file included from ./third_party/mpi/mpi.h:2673:0,
from ./tensorflow/contrib/mpi/mpi_utils.h:27,
from tensorflow/contrib/mpi/mpi_utils.cc:18:
./third_party/mpi/openmpi/ompi/mpi/cxx/mpicxx.h:35:17: fatal error: mpi.h: No such file or directory
compilation terminated.
A workaround is to build and install MVAPICH from source (the MPI toolkit path is then /usr/local). The problem exists only with OpenMPI.

Building tensorflow from source meets error: C++ compilation of rule '#jemalloc//:jemalloc' failed

I'm attempting to build tensorflow from source on CentOS 6.2 using gcc. I updated gcc globally from 4.6.6 to 5.2.0, so that may be causing some problems. Glibc 2.17 is in a local directory, but the version of the system default Glibc is 2.12.
I get the following error:
ERROR: /usr/local/app/.cache/bazel/_bazel_mqq/51871d27dfe77ebce0294c6560736a2c/external/jemalloc/BUILD:10:1: C++ compilation of rule '#jemalloc//:jemalloc' failed: gcc failed: error executing command
(cd /usr/local/app/.cache/bazel/_bazel_mqq/51871d27dfe77ebce0294c6560736a2c/execroot/tensorflow && \
exec env - \
PATH=/data6/jimpan/env/java/jdk1.8.0_131/bin:/data6/jimpan/env/python3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/local/jdk/bin:/usr/local/jdk/jre/bin:/opt/CollabNet_Subversion/bin/:/usr/local/app/java/bin:/usr/local/app/bin \
PWD=/proc/self/cwd \
PYTHON_BIN_PATH=/data6/jimpan/env/python3/bin/python3 \
PYTHON_LIB_PATH=/data6/jimpan/env/python3/lib/python3.5/site-packages \
TF_NEED_CUDA=0 \
TF_NEED_OPENCL=0 \
/usr/local/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/local/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-mcpu=native' -MD -MF bazel-out/local-py3-opt/bin/external/jemalloc/_objs/jemalloc/external/jemalloc/src/pages.pic.d -fPIC -iquote external/jemalloc -iquote bazel-out/local-py3-opt/genfiles/external/jemalloc -iquote external/bazel_tools -iquote bazel-out/local-py3-opt/genfiles/external/bazel_tools -isystem external/jemalloc/include -isystem bazel-out/local-py3-opt/genfiles/external/jemalloc/include -isystem external/bazel_tools/tools/cpp/gcc3 -O3 -funroll-loops -D_GNU_SOURCE -D_REENTRANT -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/jemalloc/src/pages.c -o bazel-out/local-py3-opt/bin/external/jemalloc/_objs/jemalloc/external/jemalloc/src/pages.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
gcc: warning: '-mcpu=' is deprecated; use '-mtune=' or '-march=' instead
external/jemalloc/src/pages.c: In function 'je_pages_huge':
external/jemalloc/src/pages.c:203:30: error: 'MADV_HUGEPAGE' undeclared (first use in this function)
return (madvise(addr, size, MADV_HUGEPAGE) != 0);
^
external/jemalloc/src/pages.c:203:30: note: each undeclared identifier is reported only once for each function it appears in
external/jemalloc/src/pages.c: In function 'je_pages_nohuge':
external/jemalloc/src/pages.c:217:30: error: 'MADV_NOHUGEPAGE' undeclared (first use in this function)
return (madvise(addr, size, MADV_NOHUGEPAGE) != 0);
^
external/jemalloc/src/pages.c: In function 'je_pages_huge':
external/jemalloc/src/pages.c:207:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
external/jemalloc/src/pages.c: In function 'je_pages_nohuge':
external/jemalloc/src/pages.c:221:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
/usr/local/app is the $HOME path of my system.
I guess the problem lies in gcc, but I'm stuck now and don't know how to proceed.
It seems that jemalloc's build is misconfigured (it's missing MADV_NOHUGEPAGE define). I found this tensorflow issue that is related.

Build failure with CUDA, clang unknown warning option

I am building TensorFlow with bazel, CUDA supported, on AWS GPU instance. I got:
error: unknown warning option '-Wno-invalid-partial-specialization'
Build options:
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package --verbose_failures
Detailed error message:
ERROR: /home/ubuntu/.cache/bazel/_bazel_ubuntu/ad1e09741bb4109fbc70ef8216b59ee2/external/boringssl/BUILD:91:1: C++ compilation of rule '#boringssl//:crypto' failed: clang failed: error executing command
(cd /home/ubuntu/.cache/bazel/_bazel_ubuntu/ad1e09741bb4109fbc70ef8216b59ee2/execroot/tensorflow && \
exec env - \
CLANG_CUDA_COMPILER_PATH=/usr/bin/clang \
COMPUTECPP_TOOLKIT_PATH=/usr/local/computecpp \
CUDA_TOOLKIT_PATH=/usr/local/cuda \
CUDNN_INSTALL_PATH=/usr/local/cuda-8.0 \
HOST_CXX_COMPILER=/usr/bin/g++ \
HOST_C_COMPILER=/usr/bin/gcc \
PWD=/proc/self/cwd \
PYTHON_BIN_PATH=/usr/bin/python \
PYTHON_LIB_PATH=/usr/local/lib/python2.7/dist-packages \
TF_CUDA_CLANG=1 \
TF_CUDA_COMPUTE_CAPABILITIES=3.5,5.2 \
TF_CUDA_VERSION=8.0 \
TF_CUDNN_VERSION='' \
TF_NEED_CUDA=1 \
TF_NEED_OPENCL=1 \
/usr/bin/clang '-march=native' -MD -MF bazel-out/local_linux-opt/bin/external/boringssl/_objs/crypto/external/boringssl/src/crypto/sha/sha512.pic.d -iquote external/boringssl -iquote bazel-out/local_linux-opt/genfiles/external/boringssl -iquote external/bazel_tools -iquote bazel-out/local_linux-opt/genfiles/external/bazel_tools -isystem external/boringssl/src/include -isystem bazel-out/local_linux-opt/genfiles/external/boringssl/src/include -isystem external/bazel_tools/tools/cpp/gcc3 -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -fPIC -U_FORTIFY_SOURCE '-D_FORTIFY_SOURCE=1' -fstack-protector -Wall -Wno-invalid-partial-specialization -fno-omit-frame-pointer -no-canonical-prefixes -DNDEBUG -g0 -O2 -ffunction-sections -fdata-sections -Wa,--noexecstack '-D_XOPEN_SOURCE=700' -Wall -Werror '-Wformat=2' -Wsign-compare -Wmissing-field-initializers -Wwrite-strings -Wshadow -fno-common '-std=c11' -Wmissing-prototypes -Wold-style-definition -Wstrict-prototypes -c external/boringssl/src/crypto/sha/sha512.c -o bazel-out/local_linux-opt/bin/external/boringssl/_objs/crypto/external/boringssl/src/crypto/sha/sha512.pic.o): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
error: unknown warning option '-Wno-invalid-partial-specialization' [-Werror,-Wunknown-warning-option]
Target //tensorflow/tools/pip_package:build_pip_package failed to build

Issue compiling TensorFlow

I'm getting an error when compiling TensorFlow.
I get to the command:
/usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-march=native' '-std=c++0x' '-march=native' -MD -MF bazel-out/local-opt/bin/tensorflow/core/kernels/_objs/reduction_ops/tensorflow/core/kernels/reduction_ops_mean.pic.d '-frandom-seed=bazel-out/local-opt/bin/tensorflow/core/kernels/_objs/reduction_ops/tensorflow/core/kernels/reduction_ops_mean.pic.o' -fPIC -DEIGEN_MPL2_ONLY -DTENSORFLOW_USE_JEMALLOC -iquote . -iquote bazel-out/local-opt/genfiles -iquote external/bazel_tools -iquote bazel-out/local-opt/genfiles/external/bazel_tools -iquote external/eigen_archive -iquote bazel-out/local-opt/genfiles/external/eigen_archive -iquote external/local_config_sycl -iquote bazel-out/local-opt/genfiles/external/local_config_sycl -iquote external/jemalloc -iquote bazel-out/local-opt/genfiles/external/jemalloc -iquote external/protobuf -iquote bazel-out/local-opt/genfiles/external/protobuf -iquote external/gif_archive -iquote bazel-out/local-opt/genfiles/external/gif_archive -iquote external/jpeg -iquote bazel-out/local-opt/genfiles/external/jpeg -iquote external/com_googlesource_code_re2 -iquote bazel-out/local-opt/genfiles/external/com_googlesource_code_re2 -iquote external/farmhash_archive -iquote bazel-out/local-opt/genfiles/external/farmhash_archive -iquote external/highwayhash -iquote bazel-out/local-opt/genfiles/external/highwayhash -iquote external/png_archive -iquote bazel-out/local-opt/genfiles/external/png_archive -iquote external/zlib_archive -iquote bazel-out/local-opt/genfiles/external/zlib_archive -isystem external/bazel_tools/tools/cpp/gcc3 -isystem external/eigen_archive -isystem bazel-out/local-opt/genfiles/external/eigen_archive -isystem external/jemalloc/include -isystem bazel-out/local-opt/genfiles/external/jemalloc/include -isystem external/protobuf/src -isystem bazel-out/local-opt/genfiles/external/protobuf/src -isystem external/gif_archive/lib -isystem bazel-out/local-opt/genfiles/external/gif_archive/lib -isystem external/farmhash_archive/src -isystem bazel-out/local-opt/genfiles/external/farmhash_archive/src -isystem external/highwayhash -isystem bazel-out/local-opt/genfiles/external/highwayhash -isystem external/png_archive -isystem bazel-out/local-opt/genfiles/external/png_archive -isystem external/zlib_archive -isystem bazel-out/local-opt/genfiles/external/zlib_archive -DEIGEN_AVOID_STL_ARRAY -Iexternal/gemmlowp -Wno-sign-compare -fno-exceptions -pthread -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c tensorflow/core/kernels/reduction_ops_mean.cc -o bazel-out/local-opt/bin/tensorflow/core/kernels/_objs/reduction_ops/tensorflow/core/kernels/reduction_ops_mean.pic.o
But I'm getting the error:
In file included from ./tensorflow/core/kernels/reduction_ops_common.h:26:0,
from tensorflow/core/kernels/reduction_ops_mean.cc:16:
./third_party/eigen3/Eigen/Core:1:22: fatal error: Eigen/Core: No such file or directory
I've looked within Eigen/Core and it contains only one line:
> cat third_party/eigen3/Eigen/Core
#include "Eigen/Core"
Has anyone had a similar issue and managed to solve?
Thanks,
Arik
I installed Eigen3 manually and then I changed the compiler flags to contain the correct include path just before calling bazel.

Converting Makefile to CMake

I am attempting to replicate the following behaviour in CMake and need a little assistance...
I am compiling using gcc then linking using ld explicity. The original makefile carries out the following:
arm-linux-gcc -MD -Wa,-mcpu=arm7tdmi -Dgcc -c init.S
arm-linux-gcc -MD -Wall -fno-common -fshort-enums -mcpu=arm7tdmi -fno-builtin -mapcs -O2 -c serial.c
arm-linux-gcc -MD -Wall -fno-common -fshort-enums -mcpu=arm7tdmi -fno-builtin -mapcs -O2 -c timer.c
arm-linux-gcc -MD -Wall -fno-common -fshort-enums -mcpu=arm7tdmi -fno-builtin -mapcs -O2 -c amd.c
arm-linux-gcc -MD -Wall -fno-common -fshort-enums -mcpu=arm7tdmi -fno-builtin -mapcs -O2 -c intel.c
arm-linux-gcc -MD -Wall -fno-common -fshort-enums -mcpu=arm7tdmi -fno-builtin -mapcs -O2 -c at25f1024.c
arm-linux-gcc -MD -Wall -fno-common -fshort-enums -mcpu=arm7tdmi -fno-builtin -mapcs -O2 -c sst25vf020.c
arm-linux-gcc -MD -Wall -fno-common -fshort-enums -mcpu=arm7tdmi -fno-builtin -mapcs -O2 -c main.c
arm-linux-ld -q --defsym ROBASE=0x00000000 -T init.lds -o init.elf init.o serial.o timer.o amd.o intel.o at25f1024.o sst25vf020.o main.o
My CMakefileLists.txt looks like this
cmake_minimum_required(VERSION 2.8)
project(bootStage2)
#add_definitions(ROBASE
set(CMAKE_C_FLAGS "-MD -Wall -fno-common -fshort-enums -mcpu=arm7tdmi -fno-builtin -mapcs -O2 -Wl,-q -Wl,--defsym=ROBASE=0x00000000 -T ${bootStage2_SOURCE_DIR}/init.lds")
#add_definitions(ROBASE=0x00000000)
set(SRCFILES
serial.c
timer.c
amd.c
intel.c
at25f1024.c
sst25vf020.c
main.c
)
set(CMAKE_init.elf_LINK_EXECUTABLE "/usr/bob/arm920t/usr/bin/arm-linux-ld")
add_executable( init.elf ${SRCFILES})
SET_TARGET_PROPERTIES(init.elf PROPERTIES LINKER_LANGUAGE C)
add_dependencies( init.elf
assemble_S
)
add_custom_target(assemble_S
COMMAND /usr/bob/arm920t/usr/bin/arm-linux-gcc -MD -Wa,-mcpu=arm7tdmi -Dgcc -c init.S
COMMENT "Assembling init.S"
WORKING_DIRECTORY ${bootStage2_SOURCE_DIR}
If I don't define the linker exe then CMake attempts to use gcc to link and seg faults on linking.
The cmake output complains that there are no files to link against when I tell it to use arm-linux-ld, I'm sure there is a better way of doing this does anyone have any useful hints?
Cheers,
Chris.
The way we found when we have faced this problem some years ago was the following:
We replaced the link-template in cmake (we used our own linker, but it also should work with only adding arguments):
set(CMAKE_CXX_LINK_EXECUTABLE "${LINKER} ... <LINK_FLAGS> <OBJECTS> <LINK_LIBRARIES>")
set(CMAKE_C_LINK_EXECUTABLE ${CMAKE_CXX_LINK_EXECUTABLE})
The ... I omitted our custom arguments. The key here is the <>-elements which are filled in by cmake for each target to be linked.
See also here.