Fedora/RISC-V architecture emulation Docker containers updated

156 views
Skip to first unread message

Stefan O'Rear

unread,
Sep 26, 2016, 2:47:10 AM9/26/16
to RISC-V SW Dev
# TLDR

`docker run -it sorear/fedora-riscv-wip`

Inspect and run the resulting configuration command, then start the
container again

```
[root@f149d30f7627 /]# rpm -i
/var/tmp/RPMS/riscv64/binutils-2.27-3.fc25.riscv64.rpm
[root@f149d30f7627 /]# objdump -d /bin/objdump | head

/bin/objdump: file format elf64-littleriscv


Disassembly of section .plt:

00000000000274f0 <__vsnprintf_chk@plt-0x20>:
274f0: 00042397 auipc t2,0x42
274f4: 41c30333 sub t1,t1,t3
274f8: b103be03 ld t3,-1264(t2) # 69000
<warn@@Base+0xa4d8>
```

# CHANGES

* Most significantly, the new version is now based on the "stage4"
images just announced by Richard W.M. Jones. That means:
* Everything in the container except the startup script and the
qemu binary is managed by RPM
* All of the packages except gcc and kernel-headers are built by
the normal rpmbuild mechanism from something close to the official
Fedora sources
* For quite a few of the packages they are built from _exactly_
the official Fedora sources
* qemu-riscv64 is updated, fixing several bugs I've encountered
* I added a small amd64 startup binary to the image which detects
binfmt_misc problems and tells you what to do about them, so now you
can just run the image _first_ and go from there.
* There are a small number of functional regressions associated with
stage4. These will be addressed by the porting effort.
* Vim is no longer available (use nano, or just share a folder and
edit outside the container)
* iconv mostly doesn't work
* the /bin/cc symlink is missing and you may need to manually add it

# README

This is the RISC-V Fedora userland from Richard W.M. Jones et al,
repackaged for Docker with the QEMU user emulator fork developed by
Alex Suykov.

* About RISC-V: https://riscv.org/
* Fedora coordinaton page: https://fedoraproject.org/wiki/Architectures/RISC-V
* QEMU fork: https://github.com/arsv/riscv-qemu
* Build script for this image: https://github.com/sorear/fedora-riscv-useremu

To set up a RISC-V userland testing environment, use:

docker run -it sorear/fedora-riscv-wip

You will need binfmt_misc configured in order to actually use this;
the container checks this, and will print instructions (or if run with
--privileged it can do the configuration itself; don't do this if you
care about the host integrity, because that turns off the sandbox).

That image includes a large set of compiled RPMs suitable for basic
development. You can instead download a much smaller image,
`sorear/fedora-riscv-wip:minimal`, (109 MB versus 667 MB), and
download RPMs as needed from the [coordination site][RPMS]. Once we
have dnf working on RISC-V this will probably become the preferred
option.

[RPMS]: https://fedorapeople.org/groups/risc-v/RPMS

---

The dev environment must be installed from RPMs using the rpm or tdnf
command, for instance:

tdnf --releasever 25 install libffi-devel libtool-ltdl-devel m4

The files are installed in /var/tmp/RPMS, or can be downloaded with
curl; the kernel-headers package is necessary for most tasks but is
not in either image and can be fetched at:

https://fedorapeople.org/groups/risc-v/SRPMS/kernel-headers-4.1.26-1.fc25.src.rpm

A list of package that you probably want to install before trying to
compile anything is in the autobuilder:

https://github.com/rwmjones/fedora-riscv-autobuild/blob/4b78ecf5/autobuild.ml#L174

After installing those, kernel-headers, m4, libtool-ltdl-devel, and
libffi-devel, and replacing iconv with a link to /bin/true, I was able
to rebuild the source package gforth-0.7.3-3.fc24.src.rpm as a test.

Stefan O'Rear

unread,
Sep 29, 2016, 1:54:14 AM9/29/16
to RISC-V SW Dev
Sorry to post again so soon but there is a major usability
improvement: tdnf now works over the Internet out of the box, so we no
longer need to ship the 660MB image with hundreds of RPMs, :latest now
points at an image with tdnf that can pull RPMs as needed. (It's a
bit larger than the old :minimal, at 152 MB, because it includes gcc
due to some temporary dependency problems.)

Packages needed for package building:

tdnf install -y bash bzip2 coreutils cpio diffutils elfutils
fedora-release findutils gawk hack-gcc glibc-headers grep gzip info
make patch redhat-rpm-config rpm-build sed shadow-utils tar unzip
util-linux which xz

The image has also been switched to use the RISC-V foundation's QEMU
tree since the user-mode changes have [been
merged](https://github.com/riscv/riscv-qemu/pull/25).

-s
Reply all
Reply to author
Forward
0 new messages