mold
mold copied to clipboard
Fails to link on alpha: relocation truncated to fit: GPREL16
Hi, I am trying to build natively on alpha, but the final pass fails to link, with the following output.
This is using gcc 13.2.1, binutils 2.41, glibc 2.38.
After running through c++filt
:
CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o: in function `std::basic_string_view<char, std::char_traits<char> > mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)':
(.text._ZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_m[std::basic_string_view<char, std::char_traits<char> > mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)]+0xc4): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)::prefixes' defined in .sbss._ZGVZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_mE8prefixes[guard variable for mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)::prefixes] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_m[std::basic_string_view<char, std::char_traits<char> > mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)]+0x130): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)::prefixes' defined in .sbss._ZGVZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_mE8prefixes_0[guard variable for mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)::prefixes] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o: in function `void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)':
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x1c): relocation truncated to fit: GPREL16 against symbol `mold::Counter::enabled' defined in .sbss._ZN4mold7Counter7enabledE[mold::Counter::enabled] section in CMakeFiles/mold.dir/elf/cmdline.cc.X86_64.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x50): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::defined' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE7defined[guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::defined] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x74): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::undefined' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE9undefined[guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::undefined] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x28c): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::alloc' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE5alloc[guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::alloc] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x2a0): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::nonalloc' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE8nonalloc[guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::nonalloc] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x490): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::comdats' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE7comdats[guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::comdats] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x4b0): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::removed_comdats' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE15removed_comdats[guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::removed_comdats] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x51c): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::num_cies' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE8num_cies[guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::num_cies] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)]+0x53c): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
I offer free shell access to the machine I reproduced this on if it will help debugging the problem.
Ah, nice, so you have a physical Alpha machine. Let me try to debug it. I'll send you an email for a remote access.
Ah, nice, so you have a physical Alpha machine. Let me try to debug it. I'll send you an email for a remote access.
Sure thing thanks! You should be able to log in as g-ruiu
now. I've preinstalled all the deps for mold as well. Let me know if there's anything else you need!
When I tried to build mold on your Alpha machine, the last link step failed probably due to the out-of-memory error of the GNU linker. Do you mind if I ask how you built mold?
When I tried to build mold on your Alpha machine, the last link step failed probably due to the out-of-memory error of the GNU linker. Do you mind if I ask how you built mold?
What CFLAGS were you using? I have 10G of swap set up but after testing it myself I didn't even go through the 2G of physical RAM.
Here is a tarball of the build directory. Here's a minimal reproducer to trigger the error, from inside mold-2.4.0/work/mold-2.4.0_build
:
$ time $(cat ../../temp/build.log | grep "create_symlink" | tail -n 1 | cut -d "&" -f 3)
CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o: in function `std::basic_string_view<char, std::char_traits<char> > mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)':
(.text._ZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_m[_ZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_m]+0xc4): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)::prefixes' defined in .sbss._ZGVZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_mE8prefixes[_ZGVZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_mE8prefixes] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_m[_ZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_m]+0x130): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::get_output_name<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&, std::basic_string_view<char, std::char_traits<char> >, unsigned long)::prefixes' defined in .sbss._ZGVZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_mE8prefixes_0[_ZGVZN4mold3elf15get_output_nameINS0_6RV64BEEEESt17basic_string_viewIcSt11char_traitsIcEERNS0_7ContextIT_EES6_mE8prefixes_0] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o: in function `void mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)':
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x1c): relocation truncated to fit: GPREL16 against symbol `mold::Counter::enabled' defined in .sbss._ZN4mold7Counter7enabledE[_ZN4mold7Counter7enabledE] section in CMakeFiles/mold.dir/elf/cmdline.cc.X86_64.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x50): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::defined' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE7defined[_ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE7defined] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x74): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::undefined' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE9undefined[_ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE9undefined] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x28c): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::alloc' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE5alloc[_ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE5alloc] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x2a0): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::nonalloc' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE8nonalloc[_ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE8nonalloc] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x490): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::comdats' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE7comdats[_ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE7comdats] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x4b0): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::removed_comdats' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE15removed_comdats[_ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE15removed_comdats] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x51c): relocation truncated to fit: GPREL16 against symbol `guard variable for mold::elf::show_stats<mold::elf::RV64BE>(mold::elf::Context<mold::elf::RV64BE>&)::num_cies' defined in .sbss._ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE8num_cies[_ZGVZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EEE8num_cies] section in CMakeFiles/mold.dir/elf/passes.cc.RV64BE.cc.o
(.text._ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE[_ZN4mold3elf10show_statsINS0_6RV64BEEEEvRNS0_7ContextIT_EE]+0x53c): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
real 0m36.050s
user 0m12.340s
sys 0m4.609s
If you want to build from scratch with these settings, I think the following command should modify the build files:
find . -type f | while read line ; do sed -i "s#/var/tmp/portage/sys-devel/mold-2.4.0#${HOME}/mold-2.4.0#g" "${line}" ; done
Let me know if that is enough info to reproduce for you?