Reputation: 4132
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)
Upvotes: 1
Views: 835
Reputation: 4132
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.
Upvotes: 0