Hello,
I'm the maintainer of the FreeBSD port of GMP. I received a few reports
about the same compilation issue with sparc64 machines, sometimes quite
detailed like the one in the attached message. I haven't a sparc64
machine and neither the skill to fix an asm issue, so I'm forwarding the
issue to you, hoping you can help/fix it. If you need additional details
I can put you in contact with one of our users.

-- 
Alex Dupre
--- Begin Message ---
Alex,

After some digging it looks like '-fPIC -DPIC' in math/gmp/mpn fails only
for the "gcd_11.asm".  All other assembly codes in this area build OK.

* Making the gcd_11.o with no "-DPIC" option to m4 works:

root@freebsd12:/usr/ports/math/gmp/work/gmp-6.2.1/mpn # /bin/ls -ld gcd_11.asm
lrwxr-xr-x  1 root  wheel  25 Sep 24 14:59 gcd_11.asm -> 
../mpn/sparc64/gcd_11.asm
root@freebsd12:/usr/ports/math/gmp/work/gmp-6.2.1/mpn # make gcd_11.o
m4 -DOPERATION_gcd_11 `test -f 'gcd_11.asm' || echo './'`gcd_11.asm 
>tmp-gcd_11.s
cc -std=gnu99 -c -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMP -I..  
-DOPERATION_`echo gcd_11 | sed 's/_$//'`    -O2 -pipe  -fstack-protector-strong 
-fno-strict-aliasing  tmp-gcd_11.s -o gcd_11.o

* But running it within "libtool" via m4-ccas (with -fPIC -DPIC) fails:

root@freebsd12:/usr/ports/math/gmp/work/gmp-6.2.1/mpn # make gcd_11.lo
/bin/sh ../libtool --mode=compile --tag=CC ../mpn/m4-ccas --m4="m4" cc 
-std=gnu99 -c -DHAVE_CONFIG_H -I. -I..  -D__GMP_WITHIN_GMP -I..  
-DOPERATION_`echo gcd_11 | sed 's/_$//'`    -O2 -pipe  -fstack-protector-strong 
-fno-strict-aliasing  `test -f 'gcd_11.asm' || echo './'`gcd_11.asm
libtool: compile:  ../mpn/m4-ccas --m4=m4 cc -std=gnu99 -c -DHAVE_CONFIG_H -I. 
-I.. -D__GMP_WITHIN_GMP -I.. -DOPERATION_gcd_11 -O2 -pipe 
-fstack-protector-strong -fno-strict-aliasing gcd_11.asm  -fPIC -DPIC -o 
.libs/gcd_11.o
m4  -DHAVE_CONFIG_H -D__GMP_WITHIN_GMP -DOPERATION_gcd_11 -DPIC gcd_11.asm 
>tmp-gcd_11.s
 cc -std=gnu99 -c -DHAVE_CONFIG_H -I. -I.. -D__GMP_WITHIN_GMP -I.. 
-DOPERATION_gcd_11 -O2 -pipe -fstack-protector-strong -fno-strict-aliasing 
tmp-gcd_11.s -fPIC -DPIC -o .libs/gcd_11.o
tmp-gcd_11.s: Assembler messages:
tmp-gcd_11.s:210: Error: Illegal operands
tmp-gcd_11.s:211: Error: Illegal operands
tmp-gcd_11.s:212: Error: Illegal operands

The m4-generated assembly codes above (w/ w/out PIC) differ in these lines:

root@freebsd12:/usr/ports/math/gmp/work/gmp-6.2.1/mpn # diff tmp-gcd_11.s.noPIC 
tmp-gcd_11.s
206,209c206,212
<       sethi   %h44(ctz_table), %o5
<       or      %o5, %m44(ctz_table), %o5
<       sllx    %o5, 12, %o5
<       or      %o5, %l44(ctz_table), %o5
---
>       rd      %pc, %o5
>       sethi   %hi(_GLOBAL_OFFSET_TABLE_+4), %g4
>       add     %g4, %lo(_GLOBAL_OFFSET_TABLE_+8), %g4
>       add     %o5, %g4, %g4
>       sethi   %gdop_hix22(ctz_table), %o5
>       xor     %o5, %gdop_lox10(ctz_table), %o5
>       ldx     [%g4 + %o5], %o5, %gdop(ctz_table)

Omitting the -fPIC -DPIC for the "m4" step but including it in the "cc" step of
m4-ccas goes through..

I saw this report of a similar issue under OpenBSD:
https://openbsdmailbox.blogspot.com/2020/02/re-update-develgmp-needs-testing-on_47.html

-arun

On Mon, Sep 20, 2021 at 09:20:52AM +0200, Alex Dupre wrote:
> On 20/09/21 04:34, Arun Venkataraman wrote:
> > I have installed FreeBSD 12.2 Sparc64 on a faithful old Sun Ultra 5, and
> > currently am trying to build packages from source via the Ports Collection
> > (no binary packages are available for this arch).  The math/gmp dependency
> > build fails with the assembler complaining about Illegal Operands per the
> > attached "make" output.  (FWIW I did also try setting MAKE_JOBS_UNSAFE=yes).
> 
> I guess you enabled the CPU_OPTS option that is disabled by default.
> 
> -- 
> Alex Dupre

-- 
Arun Venkataraman <a...@naic.edu>
IT Manager, Arecibo Observatory/HC03 Box 53995/Arecibo, PR 00612

--- End Message ---
_______________________________________________
gmp-bugs mailing list
gmp-bugs@gmplib.org
https://gmplib.org/mailman/listinfo/gmp-bugs

Reply via email to