Open TommyMurphyTM1234 opened 1 year ago
I think that the same issue arises with the Linux (glibc) multilib toolchain.
I was mistaken - the Linux glibc multilib toolchain build succeeds.
@TommyMurphyTM1234 that does ring a bell. I wonder if it was broken for glibc then we fixed it. Might pay to look at closed issues
@TommyMurphyTM1234 that does ring a bell. I wonder if it was broken for glibc then we fixed it. Might pay to look at closed issues
Maybe this is relevant here too?
The musl compiler (riscv64-unknown-linux-musl-) will only be able to target 64-bit systems due to limitations in the upstream musl architecture support. The --enable-multilib flag therefore does not actually enable multilib support for musl libc.
Perhaps the multilib option should not be available when musl is selected as the Linux C library?
@TommyMurphyTM1234 that does ring a bell. I wonder if it was broken for glibc then we fixed it. Might pay to look at closed issues
Thanks @cpackham - before logging it I did have a look at the open and closed issues but couldn't see anything obviously relevant. But it may simply be a limitation of the musl RISC-V support based on what the riscv-gnu-toolchain
repo readme says? I'll try to dig a bit deeper and post back if/when I have anything further to report.
Sounds likely. It'd be nice to point at a musl issue and be able to "say multilib isn't supported (yet?)" then we can add something to prevent it being selected when libc==musl.
The musl compiler (riscv64-unknown-linux-musl-) will only be able to target 64-bit systems due to limitations in the upstream musl architecture support. The --enable-multilib flag therefore does not actually enable multilib support for musl libc.
I'm wondering if this is incomplete or misleading. musl only supports rv64 so it makes sense that rv32 libs/multilibs cannot be built. And the default set of multilibs for the Linux toolchain](https://github.com/gcc-mirror/gcc/blob/master/gcc/config/riscv/t-linux-multilib) includes a couple of rv32 variants:
march=rv32imac/mabi=ilp32
march=rv32imafdc/mabi=ilp32d
march=rv64imac/mabi=lp64
march=rv64imafdc/mabi=lp64d
But it's unclear if a toolchain with a non-default list of only rv64 multilibs can be built - e.g.:
march=rv64imac/mabi=lp64
march=rv64imafdc/mabi=lp64d
I will see if this is possible,
Also, this is technically incorrect:
The musl compiler (riscv64-unknown-linux-musl-) will only be able to target 64-bit systems
Any RISC-V compiler can target any XLEN and set of ratified extensions so the RISC-V Linux/musl compiler can generate rv32 code but it will fail if/when it attempts to link (the non-existent) rv32 multilibs.
I did a non parallel (jobs = 1) build just to better see the errors. This makes sense - it's trying to build an rv32 library but the assembly code contains rv64 specific opcodes.
[ALL ] riscv64-unknown-linux-musl-gcc -std=c99 -nostdinc -ffreestanding -fexcess-precision=standard -frounding-math -fno-strict-aliasing -Wa,--noexecstack -D_XOPEN_SOURCE=700 -I/home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/arch/riscv64 -I/home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/arch/generic -Iobj/src/internal -I/home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/include -I/home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/internal -Iobj/include -I/home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/include -Os -pipe -fomit-frame-pointer -fno-unwind-tables -fno-asynchronous-unwind-tables -ffunction-sections -fdata-sections -Wno-pointer-to-int-cast -Werror=implicit-function-declaration -Werror=implicit-int -Werror=pointer-sign -Werror=pointer-arith -Werror=int-conversion -Werror=incompatible-pointer-types -Werror=discarded-qualifiers -Werror=discarded-array-qualifiers -Waddress -Warray-bounds -Wchar-subscripts -Wduplicate-decl-specifier -Winit-self -Wreturn-type -Wsequence-point -Wstrict-aliasing -Wunused-function -Wunused-label -Wunused-variable -march=rv32imac -mabi=ilp32 -c -o obj/src/ldso/dlerror.o /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/ldso/dlerror.c
[ALL ] In file included from /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/internal/pthread_impl.h:11,
[ALL ] from /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/ldso/dlerror.c:4:
[ALL ] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/internal/atomic.h: In function 'a_ctz_64':
[ALL ] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/internal/atomic.h:283:30: warning: right shift count >= width of type [-Wshift-count-overflow]
[ALL ] 283 | y = x>>32;
[ALL ] | ^~
[ALL ] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/internal/atomic.h: In function 'a_clz_64':
[ALL ] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/internal/atomic.h:308:14: warning: right shift count >= width of type [-Wshift-count-overflow]
[ALL ] 308 | if (x>>32) y=x>>32, r=0; else y=x, r=32;
[ALL ] | ^~
[ALL ] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/src/internal/atomic.h:308:23: warning: right shift count >= width of type [-Wshift-count-overflow]
[ALL ] 308 | if (x>>32) y=x>>32, r=0; else y=x, r=32;
[ALL ] | ^~
[ALL ] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/arch/riscv64/atomic_arch.h: Assembler messages:
[ERROR] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/arch/riscv64/atomic_arch.h:29: Error: unrecognized opcode `lr.d.aqrl a0,(a3)'
[ERROR] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/arch/riscv64/atomic_arch.h:31: Error: unrecognized opcode `sc.d.aqrl a6,a2,(a3)'
[ERROR] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/arch/riscv64/atomic_arch.h:29: Error: unrecognized opcode `lr.d.aqrl a0,(a4)'
[ERROR] /home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/src/musl/arch/riscv64/atomic_arch.h:31: Error: unrecognized opcode `sc.d.aqrl a1,a3,(a4)'
[ERROR] make[1]: *** [Makefile:150: obj/src/ldso/dlerror.o] Error 1
[ALL ] make[1]: Leaving directory '/home/tommy/Downloads/crosstool-ng/.build/riscv64-unknown-linux-musl/build/build-libc/multilib_lib32_ilp32'
[ERROR]
[ERROR] >>
[ERROR] >> Build failed in step 'Building for multilib 2/5: ' -march=rv32imac -mabi=ilp32''
[ERROR] >> called in step 'Installing C library'
[ERROR] >> called in step '(top-level)'
[ERROR] >>
Quick update - a multilib Linux/musl toolchain can be built if t-linux-multilib
specifies only rv64 libs.
I used this local patch file:
to build an rv64 only multilib Linux/musl toolchain:
I also logged the issue here:
I'm not sure if anything can be done by CT-NG to deal with this.
Is it possible to have a patch file conditional on the configuration so that t-linux-multilib
could be patched to specify only rv64 libs if the configuration was RISC-V musl multilib but otherwise left as-is as specified in the GCC source tarball? Even if it is maybe it's beyond the remit of CT-NG?
My conclusion is that CT-NG could
t-linux-multilib
to only specify rv64 libs if Linux/musl is selected (if that's possible)BTW - another restriction should probably be to disallow 32 bit if Linux/musl is selected?
Description:
Builds of the bare metal, bare metal with multilibs and Linux (musl) toolchains work OK. But for the Linux (musl) multilib toolchain it fails as below. I think that the same issue arises with the Linux (glibc) multilib toolchain. I'll post back with more info when I have tried to investigate.
Details:
.config
(unless the issue is not related to any configuration): ct-ng.config.txtbuild.log
(unless crosstool-NG fails before the build starts): build-linux-musl-multilib.log.tar.gz