From c3cd50085e400541e595a7852f84df680bb1dd14 Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Thu, 11 Jan 2024 16:36:50 +0100 Subject: Initial commit --- Fosdem2024/Makefile | 25 + Fosdem2024/contents.md | 271 +++++++++ Fosdem2024/img/Bootstrapping_now.svg | 397 +++++++++++++ Fosdem2024/img/Bootstrapping_simple.svg | 371 ++++++++++++ Fosdem2024/img/Bootstrapping_with_backport.svg | 371 ++++++++++++ Fosdem2024/img/Both.svg | 177 ++++++ Fosdem2024/img/NGIAssure.svg | 1 + Fosdem2024/img/bootstrapping.svg | 432 ++++++++++++++ Fosdem2024/img/nlnet.svg | 34 ++ Fosdem2024/img/tcc-boot.svg | 749 +++++++++++++++++++++++++ Fosdem2024/template.tex | 236 ++++++++ 11 files changed, 3064 insertions(+) create mode 100644 Fosdem2024/Makefile create mode 100644 Fosdem2024/contents.md create mode 100644 Fosdem2024/img/Bootstrapping_now.svg create mode 100644 Fosdem2024/img/Bootstrapping_simple.svg create mode 100644 Fosdem2024/img/Bootstrapping_with_backport.svg create mode 100644 Fosdem2024/img/Both.svg create mode 100644 Fosdem2024/img/NGIAssure.svg create mode 100644 Fosdem2024/img/bootstrapping.svg create mode 100644 Fosdem2024/img/nlnet.svg create mode 100644 Fosdem2024/img/tcc-boot.svg create mode 100644 Fosdem2024/template.tex (limited to 'Fosdem2024') diff --git a/Fosdem2024/Makefile b/Fosdem2024/Makefile new file mode 100644 index 0000000..1f2daf1 --- /dev/null +++ b/Fosdem2024/Makefile @@ -0,0 +1,25 @@ +TARGET = presentation.pdf + +TEMPLATE = template.tex +CONTENT = contents.md + +# IMG_DIR = img +# IMG_SRCS = $(wildcard $(IMG_DIR)/*.svg) +# IMG_BASENAME = $(notdir $(basename $(IMG_SRCS))) +# TMP_IMG_DIR = tmp +# IMGS = $(addsuffix .png, $(addprefix $(TMP_IMG_DIR)/, $(IMG_BASENAME))) + +all: $(TARGET) + +$(TARGET): $(CONTENT) $(TEMPLATE) # $(IMGS) + pandoc -f markdown+smart -t beamer $(CONTENT) -o $(TARGET) --pdf-engine=xelatex --template=$(TEMPLATE) + +# $(IMGS): $(TMP_IMG_DIR)/%.png: $(IMG_DIR)/%.svg +# mkdir -p $(TMP_IMG_DIR) +# inkscape $< --export-filename $@ --export-type=png --export-background-opacity=0.0 + +clean: + rm -r $(TARGET) # $(TMP_IMG_DIR) + +.PHONY: all clean $(CONTENT) $(TEMPLATE) + diff --git a/Fosdem2024/contents.md b/Fosdem2024/contents.md new file mode 100644 index 0000000..4c8b74e --- /dev/null +++ b/Fosdem2024/contents.md @@ -0,0 +1,271 @@ +--- +title: RISC-V Bootstrapping in Guix and Live-Bootstrap +subtitle: Status report for 2023, and what's coming up next + +license: CC-BY-SA +author: Ekaitz Zárraga +links-as-notes: true +lang: spanish +polyglossia-lang: + name: english +how-to: pandoc -f markdown+smart -t beamer contents.md -o beamer.pdf --pdf-engine=xelatex --template=template.tex +convert-img: inkscape IN.svg --export-filename OUT.png --export-type=png --export-background-opacity=0.0 # NOT NEEDED! +header-includes: + - \usepackage{multicol} + - \newcommand{\hideFromPandoc}[1]{#1} + - \hideFromPandoc{ + \let\Begin\begin + \let\End\end + } +... + +## Before we start + +If you want details and don't mind reading large text walls full of +nitty-gritty details, you can leave this talk and read [all the blogposts I did +on the process](https://ekaitz.elenq.tech/tag/bootstrapping-gcc-in-risc-v.html) + +**You can still stay here and smile, too.** + +## Who I am + +- Telecommunication engineer (EEE equivalent) +- Freelance engineer/programmer at [ElenQ.Tech](https://elenq.tech) +- Guix user and contributor +- You might remember me from my talk last year: + *"Bringing RISC-V to Guix's bootstrap"* + + + +## Context + +- In 2021 [NlNet][nlnet-grant-i] funded me to do some bootstrapping work: I + backported RISC-V support to GCC 4.6.4 from 7.5, and to our TinyCC-Boot from + upstream TinyCC. These were fundamental points in our bootstrap chain. +- I explained that in [FOSDEM 2023][fosdem-2023]. + +[nlnet-grant-i]: https://nlnet.nl/project/GNUMes-RISCV/index.html +[fosdem-2023]: https://archive.fosdem.org/2023/schedule/event/guixriscv/ + +\hfill ![\ ](img/nlnet.svg){height=25px}\ +\hfill ![\ ](img/NGIAssure.svg){height=15px} + + +## Intro + +- The work wasn't finished so I asked for a [second grant to + NlNet][nlnet-grant-ii]. +- I was tired of the previous effort and I needed help. I decided to bring more + people to the project: + - **Andrius Štikonas**: Involved in `live-bootstrap`, `stage-0` and the + related projects. Has the context awareness I lack. + - **Janneke**: `Mes` maintainer and author, `TinyCC-boot` maintainer and + `guix` contributor. All these projects are structural to the + bootstrapping process. + - More people +- My goal was to pay people for their good work, using the success of my + previous effort as a lever to get funded. + +[nlnet-grant-ii]: https://nlnet.nl/project/GNUMes-RISCV-bootstrap/ + +\hfill ![\ ](img/nlnet.svg){height=25px}\ +\hfill ![\ ](img/NGIAssure.svg){height=15px} + + +# In pictures + +## Bootstrapping process - Before + +\Begin{multicols}{2} + +- Colors represent RISC-V support: + - **\textcolor{red}{RED}**: no RISC-V support + - **\textcolor{orange}{ORANGE}**: some RISC-V support + - **\textcolor{green}{GREEN}**: full RISC-V support +- **TinyCC-boot** and **GCC (old)** are **\textcolor{red}{RED}**. +\vfill + +\columnbreak + +![\ ](img/Bootstrapping_simple.svg) + +\End{multicols} + +## Bootstrapping process - After the Backport (2022) + +\Begin{multicols}{2} + +- **Arrows** are still **\textcolor{red}{RED}** +- At that time I didn't know **TinyCC** was **\textcolor{orange}{ORANGE}**, + that was discovered later +- **GCC (old)** was actually **\textcolor{green}{GREEN}ER** than I thought +\vfill + +\columnbreak + +![\ ](img/Bootstrapping_with_backport.svg) + +\End{multicols} + +## Bootstrapping process - Now + +\Begin{multicols}{2} +- **TinyCC-Boot** is **\textcolor{green}{GREEN}** now +- The **\textcolor{green}{GREEN}** rectangle is included in `Guix` and + `live-bootstrap` +- **GCC (old)** is **\textcolor{green}{GREEN}** now: Tested in Debian in real + RISC-V hardware. +\vfill + +\columnbreak + +![\ ](img/Bootstrapping_now.svg) + +\End{multicols} + +## Bootstrapping process - Future + +\Begin{multicols}{2} +- **\textcolor{red}{->} TinyCC** requires changes in MesLibC +- **\textcolor{red}{->} GCC (old)**: + - requires `make` + - TinyCC claims to be able to build GCC 4, but we didn't test that (i386 + bootstrap uses GCC 2.95 in between). +- **\textcolor{red}{->} GCC** should *just work* +- A powerful `libc` is needed, built with TinyCC, which doesn't support + Extended Assembly. +\vfill + +\columnbreak + +![\ ](img/Bootstrapping_now.svg) + +\End{multicols} + + +# Questions? + +## + + + +# Limitations of the backport + +## TinyCC + +- I only tested the backend, in an emulated environment, using a using TinyCC + as a cross-compiler +- I tested on **GLibC**, but in the bootstrapping process it uses **MesLibC**, + a minimal **LibC**, part of Mes. +- **TinyCC-Boot** is in fact compiled several times (up to 6) with different + features (using conditional compilation via macro definitions like `-D...`). + - In a cross compiled environment this is not possible to test +- I didn't test the TinyCC **RISC-V assembler**, which happened to be + unimplemented (yeah... LOL), and it's needed for the **LibC**. + +## TinyCC + +![TinyCC-Boot bootstrapping process](img/tcc-boot.svg) + +## GCC + +- I tested it as a Cross-Compiler, so only the backend was tested. Again, no + bootstrap[^gcc-bootstrap]. +- It never compiled itself +- I didn't work on the C++ support + +[^gcc-bootstrap]: GCC has a bootstrap process that checks if the compiler works + correctly. First, it's compiled with your compiler of choice. Then, the + resulting binary is used to compile the GCC codebase again. The result of + that compiles GCC again. Then the binaries are compared, to make sure they + are identical. This can't be done in a cross-compiled environment, for + obvious reasons. + +# The work + +## TinyCC-Boot + +We focused on this, and let the other projects be carried by this effort. + +- Andrius and I spent many nights debugging crazy things in here. +- TinyCC's codebase is hard to read +- Many errors we got were not reproducible using a TinyCC compiled with GCC, so + we needed to build it from MesCC, which is very slow +- MesCC doesn't provide very helpful debug symbols +- We learned many things as we went + +> I wouldn't have the energy to make this without Andrius. + +## TinyCC-Boot - Crazy things + +1. Body is never executed: + + ``` c + if ( x < 8 ) { + // body + } + ``` +2. `A << 20 >> 20` +3. `__global_pointer$ is not a valid symbol` +4. Assembler uses a weird syntax and doesn't support Extended Assembly +5. `cannot cast from/to void` +6. And segfaults, segfaults everywhere! + +[Read more about them here](https://ekaitz.elenq.tech/bootstrapGcc8.html) + +## TinyCC-Boot - Results + +We finally managed to bootstrap TinyCC-Boot. + +- Andrius included the [build recipe in `live-bootstrap`](https://github.com/fosslinux/live-bootstrap/blob/master/steps/tcc-0.9.26/pass1.kaem) +- I did the [`guix` recipe](https://issues.guix.gnu.org/68222) + +## GNU Mes + +The problems we found in **TinyCC-Boot** made us improve Mes in several ways: + +- **MesCC**, the C compiler, had some limitations that were unnoticed in the i386 + bootstrap that appeared in RISC-V: faulty `switch-case`s, wrong `struct` + initializations, some integer weirdness... +- **MesLibC**, had to be split for our TinyCC as it doesn't support Extended + Assembly, and it also needed some extra tweaks: `char` signedness, `va_args` + support, build script support for the changes... + +> Having Janneke with us made the process very smooth. + + +## GCC + +- We compiled GCC with itself in a Debian machine in real RISC-V hardware +- Including C++ support +- [Only needed a few commits!](https://github.com/ekaitz-zarraga/gcc/compare/working-compiler...riscv) +- Guix recipe is pending, as we need to fix other steps to be able to add this: + `make`, a proper `libc`, TinyCC... + + +# Last words + +## Last words + +- People is important: I felt alone, and I didn't know how to continue. If I + had to spend another year working alone I would've just rejected the project. + **Bringing people gave me energy, knowledge and emotional support** + +- Money is important: thanks to NlNet I had the chance to pay people for their + work and buy some hardware. Covering people's basic needs is fundamental. + **Getting paid makes people independent, so they can focus on what they are + good at instead of struggling to survive** + +## So + +- Thanks, Andrius and Janneke +- Thanks, NlNet +- And... + +# Thank you + +## Contact and take part + +- Email me: +- Relevant IRC channels: `#bootstrappable`, `#guix`, `#guix-risc-v` + diff --git a/Fosdem2024/img/Bootstrapping_now.svg b/Fosdem2024/img/Bootstrapping_now.svg new file mode 100644 index 0000000..314dd32 --- /dev/null +++ b/Fosdem2024/img/Bootstrapping_now.svg @@ -0,0 +1,397 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Stage0-Posix + Guix and Live-Bootstrap + Mes + TinyCC-Boot + TinyCC + GCC (old) + GCC + The World™ + + diff --git a/Fosdem2024/img/Bootstrapping_simple.svg b/Fosdem2024/img/Bootstrapping_simple.svg new file mode 100644 index 0000000..1fbc6fc --- /dev/null +++ b/Fosdem2024/img/Bootstrapping_simple.svg @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Stage0-Posix + Mes + TinyCC-Boot + TinyCC + GCC (old) + GCC + The World™ + + diff --git a/Fosdem2024/img/Bootstrapping_with_backport.svg b/Fosdem2024/img/Bootstrapping_with_backport.svg new file mode 100644 index 0000000..44d1803 --- /dev/null +++ b/Fosdem2024/img/Bootstrapping_with_backport.svg @@ -0,0 +1,371 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Stage0-Posix + Mes + TinyCC-Boot + TinyCC + GCC (old) + GCC + The World™ + + diff --git a/Fosdem2024/img/Both.svg b/Fosdem2024/img/Both.svg new file mode 100644 index 0000000..144b76b --- /dev/null +++ b/Fosdem2024/img/Both.svg @@ -0,0 +1,177 @@ + +Logo-NGIAssure-tagLogo-NGIAssure-tag diff --git a/Fosdem2024/img/NGIAssure.svg b/Fosdem2024/img/NGIAssure.svg new file mode 100644 index 0000000..62b7c12 --- /dev/null +++ b/Fosdem2024/img/NGIAssure.svg @@ -0,0 +1 @@ +Logo-NGIAssure-tag diff --git a/Fosdem2024/img/bootstrapping.svg b/Fosdem2024/img/bootstrapping.svg new file mode 100644 index 0000000..2845e5a --- /dev/null +++ b/Fosdem2024/img/bootstrapping.svg @@ -0,0 +1,432 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Stage0-Posix + Mes + MesLibC + TinyCC-Boot + TinyCC + GCC (old) + GCC + The World™ + + + + diff --git a/Fosdem2024/img/nlnet.svg b/Fosdem2024/img/nlnet.svg new file mode 100644 index 0000000..373c8d8 --- /dev/null +++ b/Fosdem2024/img/nlnet.svg @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Fosdem2024/img/tcc-boot.svg b/Fosdem2024/img/tcc-boot.svg new file mode 100644 index 0000000..b53c61f --- /dev/null +++ b/Fosdem2024/img/tcc-boot.svg @@ -0,0 +1,749 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Tcc-Boot5 + Tcc-Boot6 + + + + + + + + + + + + Tcc-Boot5 + Tcc-Boot6 + =? + + + + TinyCC-Boot + TinyCC-Boot source code + ... + MesCC + Tcc-Mes + Tcc-Boot0 + + Tcc-Boot1 + -D HAVE_BITFIELD=1 + + + diff --git a/Fosdem2024/template.tex b/Fosdem2024/template.tex new file mode 100644 index 0000000..15b1f41 --- /dev/null +++ b/Fosdem2024/template.tex @@ -0,0 +1,236 @@ +\documentclass[$if(fontsize)$$fontsize$,$endif$$if(lang)$$babel-lang$,$endif$$if(handout)$handout,$endif$$if(beamer)$ignorenonframetext,$endif$$for(classoption)$$classoption$$sep$,$endfor$]{$documentclass$} +\setbeamertemplate{caption}[numbered] +\setbeamertemplate{caption label separator}{: } +% \selectcolormodel{gray} % Color B&W +\beamertemplatenavigationsymbols$if(navigation)$$navigation$$else$empty$endif$ + +\usepackage{amssymb,amsmath} +\usepackage{ifxetex,ifluatex} +\usepackage{fixltx2e} % provides \textsubscript + + +\usefonttheme{professionalfonts} % using non standard fonts for beamer +\usefonttheme{serif} % default family is serif + +% Font +\usepackage{fontspec} +\setmainfont[ + BoldFont = {*-Bold}, + ItalicFont = {*-Italic}, + BoldItalicFont = {*-BoldItalic}, +]{Lato} +\newcommand{\euro}{€} + +% Images with no captions +\usepackage{caption} +\captionsetup[figure]{labelformat=empty} + +% Bullet style +\useinnertheme{circles} +\newlength{\wideitemsep} +\setlength{\wideitemsep}{\itemsep} +\addtolength{\wideitemsep}{5pt} +\let\olditem\item +\renewcommand{\item}{\setlength{\itemsep}{\wideitemsep}\olditem} + +$if(euro)$ + \newcommand{\euro}{€} +$endif$ + +% Language +\usepackage{polyglossia} +\setmainlanguage[$polyglossia-lang.options$]{$polyglossia-lang.name$} + +\newif\ifbibliography +$if(natbib)$ +\usepackage{natbib} +\bibliographystyle{$if(biblio-style)$$biblio-style$$else$plainnat$endif$} +$endif$ +$if(biblatex)$ +\usepackage[$if(biblio-style)$style=$biblio-style$,$endif$$for(biblatexoptions)$$biblatexoptions$$sep$,$endfor$]{biblatex} +$for(bibliography)$ +\addbibresource{$bibliography$} +$endfor$ +$endif$ + +$if(verbatim-in-note)$ +\usepackage{fancyvrb} +$endif$ + +\hypersetup{ +$if(title-meta)$ + pdftitle={$title-meta$}, +$endif$ +$if(author-meta)$ + pdfauthor={$author-meta$}, +$endif$ +$if(keywords)$ + pdfkeywords={$for(keywords)$$keywords$$sep$, $endfor$}, +$endif$ +$if(colorlinks)$ + colorlinks=true, + linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$, + citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$, + urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$, +$else$ + pdfborder={0 0 0}, +$endif$ + breaklinks=true} +\urlstyle{same} % don't use monospace font for urls +$if(verbatim-in-note)$ +\VerbatimFootnotes % allows verbatim text in footnotes +$endif$ +$if(listings)$ +\usepackage{listings} +$endif$ +$if(lhs)$ +\lstnewenvironment{code}{\lstset{language=Haskell,basicstyle=\small\ttfamily}}{} +$endif$ +$if(highlighting-macros)$ +$highlighting-macros$ +$endif$ +$if(tables)$ +\usepackage{longtable,booktabs} +\usepackage{caption} +% These lines are needed to make table captions work with longtable: +\makeatletter +\def\fnum@table{\tablename~\thetable} +\makeatother +$endif$ +$if(graphics)$ +\usepackage{graphicx,grffile} +\makeatletter +\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth\else\Gin@nat@width\fi} +\def\maxheight{\ifdim\Gin@nat@height>\textheight0.8\textheight\else\Gin@nat@height\fi} +\makeatother +% Scale images if necessary, so that they will not overflow the page +% margins by default, and it is still possible to overwrite the defaults +% using explicit options in \includegraphics[width, height, ...]{} +\setkeys{Gin}{width=\maxwidth,height=\maxheight,keepaspectratio} +$endif$ + +% Prevent slide breaks in the middle of a paragraph: +\widowpenalties 1 10000 +\raggedbottom + +$if(section-titles)$ +\AtBeginPart{ + \let\insertpartnumber\relax + \let\partname\relax + \frame{\partpage} +} +\AtBeginSection{ + \ifbibliography + \else + \let\insertsectionnumber\relax + \let\sectionname\relax + \frame{\sectionpage} + \fi +} +\AtBeginSubsection{ + \let\insertsubsectionnumber\relax + \let\subsectionname\relax + \frame{\subsectionpage} +} +$endif$ + +$if(links-as-notes)$ +% Make links footnotes instead of hotlinks: +\renewcommand{\href}[2]{#2\footnote{\url{#1}}} +$endif$ + +$if(strikeout)$ +\usepackage[normalem]{ulem} +% avoid problems with \sout in headers with hyperref: +\pdfstringdefDisableCommands{\renewcommand{\sout}{}} +$endif$ +\setlength{\parindent}{0pt} +\setlength{\parskip}{6pt plus 2pt minus 1pt} +\setlength{\emergencystretch}{3em} % prevent overfull lines +\providecommand{\tightlist}{% + \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} +$if(numbersections)$ +\setcounter{secnumdepth}{$if(secnumdepth)$$secnumdepth$$else$5$endif$} +$else$ +\setcounter{secnumdepth}{0} +$endif$ +$if(dir)$ +\ifxetex + % load bidi as late as possible as it modifies e.g. graphicx + $if(latex-dir-rtl)$ + \usepackage[RTLdocument]{bidi} + $else$ + \usepackage{bidi} + $endif$ +\fi +\ifnum 0\ifxetex 1\fi\ifluatex 1\fi=0 % if pdftex + \TeXXeTstate=1 + \newcommand{\RL}[1]{\beginR #1\endR} + \newcommand{\LR}[1]{\beginL #1\endL} + \newenvironment{RTL}{\beginR}{\endR} + \newenvironment{LTR}{\beginL}{\endL} +\fi +$endif$ +$for(header-includes)$ +$header-includes$ +$endfor$ + +$if(title)$ +\title{$title$} +$endif$ +$if(subtitle)$ +\subtitle{$subtitle$} +$endif$ +$if(author)$ +\author{$for(author)$$author$$sep$ \and $endfor$} +$endif$ +$if(institute)$ +\institute{$for(institute)$$institute$$sep$ \and $endfor$} +$endif$ +\date{$date$} + +\begin{document} +$if(title)$ +\frame{\titlepage} +$endif$ + +$for(include-before)$ +$include-before$ + +$endfor$ +$if(toc)$ +\begin{frame} +\tableofcontents[hideallsubsections] +\end{frame} + +$endif$ +$body$ + +$if(natbib)$ +$if(bibliography)$ +$if(biblio-title)$ +$if(book-class)$ +\renewcommand\bibname{$biblio-title$} +$else$ +\renewcommand\refname{$biblio-title$} +$endif$ +$endif$ +\begin{frame}[allowframebreaks]{$biblio-title$} +\bibliographytrue +\bibliography{$for(bibliography)$$bibliography$$sep$,$endfor$} +\end{frame} + +$endif$ +$endif$ +$if(biblatex)$ +\begin{frame}[allowframebreaks]{$biblio-title$} +\bibliographytrue +\printbibliography[heading=none] +\end{frame} + +$endif$ +$for(include-after)$ +$include-after$ + +$endfor$ +\end{document} -- cgit v1.2.3