Re: qtbase-5.9.6p1 fails to build on -stable/loongson

2018-12-23 Thread Xiyue Deng

Jeremie Courreges-Anglas writes:

> On Fri, Dec 21 2018, Xiyue Deng  wrote:
>
> [...]
>
>>> Index: elf64-mips.c
>>> ===
>>> RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c,v
>>> retrieving revision 1.1.1.1
>>> diff -u -p -p -u -r1.1.1.1 elf64-mips.c
>>> --- elf64-mips.c24 Apr 2011 20:14:42 -  1.1.1.1
>>> +++ elf64-mips.c19 Dec 2018 17:22:29 -
>>> @@ -2252,6 +2252,8 @@ mips_elf64_rtype_to_howto (unsigned int 
>>> return _elf64_howto_table_rel[r_type - R_MIPS16_min];
>>> }
>>>BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
>>> +  if (!(r_type < (unsigned int) R_MIPS_max))
>>> + fprintf(stderr, "BFD:%s: relocation type %u\n", __func__, r_type);
>>>if (rela_p)
>>> return _elf64_howto_table_rela[r_type];
>>>else
>>
>> With the patch from Jeremie applied, the error message shows exact type
>> of relocation:
>>
>>
>> --8<--
>> /usr/bin/ld: BFD 2.17 assertion fail 
>> /usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254
>> BFD:mips_elf64_rtype_to_howto: relocation type 248
>> /usr/bin/ld: BFD 2.17 internal error, aborting at 
>> /usr/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c line 445 in bfd_get_reloc_size
>>
>> /usr/bin/ld: Please report this bug.
>>
>> clang-6.0: error: linker command failed with exit code 1 (use -v to see 
>> invocation)
>> -->8--
>>
>> Hope this is helpful for MIPS people to properly fix this.
>
> This is consistent with visa@'s analysis.  He committed a fix, which
> should arrive on your local CVS mirror soonish:
>
> --8<--
> CVSROOT:/cvs
> Module name:src
> Changes by: v...@cvs.openbsd.org2018/12/22 03:31:01
>
> Modified files:
> gnu/usr.bin/binutils-2.17/bfd: elf64-mips.c
>
> Log message:
> Add support for R_MIPS_PC32 relocation. It is needed for linking code
> that has been compiled using clang.
>
> The added code is based on old binutils code from year 2000.
>
> Prodded by and OK jca@, OK kettenis@ guenther@
> -->8--
>
> You could backport it to -stable, but better use -current. ;)

Fantastic! Will try on -stable first as I'm half-way through building
mu4e :D

BTW, has -current on loongson switched from gcc 4.x to clang as well?
If so will definitely try that out and hopefully help making 6.5 better
for loongson.

-- 
manphiz


signature.asc
Description: PGP signature


Re: qtbase-5.9.6p1 fails to build on -stable/loongson

2018-12-22 Thread Jeremie Courreges-Anglas
On Fri, Dec 21 2018, Xiyue Deng  wrote:

[...]

>> Index: elf64-mips.c
>> ===
>> RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c,v
>> retrieving revision 1.1.1.1
>> diff -u -p -p -u -r1.1.1.1 elf64-mips.c
>> --- elf64-mips.c 24 Apr 2011 20:14:42 -  1.1.1.1
>> +++ elf64-mips.c 19 Dec 2018 17:22:29 -
>> @@ -2252,6 +2252,8 @@ mips_elf64_rtype_to_howto (unsigned int 
>>  return _elf64_howto_table_rel[r_type - R_MIPS16_min];
>>  }
>>BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
>> +  if (!(r_type < (unsigned int) R_MIPS_max))
>> +  fprintf(stderr, "BFD:%s: relocation type %u\n", __func__, r_type);
>>if (rela_p)
>>  return _elf64_howto_table_rela[r_type];
>>else
>
> With the patch from Jeremie applied, the error message shows exact type
> of relocation:
>
>
> --8<--
> /usr/bin/ld: BFD 2.17 assertion fail 
> /usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254
> BFD:mips_elf64_rtype_to_howto: relocation type 248
> /usr/bin/ld: BFD 2.17 internal error, aborting at 
> /usr/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c line 445 in bfd_get_reloc_size
>
> /usr/bin/ld: Please report this bug.
>
> clang-6.0: error: linker command failed with exit code 1 (use -v to see 
> invocation)
> -->8--
>
> Hope this is helpful for MIPS people to properly fix this.

