[petsc-dev] GCC8 Fortran length changes from int to size_t

Jed Brown jed at jedbrown.org
Wed May 2 17:41:23 CDT 2018


Huh?  Or a test that uses enough arguments to not pass in registers if
you insist on creating a test failure.  Alternatively, do what the
documentation says.  If you doubt the documentation, we can check the
assembly.

$ cat stringarg.f                                                                                                                                     
      subroutine stringarg(s)                                                                                                                                                                 
      character(*) s
      end

With gfortran-7.3.1:

0000000000000000 <stringarg_> push   rbp                                                                                                                                                      
0000000000000001 <stringarg_+0x1> mov    rbp,rsp
0000000000000004 <stringarg_+0x4> mov    QWORD PTR [rbp-0x8],rdi
0000000000000008 <stringarg_+0x8> mov    DWORD PTR [rbp-0xc],esi
000000000000000b <stringarg_+0xb> mov    eax,DWORD PTR [rbp-0xc]
000000000000000e <stringarg_+0xe> cdqe   
0000000000000010 <stringarg_+0x10> mov    rdx,rax
0000000000000013 <stringarg_+0x13> mov    ecx,0x0
0000000000000018 <stringarg_+0x18> pop    rbp
0000000000000019 <stringarg_+0x19> ret    


Note the use of esi instead of rsi for the integer argument:

0000000000000008 <stringarg_+0x8> mov    DWORD PTR [rbp-0xc],esi

Presumably if you build with gfortran-8.1, the analogous line will use
rsi.

Satish Balay <balay at mcs.anl.gov> writes:

> So we need a 64bit arm with gcc8 - for this testcase failure?
>
> Satish
>
> On Wed, 2 May 2018, Jed Brown wrote:
>
>> On x86-64 Linux, the first six integer arguments are passed in registers
>> (rdi, rsi, rdx, rcx, r8, r9).  Multiple smaller integers are not packed
>> into these registers, but they are accessed as 32-bit (edi, ...).
>> 
>> Satish Balay <balay at mcs.anl.gov> writes:
>> 
>> > Well it should atleast bite for functions that have 2 char arguments. Perhaps
>> > none of the tests are using these routines..
>> >
>> > Satish
>> >
>> > On Wed, 2 May 2018, Jed Brown wrote:
>> >
>> >> Is the length passed in registers and incorrectly using the lower half
>> >> of the register provides the int part?
>> >> 
>> >> Satish Balay <balay at mcs.anl.gov> writes:
>> >> 
>> >> > hm - I have gfortran-8 on my laptop - but haven't seen any testsuite regressions due to this change.
>> >> >
>> >> > Satish
>> >> >
>> >> > On Wed, 2 May 2018, Jed Brown wrote:
>> >> >
>> >> >> See Fortran Language Issues.
>> >> >> 
>> >> >>   https://gcc.gnu.org/gcc-8/porting_to.html
>> >> >> 
>> >> >> We'll have to test for this (probably compiler version) and change the
>> >> >> PETSC_MIXED_LEN / PETSC_END_LEN to use size_t instead of int.
>> >> >> 
>> >> 
>> 


More information about the petsc-dev mailing list