RISC-V GNU tools on Windows?

3,219 views
Skip to first unread message

Andrew Waterman

unread,
Nov 2, 2016, 2:32:32 PM11/2/16
to RISC-V SW Dev
Has anyone successfully built the RISC-V tools on Windows, either with
cygwin or Subsystem for Unix? If so, can you avail us of your wisdom?

Thanks,
Andrew

Tobias Strauch

unread,
Nov 2, 2016, 2:51:45 PM11/2/16
to RISC-V SW Dev
Andrew,

it is pretty straight forward, even I was able to do it on cygwin. There was just one little thing I needed to change, but I have to look it up first. I remember the FPGArduino guy mentioned it on the 4th WS as well.

I don’t now what you need it for, but

1) it's worth trying and modifying it yourself – guess you are very familiar with the process.
2) or contact the FPGArduino guy if he is not on the list.
3) let me know, I’ll dig into it when there isn't any smarter reply.

Cheers, Tobias


> Andrew Waterman <and...@sifive.com> hat am 2. November 2016 um 19:32 geschrieben:
> --
> You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
> To post to this group, send email to sw-...@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CA%2B%2B6G0C8%2BuqJo0wFjf%2BNubCf_PCM9anBzRTBQLHBCCeGpKAS6Q%40mail.gmail.com.

Ben Horgan

unread,
Nov 3, 2016, 7:44:26 AM11/3/16
to Tobias Strauch, RISC-V SW Dev
Hi all,

I was able to do this using msys2 but only with the resulting binaries linking to the msys-2.0.dll rather than msvcrt.dll. When trying to link to Microsoft runtime I got problems in libiberty, pex-win32.c can't find _open, _pipe etc. I also building in msys but the version of bison it has seemed too old. I needed to do a couple of patches. In sim/riscv/sim-main.c I changd CLOCK_BOOTTIME to CLOCK_MONOTONIC and I removed a use of __int128. (I think these issue may have since been fixed.) My goal in doing this was to get gcc that runs on windows to compile for a bare metal riscv core, this worked, and to get gdb running on windows for this core, I have only tested this runs. I would be interested in knowing about building this against the msvcrt.dll and if I have done anything odd.

I did this a little while ago so things may have changed.
bhorgan@UST19 MINGW64 /c/riscv/riscv-binutils-gdb (riscv-binutils-2.26)
$ git log
commit 7a54f96685d29b5d8713a07e10106131aa4650b0
Author: Tim Newsome <t...@sifive.com>
Date: Thu Jul 28 14:43:53 2016 -0700
bhorgan@UST19 MINGW64 /c/riscv/riscv-newlib (master)
$ git log
commit 77f0072999addb5d5b5c551baec21565aaf3a9e0
Author: Palmer Dabbelt <pal...@dabbelt.com>
Date: Fri Aug 12 11:13:18 2016 -0700
bhorgan@UST19 MINGW64 /c/riscv/riscv-gcc (riscv-gcc-6.1.0)
$ git log
commit e90d8dc6f429856510a51371d21dacd97ef68d41
Author: Andrew Waterman <wate...@cs.berkeley.edu>
Date: Mon Sep 12 11:56:36 2016 -0700

My steps:
Env:
$ export TARGET=riscv32-unknown-elf
$ export PREFIX=/c/riscv/$TARGET
$ export PATH=$PATH:$PREFIX/bin

binutils:
$ ./configure --target=$TARGET --prefix=$PREFIX --disable-werror --build=x86_64-pc-msys2
$ make all
$ make install

gcc first pass:
$ ../riscv-gcc/configure --build=x86_64-pc-msys2 --target=$TARGET --enable-werror=no --disable-nls --prefix=$PREFIX --without-headers --with-newlib --with-gnu-as --with-gnu-ld --enable-languages=c
$ make all-gcc
$ make install-gcc

newlib:
$ touch ../riscv-newlib/libgloss/riscv/memory.h # Is this a good idea?
$ ../riscv-newlib/configure --disable-werror --build=x86_64-pc-msys2 --target=$TARGET --prefix=$PREFIX --disable-multilib
$ make all
$ make install

gcc again:
$ rm -rf *
$ ../riscv-gcc/configure --build=x86_64-pc-msys2 --target=$TARGET --enable-werror=no --disable-nls --prefix=$PREFIX --with-newlib --with-gnu-as --with-gnu-ld --disable-shared --disable-libssp --disable-multilib --enable-languages=c
$ make all
$ make install

Cheers

Ben
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/222553867.194758.1478112702444%40webmail.strato.com.

Andrew Waterman