This is consistent with visa@'s analysis.  He committed a fix, which
should arrive on your local CVS mirror soonish:

--8<--
CVSROOT:/cvs
Module name:src
Changes by: v...@cvs.openbsd.org2018/12/22 03:31:01

Modified files:
gnu/usr.bin/binutils-2.17/bfd: elf64-mips.c

Log message:
Add support for R_MIPS_PC32 relocation. It is needed for linking code
that has been compiled using clang.

The added code is based on old binutils code from year 2000.

Prodded by and OK jca@, OK kettenis@ guenther@
-->8--

You could backport it to -stable, but better use -current. ;)

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: qtbase-5.9.6p1 fails to build on -stable/loongson

2018-12-21 Thread Xiyue Deng

Jeremie Courreges-Anglas writes:

> On Wed, Dec 19 2018, Xiyue Deng  wrote:
>> Xiyue Deng writes:
>>
>>> Hi,
>>>
>>> As title suggests, qtbase on -stable fails to build.  Relevant part from
>>> build log:
>>>
>>> /usr/bin/ld: BFD 2.17 assertion fail 
>>> /usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254
>>> /usr/bin/ld: BFD 2.17 internal error, aborting at 
>>> /usr/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c line 445 in 
>>> bfd_get_reloc_size
>>>
>>> /usr/bin/ld: Please report this bug.
>>>
>>> clang-6.0: error: linker command failed with exit code 1 (use -v to see 
>>> invocation)
>>>
>>> Full build log is also attached.  Please advice on how to fix.  Thanks!
>>
>> Hi,
>>
>> Any updates on this issue?
>
> Your initial mail was two/three days ago.  I would not expect someone to
> jump on obscure binutils problems on a non-mainstream arch.  ;)
>
> Now, you got me curious.  Tentative analysis below, take with a grain of
> salt.
>
> Here's the code at
> /usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254:
> --8<--
> /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
>
> static reloc_howto_type *
> mips_elf64_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
> {
>   switch (r_type)
> {
> case R_MIPS_GNU_VTINHERIT:
>   return _mips_gnu_vtinherit_howto;
> case R_MIPS_GNU_VTENTRY:
>   return _mips_gnu_vtentry_howto;
> case R_MIPS_GNU_REL16_S2:
>   if (rela_p)
>   return _mips_gnu_rela16_s2;
>   else
>   return _mips_gnu_rel16_s2;
> default:
>   if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
>   {
> if (rela_p)
>   return _elf64_howto_table_rela[r_type - R_MIPS16_min];
> else
>   return _elf64_howto_table_rel[r_type - R_MIPS16_min];
>   }
>   BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
>   if (rela_p)
>   return _elf64_howto_table_rela[r_type];
>   else
>   return _elf64_howto_table_rel[r_type];
>   break;
> }
> }
> -->8--
>
> As far as binutils-2.17 know, R_MIPS_max is 51:
>
>   include/elf/mips.h
>   90:  FAKE_RELOC (R_MIPS_max, 51)
>
> But llvm/clang adds support for additional relocation types, at least:
> --8<--
> ELF_RELOC(R_MIPS_PC21_S2,60)
> ELF_RELOC(R_MIPS_PC26_S2,61)
> ELF_RELOC(R_MIPS_PC18_S3,62)
> ELF_RELOC(R_MIPS_PC19_S2,63)
> ELF_RELOC(R_MIPS_PCHI16, 64)
> ELF_RELOC(R_MIPS_PCLO16, 65)
> -->8--
> listed in /usr/src/gnu/llvm/include/llvm/BinaryFormat/ELFRelocs/Mips.def
> for base clang.
>
> To make llvm more useful on mips64 one should either try to somehow
> avoid using those relocations, or add support for those relocations to
> binutils-2.17.
>
> You could try applying this diff to see which relocation triggers the
> assert.
>
> My two cents,
>
>
> Index: elf64-mips.c
> ===
> RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c,v
> retrieving revision 1.1.1.1
> diff -u -p -p -u -r1.1.1.1 elf64-mips.c
> --- elf64-mips.c  24 Apr 2011 20:14:42 -  1.1.1.1
> +++ elf64-mips.c  19 Dec 2018 17:22:29 -
> @@ -2252,6 +2252,8 @@ mips_elf64_rtype_to_howto (unsigned int 
>   return _elf64_howto_table_rel[r_type - R_MIPS16_min];
>   }
>BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
> +  if (!(r_type < (unsigned int) R_MIPS_max))
> +   fprintf(stderr, "BFD:%s: relocation type %u\n", __func__, r_type);
>if (rela_p)
>   return _elf64_howto_table_rela[r_type];
>else

With the patch from Jeremie applied, the error message shows exact type
of relocation:


--8<--
/usr/bin/ld: BFD 2.17 assertion fail 
/usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254
   
BFD:mips_elf64_rtype_to_howto: relocation type 248
/usr/bin/ld: BFD 2.17 internal error, aborting at 
/usr/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c line 445 in bfd_get_reloc_size   
  

/usr/bin/ld: Please report this bug.

clang-6.0: error: linker command failed with exit code 1 (use -v to see 
invocation)
-->8--

Hope this is helpful for MIPS people to properly fix this.

-- 
manphiz


signature.asc
Description: PGP signature


Re: qtbase-5.9.6p1 fails to build on -stable/loongson

2018-12-19 Thread Xiyue Deng


Jeremie Courreges-Anglas writes:

> On Wed, Dec 19 2018, Xiyue Deng  wrote:
>> Xiyue Deng writes:
>>
>>> Hi,
>>>
>>> As title suggests, qtbase on -stable fails to build.  Relevant part from
>>> build log:
>>>
>>> /usr/bin/ld: BFD 2.17 assertion fail 
>>> /usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254
>>> /usr/bin/ld: BFD 2.17 internal error, aborting at 
>>> /usr/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c line 445 in 
>>> bfd_get_reloc_size
>>>
>>> /usr/bin/ld: Please report this bug.
>>>
>>> clang-6.0: error: linker command failed with exit code 1 (use -v to see 
>>> invocation)
>>>
>>> Full build log is also attached.  Please advice on how to fix.  Thanks!
>>
>> Hi,
>>
>> Any updates on this issue?
>
> Your initial mail was two/three days ago.  I would not expect someone to
> jump on obscure binutils problems on a non-mainstream arch.  ;)
>
> Now, you got me curious.

Sorry to sound pushy here, but somehow it worked :D

