bug-mes
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Porting mes to RISC-V 64 bit


From: Jan Nieuwenhuizen
Subject: Re: Porting mes to RISC-V 64 bit
Date: Mon, 05 Apr 2021 07:50:50 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

W. J. van der Laan writes:

Hello!

> Over the weekend I have been working on porting mes to RISC-V. I am
> aiming for RV32IM and RV64IM e.g. `riscv32-unknown-linux-elf` and
> `risc64-unknown-linux-elf`. But 64-bit is my primary aim at the moment
> because it is a more common architecture for Linux RISC-V.

That's beautiful.  Just a heads-up: Please note that Mes currently does
not fully support any 64bit platform yet.  For x86_64-linux it passes
most of the test set, however, we haven't built a functional tinycc yet
with MesCC.

> I got as far as having `mes-gcc` run on my SiFive Unleashed board, as
> well as having the scaffold and mes tests pass for gcc (except
> for 70-extern and 80-setjmp which seem really impractical to handle
> for gcc). `mescc` also gets to the help message but I haven't adapted
> it in any way for the architecture yet.

OK, no harm in taking small steps ;-)

> The most work was adapting the syscall interface. RISC-V Linux uses
> asm-generic's syscall list which has removed many of the legacy
> syscalls. I've switched to using more modern replacements but only for
> RV64, other architectures should be unaffected.

Very good.

> I expect that the biggest challenge in getting mescc to generate
> RISC-V binaries is the assumption that there is a persistent flags
> register (arch:a?->r and such). RISC-V instead has instructions that
> compare a register against another register or zero and branch / set a
> value directly. So some refactoring outside the architecture-specific
> module will be needed.

Okay.  Stumbling on x86-specific choices was bound to happen at some
time.  Let's look at simple examples/tests and see what can be done.

> A required patch to hex2_linker is on the 'riscv' branch here:
> https://github.com/laanwj/guix-mescc-tools

Great!  I'm sure Jeremiah will pick that up.

> The latest state of my work can be found on the 'riscv64' branch here:
> https://github.com/laanwj/guix-mes

> How does the development process work? Should I send patches to this
> mailing list for review when they are ready?

Yes, for Mes please do.  I took a look at your branch, please note that
Mes uses GNU ChangeLog like commit messages.  You can look at previous
commits for inspiration.

    
https://www.gnu.org/software/mes/manual/html_node/Submitting-Patches.html#Submitting-Patches

If you're an Emacs user, using Magit is a great help there.  Please ask
if you need any help.

We may want to keep your work on a "wip-riscv" branch for a while to
mature and see that the x86 bootstrap does not break.  Also, I'm working
to integrate the full-source bootstrap work (the wip-m2 branch).  That's
quite an operation, we may want to integrate your work first if it's
ready sooner but we probably don't want to mix those efforts.

Thanks a lot for doing this work!

Greetings,
Janneke

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]