From Fedora Project Wiki
(Remove old stuff and add pointer to repo.)
Line 1: Line 1:
{{admon/caution|Bootstrapping is over, this page is obsolete.  To find out how to build packages, please read [[Architectures/RISC-V/Building]] }}
 
 
 
All about bootstrapping Fedora on [[Architectures/RISC-V|RISC-V]].
 
All about bootstrapping Fedora on [[Architectures/RISC-V|RISC-V]].
  
 
= Introduction =
 
= Introduction =
  
We are currently building RPMs using the stage3 environment, using the rpmbuild command on RISC-V (under qemu emulation).  [https://github.com/rwmjones/fedora-riscv/blob/master/README This is step (4a) in the README.]
+
Bootstrapping happens in several stages which are outlined in the README and Makefile in [https://github.com/rwmjones/fedora-riscv-bootstrap this repository].
 
 
We aim to build just enough userspace RPMs so that we can:
 
 
 
* create a stage4 environment which is cleanly built from only RPMs
 
* the stage4 environment will be able to run gcc and rpmbuild
 
* the stage4 environment will (later) be used to build all future RPMs
 
 
 
Some packages require non-upstream patches for RISC-V.  Currently these are:
 
 
 
* kernel <i>(we are not building this as an RPM yet because there is no bootloader that could use it)</i>
 
* glibc
 
* binutils
 
* gcc
 
 
 
Some packages require modifications to the spec file to reduce extraneous dependencies, disable tests, hacks and so on.  The aim is to reduce and eliminate these changes in stage4, but they are OK for now in stage3 RPMs.
 
 
 
noarch RPMs do not need to be rebuilt.  They can just be copied over from Koji.
 
 
 
= Status =
 
 
 
All built RPMs are added to the [https://github.com/rwmjones/fedora-riscv/tree/master/stage3-built-rpms stage3-built-rpms/ subdirectory of git], with the SRPM so we can reproduce the build.
 
 
 
= Semi-automatically building packages in stage3 =
 
 
 
This basically automates the process described in the next section.
 
 
 
fedpkg clone -B the_package
 
cd the_package/f25
 
# make changes to spec file if you want
 
fedpkg srpm
 
 
 
make stage3-build SRPM=/path/to/the_package.src.rpm
 
 
 
= Manually building packages in stage3 =
 
 
 
The stage3 environment can be built from source or you can download a snapshot binary image.  See above for links to git etc.
 
 
 
Pick a package which:
 
* has very few dependencies
 
* is written in C or C++
 
* is part of Fedora [https://github.com/rwmjones/fedora-riscv/blob/master/packages-in-core @Core]
 
 
 
Grab the source RPM from [http://koji.fedoraproject.org/koji/ the F25 branch in Koji] or dist-git.  Note you must use the F25 branch, because otherwise Perl doesn't work.
 
 
 
fedpkg clone -B the_package
 
cd the_package/f25
 
# make changes to spec file if you want
 
fedpkg srpm
 
 
 
Copy the source RPM into the stage3 disk image.  The disk image <b>must not</b> be running when you do this:
 
 
 
virt-copy-in -a stage3-disk.img the_package.src.rpm /var/tmp/
 
 
 
Boot the disk image in qemu:
 
 
 
make boot-stage3-in-qemu
 
 
 
Inside the VM you may need to install some of the RPMs we have already built.  Almost certainly you'll need make and bash:
 
 
 
rpm -Uvh /rpmbuild/RPMS/riscv64/{bash,make}-*.rpm --nodeps
 
 
 
Inside the VM you can now "install" the source RPM, which makes it available under <code>/rpmbuild</code>:
 
 
 
rpm -i /var/tmp/the_package.src.rpm
 
cd /rpmbuild/SPECS
 
 
 
You may need to disable hardened build and debuginfo by adding:
 
 
 
%global debug_package %{nil}
 
%undefine _hardened_build
 
 
 
to the spec file.  Use <code>vim</code> to edit files.
 
 
 
You can now try building the package:
 
 
 
rpmbuild -ba the_package.spec --nodeps
 
 
 
If it builds successfully, brilliant!  More usually this will require many cycles of debugging and fixing things.  Removing dependencies or parts of the spec file is an option for these stage3 builds.
 
 
 
If you get a build, it will be in <code>/rpmbuild</code> inside the VM.  sync and shut down the VM, then do:
 
 
 
virt-copy-out -a stage3-disk.img /rpmbuild ./
 
 
 
and the files will be downloaded to ./SRPMS and ./RPMS in the current directory.  Note: Keep the source RPM too, especially if you modified it.
 
 
 
Add notes to the section below.  Also come to <code>#fedora-riscv</code> and discuss where to put your built packages.
 
 
 
= Notes on typical bugs etc =
 
 
 
== "all-recursive" bug in make ==
 
 
 
Making all in .
 
Makefile:742: recipe for target 'all-recursive' failed
 
 
 
This is a bug in either the cross-compiled <code>make</code> or the cross-compiled <code>bash</code>.  It is fixed by the natively compiled make and/or bash, so to fix it just run the following command from within the stage3 environment:
 
 
 
rpm -ivh /rpmbuild/RPMS/riscv64/bash-* /rpmbuild/RPMS/riscv64/make-* --nodeps
 
 
 
== debugedit missing ==
 
 
 
Use <code>%global debug_package %{nil}</code> (temporarily for stage3, in stage4 we will attempt to build the debuginfo packages).
 
 
 
== bugs about locking, random "Permission denied" ==
 
 
 
Update to the latest riscv-gnu-toolchain and rebuild the kernel from the repo.  All known locking bugs have been fixed.
 
 
 
== Build hangs ==
 
 
 
We fixed an infinite loop bug in kernel memory allocation.  Make sure your kernel is up to date.
 

Revision as of 22:13, 19 December 2017

All about bootstrapping Fedora on RISC-V.

Introduction

Bootstrapping happens in several stages which are outlined in the README and Makefile in this repository.