> Tentative analysis below, take with a grain of
> salt.
>
> Here's the code at
> /usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254:
> --8<--
> /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */
>
> static reloc_howto_type *
> mips_elf64_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
> {
>   switch (r_type)
> {
> case R_MIPS_GNU_VTINHERIT:
>   return _mips_gnu_vtinherit_howto;
> case R_MIPS_GNU_VTENTRY:
>   return _mips_gnu_vtentry_howto;
> case R_MIPS_GNU_REL16_S2:
>   if (rela_p)
>   return _mips_gnu_rela16_s2;
>   else
>   return _mips_gnu_rel16_s2;
> default:
>   if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
>   {
> if (rela_p)
>   return _elf64_howto_table_rela[r_type - R_MIPS16_min];
> else
>   return _elf64_howto_table_rel[r_type - R_MIPS16_min];
>   }
>   BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
>   if (rela_p)
>   return _elf64_howto_table_rela[r_type];
>   else
>   return _elf64_howto_table_rel[r_type];
>   break;
> }
> }
> -->8--
>
> As far as binutils-2.17 know, R_MIPS_max is 51:
>
>   include/elf/mips.h
>   90:  FAKE_RELOC (R_MIPS_max, 51)
>
> But llvm/clang adds support for additional relocation types, at least:
> --8<--
> ELF_RELOC(R_MIPS_PC21_S2,60)
> ELF_RELOC(R_MIPS_PC26_S2,61)
> ELF_RELOC(R_MIPS_PC18_S3,62)
> ELF_RELOC(R_MIPS_PC19_S2,63)
> ELF_RELOC(R_MIPS_PCHI16, 64)
> ELF_RELOC(R_MIPS_PCLO16, 65)
> -->8--
> listed in /usr/src/gnu/llvm/include/llvm/BinaryFormat/ELFRelocs/Mips.def
> for base clang.
>
> To make llvm more useful on mips64 one should either try to somehow
> avoid using those relocations, or add support for those relocations to
> binutils-2.17.

Apparently I'm pretty far from being qualified to do something like
this.  But MIPS just got open source, so maybe helps are coming.

>
> You could try applying this diff to see which relocation triggers the
> assert.
>
> My two cents,
>
>
> Index: elf64-mips.c
> ===
> RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c,v
> retrieving revision 1.1.1.1
> diff -u -p -p -u -r1.1.1.1 elf64-mips.c
> --- elf64-mips.c  24 Apr 2011 20:14:42 -  1.1.1.1
> +++ elf64-mips.c  19 Dec 2018 17:22:29 -
> @@ -2252,6 +2252,8 @@ mips_elf64_rtype_to_howto (unsigned int
>   return _elf64_howto_table_rel[r_type - R_MIPS16_min];
>   }
>BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
> +  if (!(r_type < (unsigned int) R_MIPS_max))
> +   fprintf(stderr, "BFD:%s: relocation type %u\n", __func__, r_type);
>if (rela_p)
>   return _elf64_howto_table_rela[r_type];
>else

Thanks for the detailed explanation!  Will try your patch and report back.

--
manphiz



Re: qtbase-5.9.6p1 fails to build on -stable/loongson

2018-12-19 Thread Jeremie Courreges-Anglas
On Wed, Dec 19 2018, Xiyue Deng  wrote:
> Xiyue Deng writes:
>
>> Hi,
>>
>> As title suggests, qtbase on -stable fails to build.  Relevant part from
>> build log:
>>
>> /usr/bin/ld: BFD 2.17 assertion fail 
>> /usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254
>> /usr/bin/ld: BFD 2.17 internal error, aborting at 
>> /usr/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c line 445 in bfd_get_reloc_size
>>
>> /usr/bin/ld: Please report this bug.
>>
>> clang-6.0: error: linker command failed with exit code 1 (use -v to see 
>> invocation)
>>
>> Full build log is also attached.  Please advice on how to fix.  Thanks!
>
> Hi,
>
> Any updates on this issue?

Your initial mail was two/three days ago.  I would not expect someone to
jump on obscure binutils problems on a non-mainstream arch.  ;)

Now, you got me curious.  Tentative analysis below, take with a grain of
salt.

Here's the code at
/usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254:
--8<--
/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure.  */