unread,
Nov 3, 2016, 12:06:48 PM11/3/16
to Ben Horgan, Tobias Strauch, RISC-V SW Dev
Hi Ben,

Did you happen to try using Microsoft's POSIX emulation layer (SFU, or whatever)?

Thanks for the info. I think the CLOCK_MONOTONIC issue has been fixed independently.

Andrew

Ben Horgan

unread,
Nov 3, 2016, 12:28:35 PM11/3/16
to Andrew Waterman, Tobias Strauch, RISC-V SW Dev

Hi Andrew,

 

No, I didn’t try SUA/SFU. I have windows 7 professional and so this is not available for me.

 

Thanks

 

Ben

Tommy Murphy

unread,
Feb 15, 2017, 4:55:46 PM2/15/17
to RISC-V SW Dev
I know it's an old(ish) thread but just though I'd bump it.
I've been building the bare metal/newlb tools for RV32IM on Windows via MSYS2/MinGW-64 in case that's of interest to anybody.
Note that building this way yields "native" binaries with no dependency on stuff like the cygwin1.dll etc.
It does require some MSYS2/MinGW DLLs to be bundled in the tools bin folder but otherwise doesn't require any additional "subsystem" over and above Windows itself.
If it is of interest to anybody then I can post details of the steps that I take including a few hacks that I have found necessary to get things going.
Unfortunately the 32 bit Windows binary build does not work - gdb crashes easily and I haven't had a chance to investigate/debug to see where/why.
So I am using the 64 bit Windows binary builds (don't ask but I'd prefer to use the 32 bit binaries if possible :-).

Now my ulterior motive... :-)
Anybody got any tips on building riscv-qemu for Windows (via MSYS2/MinGW-64 or Cygwin or whatever - even cross compilation from linux targeting Windows/MinGW?)?
I want to be able to test the Windows build of the tools but so far haven't managed to do so.

BTW - thanks to Andrew's guidance I learned that the default test suite use of gdb-sim is not really useful at the moment and he explained how to modify things to use qemu instead which yields better results.
Again if anybody's interested I can explain the steps.

Thanks
Tommy

Marko Zec

unread,
Feb 16, 2017, 6:19:15 AM2/16/17
to RISC-V SW Dev, Tommy Murphy
On Wed, 15 Feb 2017 13:55:46 -0800
Tommy Murphy <tommy_...@hotmail.com> wrote:

> I know it's an old(ish) thread but just though I'd bump it.
> I've been building the bare metal/newlb tools for RV32IM on Windows
> via MSYS2/MinGW-64 in case that's of interest to anybody.
> Note that building this way yields "native" binaries with no
> dependency on stuff like the cygwin1.dll etc.
> It does require some MSYS2/MinGW DLLs to be bundled in the tools bin
> folder

Actually it doesn't: if you build the tools with LDFLAGS=-static, which
apparently became possible (again) with recent snapshots of riscv
binutils and gcc, all the MSYS2/MinGW libraries will be statically
compiled. Still, the standard M$ system DLLs will have to be linked at
runtime, but this shouldn't be a problem.

If anyone is interested, a bundle of "statically" linked win32 binaries
of a recent toolchain snapshot (RISCV + MIPS) can be found here:

http://www.nxlab.fer.hr/fpgarduino/bm/f32c-win32-toolchain-6_1.zip

Marko

Andrew Waterman

unread,
Feb 16, 2017, 1:04:39 PM2/16/17
to Marko Zec, RISC-V SW Dev, Tommy Murphy
Marko, Tommy,

It would be great if one of you could make a pull request against
riscv-tools's README.md with brief instructions on how to carry out
the build (i.e., what prereqs to install, and any steps that deviate
from the *nix build).

Andrew
> --
> You received this message because you are subscribed to the Google Groups "RISC-V SW Dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sw-dev+un...@groups.riscv.org.
> To post to this group, send email to sw-...@groups.riscv.org.
> Visit this group at https://groups.google.com/a/groups.riscv.org/group/sw-dev/.
> To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/20170216122000.192b72eb%40x23.

Tommy Murphy

unread,
Feb 18, 2017, 1:20:57 PM2/18/17
to RISC-V SW Dev, tommy_...@hotmail.com
On Thursday, 16 February 2017 11:19:15 UTC, zec wrote:

Actually it doesn't: if you build the tools with LDFLAGS=-static, which
apparently became possible (again) with recent snapshots of riscv
binutils and gcc, all the MSYS2/MinGW libraries will be statically
compiled.  Still, the standard M$ system DLLs will have to be linked at
runtime, but this shouldn't be a problem.

