diff mbox series

[v2,1/6] toolchain/buildroot: allow uclibc-ng for riscv

Message ID 20200908113324.1022230-2-damien.lemoal@wdc.com
State Accepted
Headers show
Series Add support for Kendryte K210 RISC-V boards | expand

Commit Message

Damien Le Moal Sept. 8, 2020, 11:33 a.m. UTC
uclibcb supports RISC-V architecture since version 1.0.31. Allow its
selection for that architecture.

Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 package/uclibc/Config.in                | 2 ++
 toolchain/toolchain-buildroot/Config.in | 4 +++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Yann E. MORIN Sept. 8, 2020, 9:49 p.m. UTC | #1
Damien, All,

+Petr in Cc as he's working on a the same topic:

    https://patchwork.ozlabs.org/project/buildroot/patch/20200908145346.198693-1-petr.vorel@gmail.com/

On 2020-09-08 20:33 +0900, Damien Le Moal spake thusly:
> uclibcb supports RISC-V architecture since version 1.0.31. Allow its
> selection for that architecture.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
[--SNIP--]
> diff --git a/toolchain/toolchain-buildroot/Config.in b/toolchain/toolchain-buildroot/Config.in
> index 418d5cb387..49f67c7348 100644
> --- a/toolchain/toolchain-buildroot/Config.in
> +++ b/toolchain/toolchain-buildroot/Config.in
> @@ -32,7 +32,9 @@ config BR2_TOOLCHAIN_BUILDROOT_UCLIBC
>  		   BR2_i386    || BR2_m68k   || BR2_microblaze || \
>  		   BR2_mips    || BR2_mipsel || BR2_mips64 || BR2_mips64el || \
>  		   BR2_or1k    || BR2_powerpc || BR2_sh2a   || BR2_sh4	   || \
> -		   BR2_sh4eb   || BR2_sparc   || BR2_xtensa || BR2_x86_64
> +		   BR2_sh4eb   || BR2_sparc   || BR2_xtensa || BR2_x86_64  || \
> +		   BR2_riscv

Please keep alphabetical ordeing in the architecture list, i.e. riscv
goes between BR2_powerpc and BR2_sh2a

But as I said to Petr, I guess cleanup the layout of that list would
be OK in a separate, preparatory patch, which would make it easier to
properly add riscv in the correct place.

Regards,
Yann E. MORIN.

>  	select BR2_TOOLCHAIN_USES_UCLIBC
>  	help
>  	  This option selects uClibc-ng as the C library for the
> -- 
> 2.26.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Thomas Petazzoni Oct. 6, 2020, 9:40 p.m. UTC | #2
Hello,

On Tue,  8 Sep 2020 20:33:19 +0900
Damien Le Moal <damien.lemoal@wdc.com> wrote:

> diff --git a/package/uclibc/Config.in b/package/uclibc/Config.in
> index de2885bc92..35b1cb8e2f 100644
> --- a/package/uclibc/Config.in
> +++ b/package/uclibc/Config.in
> @@ -106,6 +106,8 @@ config BR2_UCLIBC_TARGET_ARCH
>  	default "xtensa"   if BR2_xtensa
>  	default "i386"	   if BR2_i386
>  	default "x86_64"   if BR2_x86_64
> +	default "riscv64"  if BR2_riscv && BR2_ARCH_IS_64
> +	default "riscv32"  if BR2_riscv && !BR2_ARCH_IS_6

There was a typo here: BR2_ARCH_IS_6 was truncated.

> diff --git a/toolchain/toolchain-buildroot/Config.in b/toolchain/toolchain-buildroot/Config.in
> index 418d5cb387..49f67c7348 100644
> --- a/toolchain/toolchain-buildroot/Config.in
> +++ b/toolchain/toolchain-buildroot/Config.in
> @@ -32,7 +32,9 @@ config BR2_TOOLCHAIN_BUILDROOT_UCLIBC
>  		   BR2_i386    || BR2_m68k   || BR2_microblaze || \
>  		   BR2_mips    || BR2_mipsel || BR2_mips64 || BR2_mips64el || \
>  		   BR2_or1k    || BR2_powerpc || BR2_sh2a   || BR2_sh4	   || \
> -		   BR2_sh4eb   || BR2_sparc   || BR2_xtensa || BR2_x86_64
> +		   BR2_sh4eb   || BR2_sparc   || BR2_xtensa || BR2_x86_64  || \
> +		   BR2_riscv

