patchelf
patchelf copied to clipboard
[RISCV] Error on 'make check' - relocation truncated to fit: R_RISCV_RVC_LUI against `__TMC_LIST__'
Describe the bug
Short description
When i try to build the patchelf on riscv architecture - got the error on step make check:
...
fpic -g -O2 -MT too-many-strtab.o -MD -MP -MF .deps/too-many-strtab.Tpo -c -o too-many-strtab.o too-many-strtab.c
mv -f .deps/too-many-strtab.Tpo .deps/too-many-strtab.Po
gcc -g -O2 -c -o too-many-strtab2.o too-many-strtab2.s
gcc -fpic -g -O2 -o too-many-strtab too-many-strtab.o too-many-strtab2.o
gcc -fpic -g -O2 -Wl,--disable-new-dtags -shared -L. -o libbar-scoped.so bar.o
gcc -fpic -g -O2 -Wl,--disable-new-dtags -shared -L. -o libfoo-scoped.so foo.o -lbar-scoped
gcc -fpic -g -O2 -Wl,--disable-new-dtags -Wl,-rpath-link=. -L. -o main-scoped main.o -lfoo-scoped
cat main.c > big-dynstr.c
i=1; while [ $i -le 2000 ]; do echo "void f$i(void) { };"; i=$(($i + 1)); done >> big-dynstr.c
gcc -DPACKAGE_NAME=\"patchelf\" -DPACKAGE_TARNAME=\"patchelf\" -DPACKAGE_VERSION=\"0.17.2\" -DPACKAGE_STRING=\"patchelf\ 0.17.2\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"patchelf\" -DVERSION=\"0.17.2\" -DHAVE_CXX17=1 -I. -fpic -g -O2 -MT big-dynstr.o -MD -MP -MF .deps/big-dynstr.Tpo -c -o big-dynstr.o big-dynstr.c
mv -f .deps/big-dynstr.Tpo .deps/big-dynstr.Po
gcc -fpic -g -O2 -Wl,--disable-new-dtags -Wl,-rpath-link=. -L. -o big-dynstr big-dynstr.o -lfoo
/usr/lib64/gcc/riscv64-tizen-linux-gnu/13.1.0/crtbegin.o: in function `deregister_tm_clones':
crtstuff.c:(.text+0x0): relocation truncated to fit: R_RISCV_RVC_LUI against `__TMC_LIST__'
collect2: error: ld returned 1 exit status
gmake[2]: *** [Makefile:715: big-dynstr] Error 1
gmake[2]: Leaving directory '/root/tmp/pip-install-uzb_vs5r/patchelf_99eaaac418c5450182717d67c17e7582/src/patchelf-upstream/tests'
gmake[1]: *** [Makefile:1453: check-am] Error 2
gmake[1]: Leaving directory '/root/tmp/pip-install-uzb_vs5r/patchelf_99eaaac418c5450182717d67c17e7582/src/patchelf-upstream/tests'
gmake: *** [Makefile:447: check-recursive] Error 1
ninja: build stopped: subcommand failed.
Due to this build starts from 'pip' i can't avoid these tests.
The bug is very similar to the https://github.com/riscvarchive/riscv-binutils-gdb/issues/144
Steps To Reproduce
Just try to build on RiscV or do pip install patchelf
Versions:
root:~/patchelf-master> python3 -V
Python 3.12.0
root:~/patchelf-master> gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/riscv64-tizen-linux-gnu/13.1.0/lto-wrapper
Target: riscv64-tizen-linux-gnu
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++,fortran --enable-checking=release --disable-libssp --disable-bootstrap --disable-libvtv --enable-plugin --disable-libcc1 --disable-libgcj --with-slibdir=/usr/lib64 --with-system-zlib --with-sysroot=/ --enable-__cxa_atexit --enable-libstdcxx-allocator=new --enable-version-specific-runtime-libs --enable-linker-build-id --without-system-libunwind --enable-threads=posix --disable-multilib --disable-cet --enable-lto --enable-libcc1 --enable-libgfortran --with-arch=rv64gc --with-abi=lp64d --with-bugurl=http://bugs.tizen.org/ --with-pkgversion='Tizen GCC 13.1.0 20230426 1.21' --target=riscv64-tizen-linux-gnu --host=riscv64-tizen-linux-gnu --build=riscv64-tizen-linux-gnu
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.1.0 (Tizen GCC 13.1.0 20230426 1.21)
Patch-elf: master 7c2f768
Possible fix
To fix it i have added -Wl,--no-relax. in tests/Makefile.in:681. But i'm not sure what about other architectures.
LDFLAGS_local = -Wl,--disable-new-dtags -Wl,-rpath-link=. -Wl,--no-relax -L. $(AM_LDFLAGS)
LDFLAGS_sharedlib = -Wl,--no-relax -Wl,--disable-new-dtags -shared -L. $(AM_LDFLAGS)