Created attachment 847690 [details] emerge --info I've found the problem related to GCC LTO optimization for GMP for ARM aarch64 under QEMU with ARM Neoverse-N1 virt-4.2 (Oracle Cloud) and ARM virt-7.2 (Apple M1) both running the latest Gentoo with gmp-6.2.1-r5 compiled by both gcc version 11.3.1 20221209 and gcc version 12.2.1 20221231. To reproduce: 1. Compile GMP with LTO optimization -- compiles OK 2. Try to compile iproute2-6.1.0 or cmake-3.25.1 -- compilation hangs during the process Disabling LTO optimization for GMP solves the problem.
- Please share the full iproute2 log up until the point it hangs, ditto CMake. - If you take a fresh stage3 then compile GMP with LTO, is that sufficient to then make building iproute2 or CMake hang?
Created attachment 847840 [details] portage_all_installed
That's my bug report to gmp-bugs at gmplib.org: --- report starts --- Let me try to reproduce the whole process with original GMP source: 1. I've downloaded https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz 2. Exported my CFLAGS with LTO enabled: export COMMON_FLAGS="-O3 -march=native -mcpu=native -pipe -funroll-loops \ -fomit-frame-pointer -fforce-addr -ftracer -fno-stack-protector -flto" export CFLAGS="${COMMON_FLAGS}" export CXXFLAGS="${COMMON_FLAGS}" 3. Configure, make & install GMP with gcc version 12.2.1 20221231: ./configure --prefix=/usr/ --libdir=/usr/lib64/ --enable-cxx make -j4 make install 4. Cloned iproute2: git clone git://git.kernel.org/pub/scm/network/iproute2/iproute2.git 5. Try to compile iproute2 with hang as follows: CC tc_cbq.o CC tc_estimator.o ... hangs here ... 6. Commented out the following piece of iproute2 code in tc/tc_estimator.c: // if (A/(-log(w)) > time_const) // break; 7. Continued to compile iproute2 and compilation went OK Same error was reproduced with current https://gmplib.org/repo/gmp-6.2/ Switching off LTO let iproute2 compile OK --- report ends --- AFAIK that's not only causing problems with iproute2/cmake but with any other packages (e.g.: dev-libs/liblinear) using some portion of math of GMP lib. My current Gentoo is based on stage3-arm64-openrc-20230101T231658Z, all others packages are up to date, please check the attached `portage_all_installed` for all packages with their current versions. As I retried to recompile iproute2 for collecting all the logs, I've found out that it started to compile OK. However other packages (liblinear & cmake) hang during the compilation. Please find `liblinear.emerge.log` & `cmake.emerge.log` attached.
Created attachment 847842 [details] liblinear.emerge.log
Created attachment 847844 [details] cmake.emerge.log
As I've just researched iproute2 started to compile since I had upgraded dev-libs/mpfr from 4.1.1_p1 to 4.2.0, however dev-libs/liblinear-243 and dev-util/cmake-3.25.1 still hang
As Torbjörn Granlund from gmplib.org answered: --- Unfortunately, I don't have time to isolate this problem. I long shot would be to disable assembly in the GMP build (by means of .../configure --disable-assembly). The arm64 asm in GMP 6.2.1 followed the ABI docs of the time, which turned out to cause problems at least in some environments. --- However enabling --disable-assembly didn't solve the problem.
(In reply to Sam James from comment #1) > - If you take a fresh stage3 then compile GMP with LTO, is that sufficient > to then make building iproute2 or CMake hang? What about this? (You would do it in a chroot in /tmp or something.) Also, please try minimise precisely which CFLAGS cause it. Is it just "-O3 -flto", for example?
Sorry, I was mistaken so further research showed that `configure --disable-assembly` solves the problem.
(In reply to Sam James from comment #8) > (In reply to Sam James from comment #1) > > - If you take a fresh stage3 then compile GMP with LTO, is that sufficient > > to then make building iproute2 or CMake hang? > > What about this? (You would do it in a chroot in /tmp or something.) > > Also, please try minimise precisely which CFLAGS cause it. Is it just "-O3 > -flto", for example? Pure CFLAGS `-O2 -flto` and `-Os -flto` for GMP leads to hang with liblinear's compilation, except if GMP is configured with `--disable-assembly`
See also https://gmplib.org/list-archives/gmp-bugs/2020-December/004981.html.
The bug has been referenced in the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=570a3e436ff2a642f9470809fdc8ef63ce560494 commit 570a3e436ff2a642f9470809fdc8ef63ce560494 Author: Sam James <sam@gentoo.org> AuthorDate: 2023-05-07 23:53:29 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2023-05-07 23:53:49 +0000 dev-libs/gmp: strip-flags & filter-lto for miscompilation Miscompiled on arm64 with LTO at least. strip-flags as well because gmp is so brittle (see e.g. the past configure mess). Bug: https://bugs.gentoo.org/889948 Signed-off-by: Sam James <sam@gentoo.org> dev-libs/gmp/gmp-6.2.1-r2.ebuild | 5 +++++ dev-libs/gmp/gmp-6.2.1-r5.ebuild | 5 +++++ 2 files changed, 10 insertions(+)
I think I can hit this with -O2 -flto and -O3 -flto with GCC 12/13/14. I get an ICE with 'echo hi | aarch64-unknown-linux-gnu-gcc -E -dM -': ``` $ echo hi | aarch64-unknown-linux-gnu-gcc -E -dM - <built-in>: internal compiler error: in real_to_decimal_for_mode, at real.cc:1899 0xe036af real_to_decimal_for_mode(char*, real_value const*, unsigned long, unsigned long, int, machine_mode) /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/real.cc:1899 0x80cdeb builtin_define_with_hex_fp_value /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/c-family/c-cppbuiltin.cc:1877 0x80e8bf builtin_define_float_constants /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/c-family/c-cppbuiltin.cc:277 0x810103 c_cpp_builtins(cpp_reader*) /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/c-family/c-cppbuiltin.cc:1245 0x82f853 c_finish_options /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/c-family/c-opts.cc:1489 0x831fb3 c_common_init() /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/c-family/c-opts.cc:1226 0x708243 lang_dependent_init /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/toplev.cc:1820 0x708243 do_compile /usr/src/debug/sys-devel/gcc-14.0.0.9999/gcc-14.0.0.9999/gcc/toplev.cc:2115 Please submit a full bug report, with preprocessed source (by using -freport-bug). Please include the complete backtrace with any bug report. See <https://bugs.gentoo.org/> for instructions. ``` and 'echo hi | aarch64-unknown-linux-gnu-gfortran -Werror -xf77 -v -c -' hangs for me.
(In reply to gluker from comment #7) > As Torbjörn Granlund from gmplib.org answered: > For the record, this was at https://gmplib.org/list-archives/gmp-bugs/2023-January/005223.html.