I fixed the alphabetic ordering.

> +

Dropped the empty new line.

And applied with some small improvements to the commit log as well.

Thanks!

Thomas
Damien Le Moal Oct. 6, 2020, 10:53 p.m. UTC | #3
On 2020/10/07 6:40, Thomas Petazzoni wrote:
> Hello,
> 
> On Tue,  8 Sep 2020 20:33:19 +0900
> Damien Le Moal <damien.lemoal@wdc.com> wrote:
> 
>> diff --git a/package/uclibc/Config.in b/package/uclibc/Config.in
>> index de2885bc92..35b1cb8e2f 100644
>> --- a/package/uclibc/Config.in
>> +++ b/package/uclibc/Config.in
>> @@ -106,6 +106,8 @@ config BR2_UCLIBC_TARGET_ARCH
>>  	default "xtensa"   if BR2_xtensa
>>  	default "i386"	   if BR2_i386
>>  	default "x86_64"   if BR2_x86_64
>> +	default "riscv64"  if BR2_riscv && BR2_ARCH_IS_64
>> +	default "riscv32"  if BR2_riscv && !BR2_ARCH_IS_6
> 
> There was a typo here: BR2_ARCH_IS_6 was truncated.

Oops. Sorry about that.

> 
>> diff --git a/toolchain/toolchain-buildroot/Config.in b/toolchain/toolchain-buildroot/Config.in
>> index 418d5cb387..49f67c7348 100644
>> --- a/toolchain/toolchain-buildroot/Config.in
>> +++ b/toolchain/toolchain-buildroot/Config.in
>> @@ -32,7 +32,9 @@ config BR2_TOOLCHAIN_BUILDROOT_UCLIBC
>>  		   BR2_i386    || BR2_m68k   || BR2_microblaze || \
>>  		   BR2_mips    || BR2_mipsel || BR2_mips64 || BR2_mips64el || \
>>  		   BR2_or1k    || BR2_powerpc || BR2_sh2a   || BR2_sh4	   || \
>> -		   BR2_sh4eb   || BR2_sparc   || BR2_xtensa || BR2_x86_64
>> +		   BR2_sh4eb   || BR2_sparc   || BR2_xtensa || BR2_x86_64  || \
>> +		   BR2_riscv
> 
> I fixed the alphabetic ordering.
> 
>> +
> 
> Dropped the empty new line.
> 
> And applied with some small improvements to the commit log as well.

Thanks for fixing these !

> 
> Thanks!
> 
> Thomas
>
Thomas Petazzoni Oct. 8, 2020, 7:33 p.m. UTC | #4
Hello Damien,

On Tue, 6 Oct 2020 23:40:12 +0200
Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:

> And applied with some small improvements to the commit log as well.

So it turns out that the riscv32 uClibc-ng toolchain doesn't build. It
fails in the uClibc-ng build with:

In file included from ./include/sys/procfs.h:34,
                 from ./libpthread/nptl/../nptl_db/thread_db.h:28,
                 from ./libpthread/nptl/descr.h:30,
                 from ./libpthread/nptl/pthreadP.h:25,
                 from <stdin>:2:
./include/sys/user.h:32:3: error: unknown type name '__uint128_t'
   32 |   __uint128_t  vregs[32];
      |   ^~~~~~~~~~~

You can see a more complete build log at:

https://gitlab.com/bootlin/toolchains-builder/-/jobs/776340188

The defconfig being built is just:

BR2_riscv=y
BR2_RISCV_32=y
BR2_KERNEL_HEADERS_5_4=y
BR2_TOOLCHAIN_BUILDROOT_LOCALE=y
BR2_PTHREAD_DEBUG=y
BR2_BINUTILS_VERSION_2_34_X=y
BR2_GCC_VERSION_10_X=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_TOOLCHAIN_BUILDROOT_FORTRAN=y
BR2_INIT_NONE=y
BR2_SYSTEM_BIN_SH_NONE=y
# BR2_PACKAGE_BUSYBOX is not set
BR2_PACKAGE_GDB=y
# BR2_TARGET_ROOTFS_TAR is not set

