c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Add Riscv Example

Open chuckb opened this issue 1 year ago • 7 comments

I took a guess as to how you might organize these kinds of examples. Also, one thing I could add to this example is the ability to cleanly exit the qemu host via semihosting (I have an example working in another project). That way, this could be integrated with CI as a multi-arch test suite.

chuckb avatar Jul 29 '24 23:07 chuckb

Can we get this into the CI in some way? Like during build on linux it downloads qemu and runs the example?

lerno avatar Jul 30 '24 01:07 lerno

Yep. That can be done - next few days...I'll get back to you.

chuckb avatar Jul 30 '24 03:07 chuckb

So, not being too familiar with github ci...it looks like starting at line 219 of .github/workflows/main.yml I'd add dependencies for qemu and the risc-v toolchain. Then I'd add a runner entry somewhere after line 274 for make run within my project, assuming that my app kills qemu when Hello World is printed and then presumably checks for that string on the console?

So I've forked your project...can I somehow test my changes to CI before another PR to you?

chuckb avatar Jul 30 '24 03:07 chuckb

At the top of the CI there is this:

on:
  push:
    branches: [ master, dev, ci_testing, experiments ]
  pull_request:
    branches: [ master, dev ]

So if you rename your branch "ci_testing" then the CI ought to immediately kick in when you push.

lerno avatar Jul 30 '24 11:07 lerno

Can you place the CI together with the rest of the CI? Right now it's a separate yml file.

lerno avatar Jul 30 '24 20:07 lerno

Yes, I will. I am trying just to strip this down to just what I need to get my piece working, then I'll add my additions to your master file. But I am stuck on a Risc-v ISA version mismatch at the moment and researching it. If you can shed light, that would be great. FYI...not encountering this on my local wks.

OSX Ventura 13.6.7. C3 installed with homebrew:

$ c3c --version
C3 Compiler Version:       0.5.5
Installed directory:       /usr/local/Cellar/c3c/0.5.5_1/bin/
LLVM version:              18.1.4
LLVM default target:       x86_64-apple-darwin22.6.0

as/ld:

$ riscv64-unknown-elf-as --version
GNU assembler (GNU Binutils) 2.42
Copyright (C) 2024 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `riscv64-unknown-elf'.

gcc:

$ riscv64-unknown-elf-gcc --version
riscv64-unknown-elf-gcc (gc891d8dc23e) 13.2.0
Copyright (C) 2023 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

chuckb avatar Jul 30 '24 22:07 chuckb

Ok, I have the CI merged and my addition working, altho testproject is failing...I don't think that was me ;-). Sorry for my messy commits. I'd like to do some more examples...maybe using opensbi and 64-bit. Or perhaps other archs. I like this project.

chuckb avatar Jul 30 '24 23:07 chuckb

Ok, I'll grab this onto my machine and see if I can figure why the testproject fails. Thanks for all the hard work so far.

lerno avatar Jul 31 '24 10:07 lerno

Some broken CI, but this is now due to LLVM making a bad release (not the first time)

lerno avatar Jul 31 '24 12:07 lerno

Thank you!

lerno avatar Jul 31 '24 12:07 lerno