Bug#995867: xtensor: mipsel FTBFS (relocation truncated to fit: R_MIPS_CALL16)

Adrian Bunk <[email protected]>
Newsgroups gmane.linux.debian.alioth.science-maintainers,gmane.linux.debian.ports.mips
Message-ID <20211027082445.GA30675@localhost>
On Sat, Oct 09, 2021 at 06:17:54PM +0200, Drew Parsons wrote:
> Source: xtensor
> Followup-For: Bug #995867
> Control: retitle -1 mipsel FTBFS (relocation truncated to fit: R_MIPS_CALL16)
> 
> The problem with undefined `__umodsi3' `__udivsi3' is not easily
> reproduced.

While -march=native is kinda OKish for test-only programs that do not 
end up in the binary package, it compiles differently depending on the
hardware.

-march=native is known to have this breakage on the oldest buildds
(eberlin, mipsel-aql-0{1,2}).

> But the mipsel build failure is consistent.
> 
> The more common symptom is "relocation truncated" errors
> e.g.
> 
> [ 39%] Linking CXX executable test_xreducer
> cd /<<PKGBUILDDIR>>/obj-mipsel-linux-gnu/test && /usr/bin/cmake -E cmake_link_script CMakeFiles/test_xreducer.dir/link.txt --verbose=1
> /usr/bin/c++ -O0 -std=c++14 -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion -Wold-style-cast -Wunused-variable -ftemplate-backtrace-limit=0 -Wl,-z,relro -rdynamic CMakeFiles/test_xreducer.dir/main.cpp.o CMakeFiles/test_xreducer.dir/test_xreducer.cpp.o -o test_xreducer  -lpthread 
> cd /<<PKGBUILDDIR>>/obj-mipsel-linux-gnu/test && /usr/bin/c++  -I/<<PKGBUILDDIR>>/include -O0 -std=c++14 -Wunused-parameter -Wextra -Wreorder -Wconversion -Wsign-conversion -Wold-style-cast -Wunused-variable -ftemplate-backtrace-limit=0 -MD -MT test/CMakeFiles/test_xexpression_traits.dir/main.cpp.o -MF CMakeFiles/test_xexpression_traits.dir/main.cpp.o.d -o CMakeFiles/test_xexpression_traits.dir/main.cpp.o -c /<<PKGBUILDDIR>>/test/main.cpp
> CMakeFiles/test_xreducer.dir/test_xreducer.cpp.o: in function `__gthread_active_p()':
> test_xreducer.cpp:(.text+0x1c): relocation truncated to fit: R_MIPS_GOT16 against `__pthread_key_create@@GLIBC_2.0'
> CMakeFiles/test_xreducer.dir/test_xreducer.cpp.o: in function `xt::xreducer_features::xreducer_features()':
> test_xreducer.cpp:(.text+0x23c): relocation truncated to fit: R_MIPS_CALL16 against `_Unwind_Resume@@GCC_3.0'
> test_xreducer.cpp:(.text+0x2ac): relocation truncated to fit: R_MIPS_CALL16 against `_Unwind_Resume@@GCC_3.0'
> CMakeFiles/test_xreducer.dir/test_xreducer.cpp.o: in function `xt::_DOCTEST_ANON_FUNC_2()':
> test_xreducer.cpp:(.text+0x418): relocation truncated to fit: R_MIPS_CALL16 against `raise@@GLIBC_2.0'
> test_xreducer.cpp:(.text+0x4b0): relocation truncated to fit: R_MIPS_CALL16 against `__cxa_begin_catch@@CXXABI_1.3'
> test_xreducer.cpp:(.text+0x4e0): relocation truncated to fit: R_MIPS_CALL16 against `__cxa_end_catch@@CXXABI_1.3'
> test_xreducer.cpp:(.text+0x504): relocation truncated to fit: R_MIPS_CALL16 against `__cxa_end_catch@@CXXABI_1.3'
> test_xreducer.cpp:(.text+0x5a4): relocation truncated to fit: R_MIPS_CALL16 against `_Unwind_Resume@@GCC_3.0'
> CMakeFiles/test_xreducer.dir/test_xreducer.cpp.o: in function `xt::_DOCTEST_ANON_FUNC_4()':
> test_xreducer.cpp:(.text+0x70c): relocation truncated to fit: R_MIPS_CALL16 against `raise@@GLIBC_2.0'
> test_xreducer.cpp:(.text+0x7a4): relocation truncated to fit: R_MIPS_CALL16 against `__cxa_begin_catch@@CXXABI_1.3'
> test_xreducer.cpp:(.text+0x7d4): additional relocation overflows omitted from the output
> collect2: error: ld returned 1 exit status
> make[3]: *** [test/CMakeFiles/test_xreducer.dir/build.make:116: test/test_xreducer] Error 1
> 
> 
> "relocation truncated" together with the virtual memory exhaustion
> seen without -O0 suggests the test program is simply too large to link.
>...

-O0 code is always larger than -Os code, and especially for C++ code 
-O0 code is also larger than -O2 code.

The patch below builds for me for mipsel on eller.

cu
Adrian

--- debian/rules.old	2021-10-26 20:34:09.552672142 +0000
+++ debian/rules	2021-10-26 20:37:13.683376341 +0000
@@ -25,7 +25,7 @@
 # try to avoid exhausting virtual memory on small-memory arches
 SMALL_MEM_ARCH_LIST := armel mipsel hurd-i386
 ifneq (,$(findstring $(space)$(DEB_HOST_ARCH)$(space), $(space)$(SMALL_MEM_ARCH_LIST)$(space)))
-  BUILD_OPTIONS += -DCMAKE_CXX_FLAGS="-O0"
+  export DEB_CXXFLAGS_MAINT_APPEND = -Os -g0
 endif
 
 # test_xnpy fails on some architectures, see Bug#985699,
@@ -36,6 +36,7 @@
   BUILD_OPTIONS += -DBUILD_TEST_XNPY=OFF
 endif
 
+BUILD_OPTIONS += -Darch_native_supported=OFF
 
 %:
 	dh $@ --with sphinxdoc
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.