Do you have some idea of what could be wrong here ?

Thanks a lot,

Thomas
Damien Le Moal Oct. 12, 2020, 5 a.m. UTC | #5
On 2020/10/09 4:33, Thomas Petazzoni wrote:
> Hello Damien,
> 
> On Tue, 6 Oct 2020 23:40:12 +0200
> Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:
> 
>> And applied with some small improvements to the commit log as well.
> 
> So it turns out that the riscv32 uClibc-ng toolchain doesn't build. It
> fails in the uClibc-ng build with:
> 
> In file included from ./include/sys/procfs.h:34,
>                  from ./libpthread/nptl/../nptl_db/thread_db.h:28,
>                  from ./libpthread/nptl/descr.h:30,
>                  from ./libpthread/nptl/pthreadP.h:25,
>                  from <stdin>:2:
> ./include/sys/user.h:32:3: error: unknown type name '__uint128_t'
>    32 |   __uint128_t  vregs[32];
>       |   ^~~~~~~~~~~
> 
> You can see a more complete build log at:
> 
> https://gitlab.com/bootlin/toolchains-builder/-/jobs/776340188
> 
> The defconfig being built is just:
> 
> BR2_riscv=y
> BR2_RISCV_32=y
> BR2_KERNEL_HEADERS_5_4=y
> BR2_TOOLCHAIN_BUILDROOT_LOCALE=y
> BR2_PTHREAD_DEBUG=y
> BR2_BINUTILS_VERSION_2_34_X=y
> BR2_GCC_VERSION_10_X=y
> BR2_TOOLCHAIN_BUILDROOT_CXX=y
> BR2_TOOLCHAIN_BUILDROOT_FORTRAN=y
> BR2_INIT_NONE=y
> BR2_SYSTEM_BIN_SH_NONE=y
> # BR2_PACKAGE_BUSYBOX is not set
> BR2_PACKAGE_GDB=y
> # BR2_TARGET_ROOTFS_TAR is not set
> 
> Do you have some idea of what could be wrong here ?

No clue. This is very weird since this vregs thing is declared only in
libc/sysdeps/linux/aarch64/sys/user.h. So ARM64, not riscv.

The file libc/sysdeps/linux/riscv64/sys/user.h exists but does not use
__uint128_t, it is in fact empty. And this file does not exist for riscv32, the
entire libc/sysdeps/linux/riscv32 directory does not exist.

Something funky is going on with the arch dependent definitions...

Alistair,

Any idea ?


> 
> Thanks a lot,
> 
> Thomas
>
Waldemar Brodkorb Oct. 12, 2020, 5:18 a.m. UTC | #6
Hi,
Uclibc-Ng doesn’t support riscv32!
Best regards
 Waldemar 

