Multilib support in Chipyard toolchains?

233 views
Skip to first unread message

baltaz...@gmail.com

unread,
Jul 15, 2020, 4:24:15 PM7/15/20
to Chipyard
This has been somewhat discussed in other threads, but I seem to be running into a slightly different issue.

I'm trying to compile a test in the chipyard `tests` directory for 32 bit. I added `-march=rv32ima -mabi=ilp32` to the Makefile CFLAGS. This seems to compile okay, but then I hit a bunch of linking errors along the lines of

> riscv-tools-install/lib/gcc/riscv64-unknown-elf/9.2.0/crtend.o: ABI is incompatible with that of the selected emulation:
>  target emulation `elf64-littleriscv' does not match `elf32-littleriscv'

and

> riscv64-unknown-elf/lib/crt0.o: file class ELFCLASS64 incompatible with ELFCLASS32

I tried adding `--enable-multilib` to both libgloss and gcc in the toolchain install script, but it doesn't help. When I use a non-chipyard compiled riscv32 gcc, I get issues in the libgloss makefile ("configure: error: The target architecture of the C compiler does not appear to be RISC-V." even though this is definitely a riscv32 GCC).

Is there a clean way to compile for 32 bit in a way that incorporates the htif linker script?

Albert Ou

unread,
Jul 16, 2020, 6:48:58 PM7/16/20
to chip...@googlegroups.com
rv32ima-ilp32 is not one of the default multilib combinations enabled in
riscv-gnu-toolchain. You will need to modify and regenerate configure.ac
yourself:

https://github.com/riscv/riscv-gnu-toolchain/blob/256a4108922f76403a63d6567501c479971d5575/configure.ac#L106

The libgloss configure test is quite definitive, as it checks that the
__riscv built-in macro is defined. If running configure manually, you
must pass the correct --host triplet (as the error message helpfully
suggests), or autoconf instead detects the native gcc.

> Is there a clean way to compile for 32 bit in a way that incorporates the
> htif linker script?
>

It is usually simpler to dispense with multilib and build an ELF
toolchain for the exact march/mabi combination desired by using the
--with-arch and --with-abi configure options. Then libgloss can be
built and used as usual (after providing --host), since gcc will just
use the default target in the absence of -march or -mabi.

> --
> You received this message because you are subscribed to the Google Groups "Chipyard" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to chipyard+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/chipyard/64981411-f70d-4d73-ad6e-bdecd04cf72en%40googlegroups.com.

--
Albert Ou

baltaz...@gmail.com

unread,
Jul 23, 2020, 4:10:46 PM7/23/20
to Chipyard
Thanks! I realized I actually only needed rv32im-ilp32, which is supported. Thanks for pointing out where to check that!
Reply all
Reply to author
Forward
Message has been deleted
0 new messages