static reloc_howto_type *
mips_elf64_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p)
{
  switch (r_type)
{
case R_MIPS_GNU_VTINHERIT:
  return _mips_gnu_vtinherit_howto;
case R_MIPS_GNU_VTENTRY:
  return _mips_gnu_vtentry_howto;
case R_MIPS_GNU_REL16_S2:
  if (rela_p)
return _mips_gnu_rela16_s2;
  else
return _mips_gnu_rel16_s2;
default:
  if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max)
{
  if (rela_p)
return _elf64_howto_table_rela[r_type - R_MIPS16_min];
  else
return _elf64_howto_table_rel[r_type - R_MIPS16_min];
}
  BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
  if (rela_p)
return _elf64_howto_table_rela[r_type];
  else
return _elf64_howto_table_rel[r_type];
  break;
}
}
-->8--

As far as binutils-2.17 know, R_MIPS_max is 51:

  include/elf/mips.h
  90:  FAKE_RELOC (R_MIPS_max, 51)

But llvm/clang adds support for additional relocation types, at least:
--8<--
ELF_RELOC(R_MIPS_PC21_S2,60)
ELF_RELOC(R_MIPS_PC26_S2,61)
ELF_RELOC(R_MIPS_PC18_S3,62)
ELF_RELOC(R_MIPS_PC19_S2,63)
ELF_RELOC(R_MIPS_PCHI16, 64)
ELF_RELOC(R_MIPS_PCLO16, 65)
-->8--
listed in /usr/src/gnu/llvm/include/llvm/BinaryFormat/ELFRelocs/Mips.def
for base clang.

To make llvm more useful on mips64 one should either try to somehow
avoid using those relocations, or add support for those relocations to
binutils-2.17.

You could try applying this diff to see which relocation triggers the
assert.

My two cents,


Index: elf64-mips.c
===
RCS file: /cvs/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c,v
retrieving revision 1.1.1.1
diff -u -p -p -u -r1.1.1.1 elf64-mips.c
--- elf64-mips.c24 Apr 2011 20:14:42 -  1.1.1.1
+++ elf64-mips.c19 Dec 2018 17:22:29 -
@@ -2252,6 +2252,8 @@ mips_elf64_rtype_to_howto (unsigned int 
return _elf64_howto_table_rel[r_type - R_MIPS16_min];
}
   BFD_ASSERT (r_type < (unsigned int) R_MIPS_max);
+  if (!(r_type < (unsigned int) R_MIPS_max))
+ fprintf(stderr, "BFD:%s: relocation type %u\n", __func__, r_type);
   if (rela_p)
return _elf64_howto_table_rela[r_type];
   else

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE



Re: qtbase-5.9.6p1 fails to build on -stable/loongson

2018-12-19 Thread Xiyue Deng

Xiyue Deng writes:

> Hi,
>
> As title suggests, qtbase on -stable fails to build.  Relevant part from
> build log:
>
> /usr/bin/ld: BFD 2.17 assertion fail 
> /usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254
> /usr/bin/ld: BFD 2.17 internal error, aborting at 
> /usr/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c line 445 in bfd_get_reloc_size
>
> /usr/bin/ld: Please report this bug.
>
> clang-6.0: error: linker command failed with exit code 1 (use -v to see 
> invocation)
>
> Full build log is also attached.  Please advice on how to fix.  Thanks!

Hi,

Any updates on this issue?

-- 
manphiz


signature.asc
Description: PGP signature


qtbase-5.9.6p1 fails to build on -stable/loongson

2018-12-16 Thread Xiyue Deng
Hi,

As title suggests, qtbase on -stable fails to build.  Relevant part from
build log:

/usr/bin/ld: BFD 2.17 assertion fail 
/usr/src/gnu/usr.bin/binutils-2.17/bfd/elf64-mips.c:2254
/usr/bin/ld: BFD 2.17 internal error, aborting at 
/usr/src/gnu/usr.bin/binutils-2.17/bfd/reloc.c line 445 in bfd_get_reloc_size

/usr/bin/ld: Please report this bug.

clang-6.0: error: linker command failed with exit code 1 (use -v to see 
invocation)

Full build log is also attached.  Please advice on how to fix.  Thanks!

-- 
manphiz



qtbase.log.gz
Description: application/gzip


signature.asc
Description: PGP signature