> Am 12.10.2020 um 07:00 schrieb Damien Le Moal <damien.lemoal@wdc.com>:
> 
> On 2020/10/09 4:33, Thomas Petazzoni wrote:
>> Hello Damien,
>> 
>>> On Tue, 6 Oct 2020 23:40:12 +0200
>>> Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:
>>> 
>>> And applied with some small improvements to the commit log as well.
>> 
>> So it turns out that the riscv32 uClibc-ng toolchain doesn't build. It
>> fails in the uClibc-ng build with:
>> 
>> In file included from ./include/sys/procfs.h:34,
>>                 from ./libpthread/nptl/../nptl_db/thread_db.h:28,
>>                 from ./libpthread/nptl/descr.h:30,
>>                 from ./libpthread/nptl/pthreadP.h:25,
>>                 from <stdin>:2:
>> ./include/sys/user.h:32:3: error: unknown type name '__uint128_t'
>>   32 |   __uint128_t  vregs[32];
>>      |   ^~~~~~~~~~~
>> 
>> You can see a more complete build log at:
>> 
>> https://gitlab.com/bootlin/toolchains-builder/-/jobs/776340188
>> 
>> The defconfig being built is just:
>> 
>> BR2_riscv=y
>> BR2_RISCV_32=y
>> BR2_KERNEL_HEADERS_5_4=y
>> BR2_TOOLCHAIN_BUILDROOT_LOCALE=y
>> BR2_PTHREAD_DEBUG=y
>> BR2_BINUTILS_VERSION_2_34_X=y
>> BR2_GCC_VERSION_10_X=y
>> BR2_TOOLCHAIN_BUILDROOT_CXX=y
>> BR2_TOOLCHAIN_BUILDROOT_FORTRAN=y
>> BR2_INIT_NONE=y
>> BR2_SYSTEM_BIN_SH_NONE=y
>> # BR2_PACKAGE_BUSYBOX is not set
>> BR2_PACKAGE_GDB=y
>> # BR2_TARGET_ROOTFS_TAR is not set
>> 
>> Do you have some idea of what could be wrong here ?
> 
> No clue. This is very weird since this vregs thing is declared only in
> libc/sysdeps/linux/aarch64/sys/user.h. So ARM64, not riscv.
> 
> The file libc/sysdeps/linux/riscv64/sys/user.h exists but does not use
> __uint128_t, it is in fact empty. And this file does not exist for riscv32, the
> entire libc/sysdeps/linux/riscv32 directory does not exist.
> 
> Something funky is going on with the arch dependent definitions...
> 
> Alistair,
> 
> Any idea ?
> 
> 
>> 
>> Thanks a lot,
>> 
>> Thomas
>> 
> 
> 
> -- 
> Damien Le Moal
> Western Digital Research
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
Damien Le Moal Oct. 12, 2020, 5:28 a.m. UTC | #7
On 2020/10/12 14:19, Waldemar Brodkorb wrote:
> Hi,
> Uclibc-Ng doesn’t support riscv32!

That's a simple explanation for the problem :)
Solved !

Thanks.

Thomas,

I think we just need to patch buildroot config to prevent rv32 builds with
uclibc. Something like this:

diff --git a/package/uclibc/Config.in b/package/uclibc/Config.in
index 494758bd9d..e59fef3c69 100644
--- a/package/uclibc/Config.in
+++ b/package/uclibc/Config.in
@@ -107,7 +107,6 @@ config BR2_UCLIBC_TARGET_ARCH
        default "i386"     if BR2_i386
        default "x86_64"   if BR2_x86_64
        default "riscv64"  if BR2_RISCV_64
-       default "riscv32"  if BR2_RISCV_32

 config BR2_UCLIBC_MIPS_ABI
        string
diff --git a/toolchain/toolchain-buildroot/Config.in
b/toolchain/toolchain-buildroot/Config.in
index f34dd84c29..ba2f2cec9b 100644
--- a/toolchain/toolchain-buildroot/Config.in
+++ b/toolchain/toolchain-buildroot/Config.in
@@ -31,7 +31,7 @@ config BR2_TOOLCHAIN_BUILDROOT_UCLIBC
                   BR2_arm     || BR2_armeb    || \
                   BR2_i386    || BR2_m68k   || BR2_microblaze || \
                   BR2_mips    || BR2_mipsel || BR2_mips64 || BR2_mips64el || \
-                  BR2_or1k    || BR2_powerpc || BR2_riscv || BR2_sh2a   || \
+                  BR2_or1k    || BR2_powerpc || BR2_RISCV_64|| BR2_sh2a   || \
                   BR2_sh4     || BR2_sh4eb   || BR2_sparc || BR2_xtensa || \
                   BR2_x86_64
        select BR2_TOOLCHAIN_USES_UCLIBC

Totally untested.


