[Buildroot] [PATCH 2/9] package/binutils: add upstream backported patches to support -mcmodel=large gcc option

Giulio Benetti giulio.benetti at benettiengineering.com
Wed Jun 9 16:50:02 UTC 2021


Hi Romain, All,

On 6/9/21 8:26 AM, Romain Naour wrote:
> Hi Giulio,
> 
> Le 09/06/2021 à 00:16, Giulio Benetti a écrit :
>> Hi Romain,
>>
>> On 6/8/21 11:29 PM, Romain Naour wrote:
>>> Hi Giulio, All,
>>>
>>> Le 03/05/2021 à 13:13, Giulio Benetti a écrit :
>>>> Add upstream backported patches that allows using -mcmodel=large gcc option
>>>> that in order allows fixing build failure due to binutils bug 21464:
>>>> https://sourceware.org/bugzilla/show_bug.cgi?id=21464
>>>>
>>>> Signed-off-by: Giulio Benetti <giulio.benetti at benettiengineering.com>
>>>> ---
>>>>    ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>>>    ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>>>>    ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>>>    ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>>>    ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>>>>    ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>>>    ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>>>    ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>>>>    ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>>>    ...elocation-R_OR1K_GOT_AHI16-for-gotha.patch | 256 +++++++++
>>>>    ...K_GOT16-overflow-failures-in-presenc.patch |  61 +++
>>>>    ...ge-plt_relocs-when-generating-plt-en.patch | 500 ++++++++++++++++++
>>>>    12 files changed, 3268 insertions(+)
>>>>    create mode 100644
>>>> package/binutils/2.32/0011-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.32/0012-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.32/0013-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.34/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.34/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.34/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.35.2/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.35.2/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.35.2/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.36.1/0004-or1k-Implement-relocation-R_OR1K_GOT_AHI16-for-gotha.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.36.1/0005-or1k-Avoid-R_OR1K_GOT16-overflow-failures-in-presenc.patch
>>>>
>>>>    create mode 100644
>>>> package/binutils/2.36.1/0006-or1k-Support-large-plt_relocs-when-generating-plt-en.patch
>>>>
>>>>
>>>
>>>> +   unsigned nodelay = elf_elfheader (output_bfd)->e_flags & EF_OR1K_NODELAY;
>>>> +-  unsigned insn4;
>>>> ++  unsigned output_insns[PLT_MAX_INSN_COUNT];
>>>> ++
>>>> ++  /* Copy instructions into the output buffer.  */
>>>> ++  for (size_t i = 0; i < insn_count; i++)
>>>> ++    output_insns[i] = insns[i];
>>>> +
>>>
>>> This syntax break with good old compilers :)
>>>
>>> elf32-or1k.c:2251:3: error: 'for' loop initial declarations are only allowed in
>>> C99 or C11 mode
>>>      for (size_t i = 0; i < insn_count; i++)
>>>      ^
>>>
>>> See:
>>> https://gitlab.com/bootlin/toolchains-builder/-/jobs/1325646298
>>
>> Thanks for pointing, I didn't think about old host compiler. I'm going to fix it
>> soon by patching actual patches initializing variable at the
>> begin of functions.
> 
> Toolchain-builder use Debian 8 jessie to build the toolchain while Debian 9
> stretch is used to run the Buildroot testsuite.
> 
> See, there is no problem to build the qemu_or1k_defconfig in gitlab using stretch:
> https://gitlab.com/buildroot.org/buildroot/-/jobs/1307293494
> 
> The host gcc used by stretch is gcc 6 while it's gcc 4.9 for jessie, the default
> mode for C is -std=gnu11 since gcc 5:
> https://gcc.gnu.org/gcc-5/changes.html

Here is the patch that fixes that issue [1]

I've tested it on Debian Jessie and it works fine(while before I've 
encountered your same problem).

It's pending upstream[2], this is why I've decided to add a new patch 
instead of modifying the current one.

Does it sound good for you?

[1]: 
https://patchwork.ozlabs.org/project/buildroot/patch/20210609162753.1138390-1-giulio.benetti@benettiengineering.com/

[2]: https://sourceware.org/pipermail/binutils/2021-June/116884.html

Best regards
-- 
Giulio Benetti
Benetti Engineering sas



More information about the buildroot mailing list