[PATCH v5] riscv: Handle zicsr/zifencei issue between gcc and binutils

Mingzheng Xing xingmingzheng at iscas.ac.cn
Thu Aug 24 10:30:36 PDT 2023


On 8/24/23 19:32, Mingzheng Xing wrote:
> On 8/23/23 21:31, Conor Dooley wrote:
>> On Wed, Aug 23, 2023 at 12:51:13PM +0100, Conor Dooley wrote:
>>> On Thu, Aug 17, 2023 at 03:20:24PM +0000, 
>>> patchwork-bot+linux-riscv at kernel.org wrote:
>>>> Hello:
>>>>
>>>> This patch was applied to riscv/linux.git (fixes)
>>>> by Palmer Dabbelt <palmer at rivosinc.com>:
>>>>
>>>> On Thu, 10 Aug 2023 00:56:48 +0800 you wrote:
>>>>> Binutils-2.38 and GCC-12.1.0 bumped[0][1] the default ISA spec to 
>>>>> the newer
>>>>> 20191213 version which moves some instructions from the I 
>>>>> extension to the
>>>>> Zicsr and Zifencei extensions. So if one of the binutils and GCC 
>>>>> exceeds
>>>>> that version, we should explicitly specifying Zicsr and Zifencei 
>>>>> via -march
>>>>> to cope with the new changes. but this only occurs when binutils 
>>>>> >= 2.36
>>>>> and GCC >= 11.1.0. It's a different story when binutils < 2.36.
>>>>>
>>>>> [...]
>>>> Here is the summary with links:
>>>>    - [v5] riscv: Handle zicsr/zifencei issue between gcc and binutils
>>>>      https://git.kernel.org/riscv/c/ca09f772ccca
>>> *sigh* so this breaks the build for gcc-11 & binutils 2.37 w/
>>>     Assembler messages:
>>>     Error: cannot find default versions of the ISA extension `zicsr'
>>>     Error: cannot find default versions of the ISA extension `zifencei'
>>>
>>> I'll have a poke later.
>> So uh, are we sure that this should not be:
>> -       depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || 
>> (CC_IS_GCC && GCC_VERSION < 110100)
>> +       depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || 
>> (CC_IS_GCC && GCC_VERSION <= 110100)
>>
>> My gcc-11.1 + binutils 2.37 toolchain built from riscv-gnu-toolchain
>> doesn't have the default versions & the above diff fixes the build.
>
> I reproduced the error, the combination of gcc-11.1 and
> binutils 2.37 does cause errors. What a surprise, since binutils
> 2.36 and 2.38 are fine.
>
> I used git bisect to locate this commit[1] for binutils.
> I'll test this diff in more detail later. Thanks!
>
> [1] 
> https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f0bae2552db1dd4f1995608fbf6648fcee4e9e0c
>

Hi, Conor.
The above error does originate from link[1] mentioned above, which was
resolved in gcc-12.1.0[2], and gcc-11.3.0 made the backport[3].
So gcc-11.2.0 combined with binutils 2.37 produces the same error.
I think we should do the following diff to fix it:
-       depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || (CC_IS_GCC 
&& GCC_VERSION < 110100)
+       depends on (CC_IS_CLANG && CLANG_VERSION < 170000) || (CC_IS_GCC 
&& GCC_VERSION < 110300)

Then below are my test results after the fix:

gcc        binutils

10.5.0     2.35            ok
10.5.0     2.36            ok
10.5.0     2.37            ok
10.5.0     2.38            ok

11.1.0     2.35            ok
11.1.0     2.36            ok
11.1.0     2.37            ok
11.1.0     2.38            ok

11.2.0     2.35            ok
11.2.0     2.36            ok
11.2.0     2.37            ok
11.2.0     2.38            ok

11.3.0     2.35            ok
11.3.0     2.36            ok
11.3.0     2.37            ok
11.3.0     2.38            ok

11.4.0     2.35            ok
11.4.0     2.36            ok
11.4.0     2.37            ok
11.4.0     2.38            ok

12.1.0     2.35            ok
12.1.0     2.36            ok
12.1.0     2.37            ok
12.1.0     2.38            ok

12.2.0     2.35            ok
12.2.0     2.36            ok
12.2.0     2.37            ok
12.2.0     2.38            ok

[1] 
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=f0bae2552db1dd4f1995608fbf6648fcee4e9e0c
[2] 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ca2bbb88f999f4d3cc40e89bc1aba712505dd598
[3] 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=d29f5d6ab513c52fd872f532c492e35ae9fd6671

Thanks,
Mingzheng.

>>
>> Thanks,
>> Conor.
>
>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv




More information about the linux-riscv mailing list