> Best regards
>  Waldemar 
> 
>> Am 12.10.2020 um 07:00 schrieb Damien Le Moal <damien.lemoal@wdc.com>:
>>
>> On 2020/10/09 4:33, Thomas Petazzoni wrote:
>>> Hello Damien,
>>>
>>>> On Tue, 6 Oct 2020 23:40:12 +0200
>>>> Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:
>>>>
>>>> And applied with some small improvements to the commit log as well.
>>>
>>> So it turns out that the riscv32 uClibc-ng toolchain doesn't build. It
>>> fails in the uClibc-ng build with:
>>>
>>> In file included from ./include/sys/procfs.h:34,
>>>                 from ./libpthread/nptl/../nptl_db/thread_db.h:28,
>>>                 from ./libpthread/nptl/descr.h:30,
>>>                 from ./libpthread/nptl/pthreadP.h:25,
>>>                 from <stdin>:2:
>>> ./include/sys/user.h:32:3: error: unknown type name '__uint128_t'
>>>   32 |   __uint128_t  vregs[32];
>>>      |   ^~~~~~~~~~~
>>>
>>> You can see a more complete build log at:
>>>
>>> https://gitlab.com/bootlin/toolchains-builder/-/jobs/776340188
>>>
>>> The defconfig being built is just:
>>>
>>> BR2_riscv=y
>>> BR2_RISCV_32=y
>>> BR2_KERNEL_HEADERS_5_4=y
>>> BR2_TOOLCHAIN_BUILDROOT_LOCALE=y
>>> BR2_PTHREAD_DEBUG=y
>>> BR2_BINUTILS_VERSION_2_34_X=y
>>> BR2_GCC_VERSION_10_X=y
>>> BR2_TOOLCHAIN_BUILDROOT_CXX=y
>>> BR2_TOOLCHAIN_BUILDROOT_FORTRAN=y
>>> BR2_INIT_NONE=y
>>> BR2_SYSTEM_BIN_SH_NONE=y
>>> # BR2_PACKAGE_BUSYBOX is not set
>>> BR2_PACKAGE_GDB=y
>>> # BR2_TARGET_ROOTFS_TAR is not set
>>>
>>> Do you have some idea of what could be wrong here ?
>>
>> No clue. This is very weird since this vregs thing is declared only in
>> libc/sysdeps/linux/aarch64/sys/user.h. So ARM64, not riscv.
>>
>> The file libc/sysdeps/linux/riscv64/sys/user.h exists but does not use
>> __uint128_t, it is in fact empty. And this file does not exist for riscv32, the
>> entire libc/sysdeps/linux/riscv32 directory does not exist.
>>
>> Something funky is going on with the arch dependent definitions...
>>
>> Alistair,
>>
>> Any idea ?
>>
>>
>>>
>>> Thanks a lot,
>>>
>>> Thomas
>>>
>>
>>
>> -- 
>> Damien Le Moal
>> Western Digital Research
>> _______________________________________________
>> buildroot mailing list
>> buildroot@busybox.net
>> http://lists.busybox.net/mailman/listinfo/buildroot
>>
> 
> _______________________________________________
> buildroot mailing list
> buildroot@busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
>
diff mbox series

Patch

diff --git a/package/uclibc/Config.in b/package/uclibc/Config.in
index de2885bc92..35b1cb8e2f 100644
--- a/package/uclibc/Config.in
+++ b/package/uclibc/Config.in
@@ -106,6 +106,8 @@  config BR2_UCLIBC_TARGET_ARCH
 	default "xtensa"   if BR2_xtensa
 	default "i386"	   if BR2_i386
 	default "x86_64"   if BR2_x86_64
+	default "riscv64"  if BR2_riscv && BR2_ARCH_IS_64
+	default "riscv32"  if BR2_riscv && !BR2_ARCH_IS_6
 
 config BR2_UCLIBC_MIPS_ABI
 	string
diff --git a/toolchain/toolchain-buildroot/Config.in b/toolchain/toolchain-buildroot/Config.in
index 418d5cb387..49f67c7348 100644
--- a/toolchain/toolchain-buildroot/Config.in
+++ b/toolchain/toolchain-buildroot/Config.in
@@ -32,7 +32,9 @@  config BR2_TOOLCHAIN_BUILDROOT_UCLIBC
 		   BR2_i386    || BR2_m68k   || BR2_microblaze || \
 		   BR2_mips    || BR2_mipsel || BR2_mips64 || BR2_mips64el || \
 		   BR2_or1k    || BR2_powerpc || BR2_sh2a   || BR2_sh4	   || \
-		   BR2_sh4eb   || BR2_sparc   || BR2_xtensa || BR2_x86_64
+		   BR2_sh4eb   || BR2_sparc   || BR2_xtensa || BR2_x86_64  || \
+		   BR2_riscv
+
 	select BR2_TOOLCHAIN_USES_UCLIBC
 	help
 	  This option selects uClibc-ng as the C library for the