Hi Marko - how exactly do you do this?
I tried both

./configure ... LDFLAGS=-static
make

and 

export LDFLAGS=-static
./configure
make

but neither resulted in statically linked binaries.

Thanks
Tommy

Marko Zec

unread,
Feb 18, 2017, 2:25:41 PM2/18/17
to Tommy Murphy, RISC-V SW Dev
I use this script:

https://github.com/f32c/f32c/blob/master/src/compiler/build.sh

For MSYS2 I have to comment out the LDFLAGS line, and nullify the SUDO
as well, as MSYS has no sudo, that should be it

Marko Zec

unread,
Feb 18, 2017, 2:34:53 PM2/18/17
to Tommy Murphy, RISC-V SW Dev
On Sat, 18 Feb 2017 20:26:32 +0100
Marko Zec <z...@fer.hr> wrote:
...
> I use this script:
>
> https://github.com/f32c/f32c/blob/master/src/compiler/build.sh
>
> For MSYS2 I have to comment out the LDFLAGS line, and nullify the SUDO

s/comment out/uncomment/ , sorry for the typo...

ganson

unread,
Mar 15, 2017, 3:33:45 AM3/15/17
to RISC-V SW Dev, tommy_...@hotmail.com
Dear,

I try this.
then I can see following files in MSYS2 folder
mips-elf-c++.exe
mips-elf-g++.exe
mips-elf-gcov.exe
mips-elf-gcov-tool.exe
riscv32-elf-c++.exe
riscv32-elf-g++.exe
riscv32-elf-gcov.exe
riscv32-elf-gcov-tool.exe

but actually I need files like

riscv64-unknown-elf-gcc.exe
riscv64-unknown-elf-objdump


Thans a lot.


在 2017年2月19日星期日 UTC+8上午3:25:41,zec写道:

Tommy Murphy

unread,
Mar 15, 2017, 4:00:02 AM3/15/17
to RISC-V SW Dev
You need to build the tools with --with-arch=rv64xxx where xxx is whatever extensions your rv64 target supports.

Sober Liu

unread,
Jul 2, 2017, 11:06:24 AM7/2/17
to Andrew Waterman, Marko Zec, RISC-V SW Dev, Tommy Murphy
Yes, it will be very helpful.
In fact I just tried to build riscv-tools with latest Cygwin (including gcc 5.4.0).
I see 2 issues from my side for fesvr build:
1. /usr/include/machine/types.h:74:15: error: conflicting declaration ‘typedef char* addr_t’
../fesvr/memif.h:11:15: note: previous declaration as ‘typedef reg_t addr_t’
2. strnlen missing in Cygwin.


-----Original Message-----
From: Andrew Waterman [mailto:and...@sifive.com]
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/CA%2B%2B6G0Bdz0T4NTweVsnYEiWJu8AcVGUfFaSMto1-GNQ64czRtg%40mail.gmail.com.

-----------------------------------------------------------------------------------
This email message is for the sole use of the intended recipient(s) and may contain
confidential information. Any unauthorized review, use, disclosure or distribution
is prohibited. If you are not the intended recipient, please contact the sender by
reply email and destroy all copies of the original message.
-----------------------------------------------------------------------------------

Sober Liu

unread,
Jul 6, 2017, 11:22:15 AM7/6/17
to Andrew Waterman, Marko Zec, RISC-V SW Dev, Tommy Murphy
Let me share Cygwin build status from my side.
I get problem in following modules:
- for riscv-fesvr, I have to use window branch from: https://github.com/firesim/riscv-fesvr.
- for riscv-isa-sim, I cannot find a valid device-tree-compiler for Cygwin. Then I didn't try riscv-pk.
- Passed with riscv-openocd and riscv-gnu-toolchain.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/sw-dev/be52340313074fa18f4857b78f7d4e8c%40HKMAIL101.nvidia.com.

Liviu Ionescu

unread,
Jul 6, 2017, 11:34:31 AM7/6/17
to Sober Liu, Andrew Waterman, Marko Zec, RISC-V SW Dev, Tommy Murphy

probably not directly related to the thread, but perhaps useful:

the Eclipse CDT managed projects use automatically generated make files. to run the build on windows, the GNU MCU Eclipse project provides a set of windows binaries (make, rm, echo, sh, etc), packed as the [GNU MCU Eclipse Windows Build Tools](https://github.com/gnu-mcu-eclipse/windows-build-tools).

if needed, these tools can be also used outside Eclipse.


regards,

Liviu


Reply all
Reply to author
Forward
0 new messages