Miscompilation on arm64 with GCC LTO

Niels Möller nisse at lysator.liu.se
Wed May 10 08:14:22 CEST 2023

Sam James <sam at gentoo.org> writes:

> Note that Jannik identified the bad commit [0] as 18082:c5d0fcb06969 [4].
> [0] https://gmplib.org/list-archives/gmp-bugs/2020-December/004981.html
> [1] https://gmplib.org/list-archives/gmp-bugs/2023-January/005223.html
> [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109765
> [4] https://gmplib.org/repo/gmp/rev/c5d0fcb06969

It looks like that commit changes

  adrp	x1, approx_tab
  add	x1, x1, :lo12:approx_tab


  adrp	x1, :got:approx_tab
  ldr	x1, [x1, #:got_lo12:approx_tab]

and only when PIC is defined (via LEA_HI and LEA_LO m4 macros). I
haven't double checked what assembly files actually look like after
preprocessing, though.

And something similar for __gmp_binvert_limb_table.

But I have no clue about the arm64 abi. Is PIC defined in the failing
build, or should it be?


Niels Möller. PGP key CB4962D070D77D7FCB8BA36271D8F1FF368C6677.
Internet email is subject to wholesale government surveillance.

More information about the gmp-bugs mailing list