Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RISC-V support. #208

Closed
wants to merge 1 commit into from
Closed

Add RISC-V support. #208

wants to merge 1 commit into from

Conversation

shlevy
Copy link
Contributor

@shlevy shlevy commented Feb 18, 2018

@shlevy
Copy link
Contributor Author

shlevy commented Feb 18, 2018

Currently only compile-tested on risc64, will report back when runtime tested. Thanks to @sorear for the pointers.

@shlevy
Copy link
Contributor Author

shlevy commented Feb 18, 2018

I've now done some light runtime testing (via the repl for the nix expression language) and all seems good so far. Do you have a stress test I can run?

@ivmai
Copy link
Owner

ivmai commented Feb 19, 2018

Requires ivmai/libatomic_ops#32

No, it does not. The code in master branch relies on GCC built-in primitives if test_atomic_ops passes.

ivmai pushed a commit that referenced this pull request Feb 19, 2018
Issue #208 (bdwgc).

* include/private/gcconfig.h [__riscv && LINUX && __riscv_xlen==32]
(RISCV32, mach_type_known): Define macro.
* include/private/gcconfig.h [__riscv && LINUX && __riscv_xlen==64]
(RISCV64, mach_type_known): Define macro.
* include/private/gcconfig.h [RISCV32 || RISCV64] (CPP_WORDSZ,
MACH_TYPE, ALIGNMENT): Likewise.
* include/private/gcconfig.h [(RISCV32 || RISCV64) && LINUX] (OS_TYPE,
DATASTART, LINUX_STACKBOTTOM, DYNAMIC_LOADING): Likewise.
* include/private/gcconfig.h [(RISCV32 || RISCV64) && LINUX]
(__data_start): Declare external variable.
@brucehoult
Copy link
Contributor

brucehoult commented Feb 19, 2018

@palmer-dabbelt would you have a chance to test Boehm GC native on Hifive Unleashed? Should take under five minutes of your time (it took 4m30s on a Raspberry pi just now, 2m30s on an Odroid C2 (1.5 GHz A53)).

git clone git://github.com/ivmai/bdwgc.git
cd bdwgc
./autogen.sh
./configure
make -j4
make check

@ivmai
Copy link
Owner

ivmai commented Feb 19, 2018

After merging your patch, I found another variant of the patch (https://github.com/AOSC-Dev/aosc-os-abbs/blob/staging/base-libs/gc/autobuild/patches/gc-riscv.patch) created by @Icenowy (the difference is in DATAEND and DYNAMIC_LOADING).

@shlevy
Copy link
Contributor Author

shlevy commented Feb 19, 2018

@ivmai I will verify that DYNAMIC_LOADING works here. How can I determine which DATAEND is correct?

@shlevy
Copy link
Contributor Author

shlevy commented Feb 19, 2018

Ah, I'll do a native build and run the tests when I get my native toolchain bootstrapped.

@ivmai
Copy link
Owner

ivmai commented Feb 19, 2018

the difference is in DATAEND and DYNAMIC_LOADING

I'm sorry, no difference (DYNAMIC_LOADING exists in both patches, DATA is defined to _end by default).
So your patch is OK, I've merged it already. The only thing, I think, it would be nice to collapse RISCV32/64 cases into single RISCV (like it is done e.g. for MIPS which could be both 32 and 64-bit too).

@shlevy
Copy link
Contributor Author

shlevy commented Feb 19, 2018

@ivmai OK, I'll do that, thanks!

@shlevy
Copy link
Contributor Author

shlevy commented Feb 19, 2018

Merged in 4f7f0ee

@shlevy shlevy closed this Feb 19, 2018
@shlevy shlevy deleted the riscv branch February 19, 2018 15:33
ivmai pushed a commit that referenced this pull request Feb 20, 2018
(code refactoring of commit 4f7f0ee)

Issue #208 (bdwgc).

* include/private/gcconfig.h [__riscv && LINUX] (RISCV32, RISCV64):
Replace with RISCV.
* include/private/gcconfig.h [RISCV] (MACH_TYPE): Change to "RISC-V".
* include/private/gcconfig.h [RISCV] (CPP_WORDSZ, ALIGNMENT): Define
using __riscv_xlen.
@palmer-dabbelt
Copy link

@brucehoult Can you point me to a disk image (which you could generate with QEMU) that has all the stuff you want me to run, and then I can run it on the board? I can't figure out how to use Fedora :)

@brucehoult
Copy link
Contributor

@palmer-dabbelt that's exactly why I pinged you .. it's tooooo hard to do with cross compilers and qemu and just busybox (especially given this stuff is just in my copious free time), but I figured you'd have a real GNU userland and toolchain on your board by now :-)

It's not exactly urgent,. It would be good to have once people start to have real boards in their hands, but once we have real boards in our hands we can do it easily. I sounds as if Fedora will be there by the end of next month.

Did I get the correct impression that one of the *BSDs is done and ready to go?

@palmer-dabbelt
Copy link

Fedora should have native toolchain packages now... :)

@rwmjones
Copy link

Fedora image is here: https://fedorapeople.org/groups/risc-v/disk-images/ and indeed it is true that we have a native toolchain based on gcc 7.3.1, binutils 2.30 and glibc 2.27. You need to read the readme file in that link to understand how to use it.

I am running the test above using the latest version from git (f9c5815). Will report back once it has finished.

@rwmjones
Copy link

Note these results are on qemu, not on real hardware. I used -smp 4 to emulate 4 CPUs.

PASS: cordtest
./test-driver: line 107:  4801 Aborted                 (core dumped) "$@" > $log_file 2>&1
FAIL: gctest
PASS: leaktest
PASS: middletest
PASS: smashtest
PASS: hugetest
PASS: realloc_test
PASS: staticrootstest
PASS: test_atomic_ops
PASS: threadleaktest
PASS: threadkey_test
PASS: subthreadcreate_test
PASS: initsecondarythread_test
PASS: disclaim_test
PASS: disclaim_bench
============================================================================
Testsuite summary for gc 7.7.0
============================================================================
# TOTAL: 15
# PASS:  14
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See ./test-suite.log
Please report to https://github.com/ivmai/bdwgc/issues
============================================================================

I'll see if I can get a stack trace from the failure.

@rwmjones
Copy link

rwmjones commented Feb 27, 2018

FAIL: gctest
============

Typed alloc failed at 15921
Test failed
FAIL gctest (exit status: 134)

I just realised we don't have gdb, and we're some way from having it, so no stack trace for a while ... If there's anything else that can be done to diagnose problems (verbose mode?) let me know.

@ivmai ivmai mentioned this pull request Feb 28, 2018
@ivmai
Copy link
Owner

ivmai commented Feb 28, 2018

I've created #212 for the test failure.

ivmai pushed a commit that referenced this pull request Apr 26, 2018
(back-port of commits 4f7f0ee, 3b008f7 from 'master')

Issue #208 (bdwgc).

* include/private/gcconfig.h [__riscv && LINUX] (RISCV,
mach_type_known): Define macro.
* include/private/gcconfig.h [RISCV] (MACH_TYPE): Likewise.
* include/private/gcconfig.h [RISCV && LINUX] (OS_TYPE, DATASTART,
LINUX_STACKBOTTOM, DYNAMIC_LOADING): Likewise.
* include/private/gcconfig.h [RISCV && LINUX] (__data_start): Declare
external variable.
* include/private/gcconfig.h [RISCV] (CPP_WORDSZ, ALIGNMENT): Define
using __riscv_xlen.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants