Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac5
-rw-r--r--docs/riscv.md100
-rw-r--r--mono/mini/mini-riscv.h1
-rw-r--r--mono/mini/mini.c1
-rw-r--r--mono/utils/mono-context.c8
-rw-r--r--mono/utils/mono-sigcontext.h4
6 files changed, 73 insertions, 46 deletions
diff --git a/configure.ac b/configure.ac
index ee535534791..1afcf0bffcb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -702,6 +702,11 @@ case "$host" in
have_sys_zlib=no
zlib_msg="bundled zlib"
;;
+ # Use bundled zlib on RISC-V for now to make cross-compiling easier.
+ riscv*)
+ have_sys_zlib=no
+ zlib_msg="bundled zlib"
+ ;;
*)
AC_CHECK_HEADER(zlib.h, [have_sys_zlib=yes], [have_sys_zlib=no])
if test x$have_sys_zlib = xyes; then
diff --git a/docs/riscv.md b/docs/riscv.md
index 53e42761514..559f5688503 100644
--- a/docs/riscv.md
+++ b/docs/riscv.md
@@ -2,36 +2,58 @@
These are some useful links and notes pertaining to the RISC-V port of Mono.
-## Useful RISC-V documents
+## Useful RISC-V documentation
-* [RISC-V User-Level ISA Specification](https://riscv.org/specifications/)
-* [RISC-V Privileged ISA Specification](https://riscv.org/specifications/privileged-isa/)
-* [RISC-V Debug Specification Standard](https://github.com/riscv/riscv-debug-spec/blob/master/riscv-debug-spec.pdf)
-* [RISC-V Assembly Programmer's Manual](https://github.com/riscv/riscv-asm-manual/blob/master/riscv-asm.md)
-* [RISC-V ELF psABI Specification](https://github.com/riscv/riscv-elf-psabi-doc/blob/master/riscv-elf.md)
+* [RISC-V User-Level ISA Specification](https://riscv.org/specifications)
+* [RISC-V Privileged ISA Specification](https://riscv.org/specifications/privileged-isa)
+* [RISC-V Debug Specification](https://riscv.org/specifications/debug-specification)
+* [RISC-V ELF psABI Specification](https://github.com/riscv/riscv-elf-psabi-doc)
+* [RISC-V C API Specification](https://github.com/riscv/riscv-c-api-doc)
+* [RISC-V Toolchain Conventions](https://github.com/riscv/riscv-toolchain-conventions)
+* [RISC-V Assembly Programmer's Manual](https://github.com/riscv/riscv-asm-manual)
## Useful RISC-V repositories
* [RISC-V Organization](https://github.com/riscv)
- * [RISC-V Linux](https://github.com/riscv/riscv-linux)
- * [RISC-V LLD](https://github.com/riscv/riscv-lld)
+ * [RISC-V GNU Toolchain](https://github.com/riscv/riscv-gnu-toolchain)
+ * [RISC-V Binutils](https://github.com/riscv/riscv-binutils-gdb)
+ * [RISC-V GCC](https://github.com/riscv/riscv-gcc)
+ * [RISC-V Glibc](https://github.com/riscv/riscv-glibc)
+ * [RISC-V Newlib](https://github.com/riscv/riscv-newlib)
* [RISC-V Tools](https://github.com/riscv/riscv-tools)
- * [RISC-V GNU Toolchain](https://github.com/riscv/riscv-gnu-toolchain)
- * [RISC-V Binutils](https://github.com/riscv/riscv-binutils-gdb)
- * [RISC-V GCC](https://github.com/riscv/riscv-gcc)
- * [RISC-V Glibc](https://github.com/riscv/riscv-glibc)
- * [RISC-V Newlib](https://github.com/riscv/riscv-newlib)
- * [RISC-V QEMU](https://github.com/riscv/riscv-qemu)
* [RISC-V Opcodes](https://github.com/riscv/riscv-opcodes)
* [RISC-V Tests](https://github.com/riscv/riscv-tests)
-* [lowRISC Organization](https://github.com/lowrisc)
- * [RISC-V LLVM](https://github.com/lowrisc/riscv-llvm)
## Setting up a cross environment
-Setting up a cross environment with a Linux toolchain and QEMU is quite easy.
+### Debian/Ubuntu packages
-First, add these to your `.bashrc` (or some other script that you run):
+This is the most painless way of getting a functional toolchain installed. Note
+that these packages may not be available on older distributions; this is tested
+on Ubuntu 19.04.
+
+First, add this to your `$HOME/.bashrc` (or some other script that you run):
+
+```bash
+export RISCV=$HOME/riscv
+export PATH=$RISCV/bin:$PATH
+export QEMU_LD_PREFIX=/usr/riscv64-linux-gnu
+```
+
+Next, install the toolchain packages like so:
+
+```bash
+# apt install autoconf automake binutils-riscv64-linux-gnu build-essential gcc-riscv64-linux-gnu gdb-multiarch g++-riscv64-linux-gnu libtool qemu qemu-system-misc qemu-user qemu-user-static
+```
+
+You will now have all the toolchain binaries in `/usr/bin`.
+
+### Building manually
+
+This approach may be somewhat unstable since you will be using the latest
+versions of the various parts of the toolchain.
+
+First, add this to your `$HOME/.bashrc` (or some other script that you run):
```bash
export RISCV=$HOME/riscv
@@ -39,47 +61,42 @@ export PATH=$RISCV/bin:$PATH
export QEMU_LD_PREFIX=$RISCV/sysroot
```
-Install some dependencies needed to build the toolchain:
+Next, install some dependencies needed to build the toolchain:
```console
-# apt install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev libusb-1.0-0-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev device-tree-compiler pkg-config libexpat-dev libglib2.0-dev libpixman-1-dev
+# apt install autoconf automake autotools-dev curl libmpc-dev libmpfr-dev libgmp-dev gawk build-essential bison flex texinfo gperf libtool patchutils bc zlib1g-dev libexpat-dev
```
-Now you can build the toolchain:
+Finally, build the toolchain:
```console
-$ git clone --recursive git@github.com:riscv/riscv-tools.git
-$ cd riscv-tools
-$ ./build.sh
+$ git clone --recursive git@github.com:riscv/riscv-gnu-toolchain.git
$ cd riscv-gnu-toolchain
-$ ./configure --prefix=$RISCV --enable-multilib
+$ ./configure --prefix=$RISCV --enable-linux --enable-multilib --with-arch=rv64imafdc --with-abi=lp64d
$ make linux
-$ cd ../..
-$ git clone --recursive git@github.com:riscv/riscv-qemu.git
-$ cd riscv-qemu
-$ mkdir build
-$ cd build
-$ ../configure --prefix=$RISCV --disable-werror
-$ make
-$ make install
```
+This will install the built toolchain binaries in `$RISCV/bin`.
+
## Building Mono with a cross toolchain
Building Mono is quite straightforward:
```console
-$ ./autogen.sh --prefix=$RISCV/sysroot --host=riscv64-unknown-linux-gnu
+$ ./autogen.sh --prefix=$RISCV/sysroot --host=riscv64-linux-gnu
$ make
$ make install
```
+(Note: You may need to use `--host=riscv64-unknown-linux-gnu` instead if you
+built the toolchain manually.)
+
You can set `CFLAGS` as appropriate to change the RISC-V options, such as which
standard extensions and ABI to use. For example, to use the 64-bit soft float
ABI:
```console
-$ CFLAGS="-mabi=lp64" ./autogen.sh --prefix=$RISCV/sysroot --host=riscv64-unknown-linux-gnu
+$ CFLAGS="-mabi=lp64" ./autogen.sh --prefix=$RISCV/sysroot --host=riscv64-linux-gnu
```
Note that, since this is a cross build, the `mcs` directory won't be built. You
@@ -89,19 +106,24 @@ Mono and copy them into `$RISCV/sysroot`.
You can run Mono with QEMU like this:
```console
-$ qemu-riscv64 $RISCV/sysroot/bin/mono hello.exe
+$ qemu-riscv64 ./mono/mini/mono hello.exe
```
## Debugging
+Debugging with GDB currently requires a manually built toolchain.
+
+It can be done like so:
+
```console
-$ qemu-riscv64 -g 12345 ./mono/mini/mono-sgen --interp basic.exe &
-$ riscv64-unknown-elf-gdb -ex 'target remote localhost:12345' -ex 'b main' -ex 'c' ./mono/mini/mono-sgen
+$ qemu-riscv64 -g 12345 ./mono/mini/mono --interp basic.exe &
+$ riscv64-unknown-elf-gdb -ex 'target remote localhost:12345' -ex 'b main' -ex 'c' ./mono/mini/mono
```
## Things to be done
-In no particular order:
+Things that need to be done beyond the basic 64-bit port, in no particular
+order:
* Complete the soft float port.
* Complete the 32-bit port.
diff --git a/mono/mini/mini-riscv.h b/mono/mini/mini-riscv.h
index 17c70451210..fe0bf9e5803 100644
--- a/mono/mini/mini-riscv.h
+++ b/mono/mini/mini-riscv.h
@@ -187,6 +187,7 @@ struct MonoLMF {
#define MONO_ARCH_INIT_TOP_LMF_ENTRY(lmf)
typedef struct {
+ guint8 *stack;
} CallContext;
enum {
diff --git a/mono/mini/mini.c b/mono/mini/mini.c
index 5a8d9eb1607..4df4a6885bd 100644
--- a/mono/mini/mini.c
+++ b/mono/mini/mini.c
@@ -4316,7 +4316,6 @@ mini_get_cpu_features (MonoCompile* cfg)
#endif
}
#endif
- MonoCPUFeatures features_ = features;
// apply parameters passed via -mattr
features = (MonoCPUFeatures) (features | mono_cpu_features_enabled);
diff --git a/mono/utils/mono-context.c b/mono/utils/mono-context.c
index 8dfc321c4a6..4db04eeb75c 100644
--- a/mono/utils/mono-context.c
+++ b/mono/utils/mono-context.c
@@ -578,8 +578,8 @@ mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx)
#else
ucontext_t *uctx = sigctx;
- memcpy (&mctx->gregs, &uctx->uc_mcontext.gregs, sizeof (host_mgreg_t) * G_N_ELEMENTS (mctx->gregs));
- memcpy (&mctx->fregs, &uctx->uc_mcontext.fpregs, sizeof (double) * G_N_ELEMENTS (mctx->fregs));
+ memcpy (&mctx->gregs, &uctx->uc_mcontext.__gregs, sizeof (host_mgreg_t) * G_N_ELEMENTS (mctx->gregs));
+ memcpy (&mctx->fregs, &uctx->uc_mcontext.__fpregs, sizeof (double) * G_N_ELEMENTS (mctx->fregs));
#endif
}
@@ -591,8 +591,8 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx)
#else
ucontext_t *uctx = sigctx;
- memcpy (&uctx->uc_mcontext.gregs, &mctx->gregs, sizeof (host_mgreg_t) * G_N_ELEMENTS (mctx->gregs));
- memcpy (&uctx->uc_mcontext.fpregs, &mctx->fregs, sizeof (double) * G_N_ELEMENTS (mctx->fregs));
+ memcpy (&uctx->uc_mcontext.__gregs, &mctx->gregs, sizeof (host_mgreg_t) * G_N_ELEMENTS (mctx->gregs));
+ memcpy (&uctx->uc_mcontext.__fpregs, &mctx->fregs, sizeof (double) * G_N_ELEMENTS (mctx->fregs));
#endif
}
diff --git a/mono/utils/mono-sigcontext.h b/mono/utils/mono-sigcontext.h
index a46f413b05b..254d7ab734b 100644
--- a/mono/utils/mono-sigcontext.h
+++ b/mono/utils/mono-sigcontext.h
@@ -555,8 +555,8 @@ typedef struct ucontext
#include <ucontext.h>
-#define UCONTEXT_GREGS(ctx) (((ucontext_t *) (ctx))->uc_mcontext.gregs)
-#define UCONTEXT_FREGS(ctx) (((ucontext_t *) (ctx))->uc_mcontext.fpregs)
+#define UCONTEXT_GREGS(ctx) (((ucontext_t *) (ctx))->uc_mcontext.__gregs)
+#define UCONTEXT_FREGS(ctx) (((ucontext_t *) (ctx))->uc_mcontext.__fpregs)
#define UCONTEXT_REG_PC(ctx) (UCONTEXT_GREGS ((ctx)) [REG_PC])
#define UCONTEXT_REG_BP(ctx) (UCONTEXT_GREGS ((ctx)) [REG_S0])
#define UCONTEXT_REG_SP(ctx) (UCONTEXT_GREGS ((ctx)) [REG_SP])