summaryrefslogtreecommitdiff
path: root/Fosdem2022
diff options
context:
space:
mode:
Diffstat (limited to 'Fosdem2022')
-rw-r--r--Fosdem2022/TALK.txt201
-rw-r--r--Fosdem2022/contents.md244
-rw-r--r--Fosdem2022/img/better_documentation.pngbin0 -> 102745 bytes
-rw-r--r--Fosdem2022/img/drake.jpgbin0 -> 93013 bytes
-rw-r--r--Fosdem2022/template.tex236
5 files changed, 681 insertions, 0 deletions
diff --git a/Fosdem2022/TALK.txt b/Fosdem2022/TALK.txt
new file mode 100644
index 0000000..719c001
--- /dev/null
+++ b/Fosdem2022/TALK.txt
@@ -0,0 +1,201 @@
+Who I am (it's a little bit relevant to understand my previous knowledge)
+- telecommunication engineer (EEE equivalent)
+- Freelance engineer/programmer at ElenQ.Tech
+- Guix user and contributor
+
+Recently:
+- Interested in small computing
+- Lisp, specially scheme, specially small scheme implementations
+
+The early beginnings:
+- Started a very small scheme compiler for small machines, and thought
+ about RISC-V. I decided to target RISC-V assembly (following:
+ https://compilers.iecc.com/crenshaw/)
+- I studied RISC-V via [riscvbook]
+- I studied several scheme implementations
+- Nothing happened out of this, I gave up when I read about continuations but I
+ learned some stuff.
+
+The random events
+- One day a friend tells me guix mailing list is looking for help to make a
+ RISC-V port. I decide to raise my hand.
+- Now I'm involved in RISC-V porting effort somehow.
+- One day Andy Wingo, the Guile maintainer, mentions it would be interesting
+ to port Lightening, Guile's JIT code generation library to RISC-V.
+
+Now I'm working on Lightening: things learned
+- Code is data -> I'm a lisp guy, I already knew that!
+- Some cool GDB debugging I already forgot (disassemble)
+- Now I'm able to hand-assemble instructions too
+- Machine code generation is not that complex
+- Relocations and large immediates are painful
+
+Lightening RISC-V is passing all the tests, next step is to give it a serious
+try and see if it works! Cross fingers!
+
+Stage0
+- There was a chance to work on the bootstrap system of Guix via NlNet and the
+ guys involved in the porting effort helped me prepare a proposal.
+- I had to learn about all the steps around so I started with Stage0.
+
+Stage0's steps:
+hex0 -> hex1 -> hex2 -> M0 (macro system) -> M2-Planet [ -> Gnu Mes ]
+
+Hex0
+- Hex0 are hex files that contain what the ELF executable would, but encoded in
+ Hexadecimal text.
+- I started with hex0, porting it to RISC-V (RV64). Thankfully, I was
+ developing a RISC-V assembler (I never finished) that helped me generate the
+ instructions by hand.
+- Took the ELF headers from the wikipedia.
+- It worked!!
+
+Effects of this effort
+- Other people at Bootstrappable took this work and finished the whole chain
+ of Stage0!
+
+A random afternoon:
+- I was bored and the Hex0 for RV32 was missing. Looked the headers in the
+ wikipedia and 20 minutes later it was added to the project. Another starting
+ point solved!
+
+Now:
+- Took the NlNet grant and now I'm going to contribute to the full source
+ bootstrap ecosystem. So now this is kind of my job.
+
+Conclusions:
+- This is just random work
+- Embrace the randomness of life, stay curious and you may reach interesting
+ places.
+
+
+
+---
+
+
+My blogposts about this process:
+https://ekaitz.elenq.tech/lightening.html
+https://ekaitz.elenq.tech/hex0.html
+https://ekaitz.elenq.tech/machine-code-generation.html
+
+RISC-V:
+http://riscvbook.com/
+
+Bootstrap related:
+http://bootstrappable.org
+https://github.com/oriansj/stage0
+https://github.com/oriansj/bootstrap-seeds
+
+GUILE
+https://www.gnu.org/software/guile/
+https://gitlab.com/wingo/lightening/-/merge_requests/14/commits
+
+---
+
+We are excited to announce a devroom on Declarative and Minimalistic
+Computing at FOSDEM on 5th and 6th of February, 2022, online!
+
+FOSDEM is one of the most important free software conferences and is
+hosted annually at Université libre de Bruxelles in Brussels,
+Belgium. Unfortunately again this year FOSDEM will not run a physical
+conference but will be online only. Talks will be pre-recorded with
+some live content including Q&A sessions and discussion panels.
+
+We accept talks from languages that attempt to minimize use of hardware
+and software while trying to make systems simpler, more robust and more
+secure. If you are working on improving today's systems taking
+declarative/minimalistic approaches feel free to submit a talk
+proposal. Examples include the Scheme/Lisp family of programmings
+languages. In past editions, this devroom has received presentations
+from a varied number of language communities, including Forth, Guile,
+Lua, Nim, Racket, Raku and Tcl as well as several experimental projects
+that push minimalism in new directions.
+
+Minimalism and declarative programming are two important topics for
+this devroom. Minimalism matters. Minimalism allows for smaller
+systems that take less resources and consume less energy. More
+importantly, free and open source minimalism allows for secure systems
+that are easy to understand. Declarative programming is a programming
+paradigm that expresses the logic of a computation without describing
+its control flow. Many languages that apply this style attempt to
+minimize or eliminate side effects by describing what the program must
+accomplish in terms of the problem domain, rather than describe how to
+accomplish it as a sequence of the programming language primitives.
+
+Finally, in this year's virtual conference we will honor the late Professor
+[https://en.wikipedia.org/wiki/John_McCarthy_(computer_scientist) John
+McCarthy] as the founder of AI and the inventor of LISP. McCarthy with
+his work pioneered artificial intelligence, developed the Lisp
+programming language family and kickstarted our modern computing world.
+
+We want to invite you to submit a talk on declarative and minimalistic
+computing that fits that description. We are especially happy to
+receive talk submissions from members of groups underrepresented in
+free software.
+
+If you have something you’d like to share with your fellow developers,
+please E-mail us! Talks considered for the devroom will have to
+be entered in
+
+ - https://penta.fosdem.org/submission/FOSDEM22
+
+The deadline for submission is December 20th. If you have a FOSDEM
+pentabarf account from a previous year, please use that
+account. Otherwise add one on
+https://penta.fosdem.org/user/new_account. Reach out to
+pjotr.public456@thebird.nl or manolis837@gmail.com if you run into any
+trouble.
+
+When submitting your talk make doubly sure to select "Declarative and
+Minimalistic Computing devroom" as track (if you don't we won't find
+it), and include the following information:
+
+ * The title and subtitle of your talk
+ * A short abstract of one paragraph
+ * A longer description if you wish to do so
+ * Links to related websites/blogs etc
+ * Presentations has to be pre-recorded and streamed before the event.
+ * Start recording early!
+
+To see what a final talk looks like see
+
+ https://archive.fosdem.org/2021/schedule/event/gnumes/
+
+For accepted talks
+
+ * Once your talk was accepted, we will assign you an organizer to
+help you to produce the pre-recorded content.
+ * The organizer will review the content and ensure it has the
+required quality. He is also responsible for ensuring the content is
+into the system and ready to broadcast.
+ * During the stream of your talk, you must be available online for
+the Q/A session
+
+Let's make this a fun day!
+
+= Organizers =
+
+Pjotr Prins, Manolis Ragkousis, Ludovic Courtès, Amirouche Boubekki,
+Hisham Muhammad, Jan Nieuwenhuizen, Ricardo Wurmus, Alex
+Sassmannshausen, William Byrd, Oliver Propst, Efraim Flashner, Julien
+Lepiller
+
+= Code of conduct =
+
+ - https://fosdem.org/2022/practical/conduct/
+
+= Original proposal =
+
+ - https://libreplanet.org/wiki/FOSDEM2022-devroom-proposal
+
+= Important dates: =
+
+ - Dec 20th 2021: submission deadline for talk proposals
+ - Dec 31th 2021: announcement of the final schedule
+ - Jan 14th 2021: submission deadline for recordings
+ - Feb 5th 2022: FOSDEM!
+
+= Links: =
+
+ -
+https://libreplanet.org/wiki/FOSDEM2022-devroom-declarative-and-minimalistic-computing-cfp
diff --git a/Fosdem2022/contents.md b/Fosdem2022/contents.md
new file mode 100644
index 0000000..e8533b8
--- /dev/null
+++ b/Fosdem2022/contents.md
@@ -0,0 +1,244 @@
+---
+title: "A year of RISC-V adventures: embracing chaos in your software journey"
+
+subtitle: How I started from zero and ended up porting a JIT compilation library and assembling files by hand
+
+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
+...
+
+# Who I am
+- Telecommunication engineer (EEE equivalent)
+- Freelance engineer/programmer at [ElenQ.Tech](https://elenq.tech)
+- Guix user and contributor
+
+## Recently
+- Interested in small computing
+- Lisp, specially Scheme, more specifically small Scheme implementations.
+
+
+
+# The beginnings
+- Started a very small scheme compiler for small machines, and thought about
+ RISC-V. I decided to target RISC-V assembly following ["Let's Build a
+ Compiler" by Jack Crenshaw](https://compilers.iecc.com/crenshaw/)
+- I studied RISC-V with: ["The RISC-V Reader: An Open Architecture
+ Atlas"](http://riscvbook.com/)
+- I studied several scheme implementations and read some papers
+- Nothing happened out of this, I gave up when I read about continuations but I
+ learned some stuff.
+
+
+
+# Chaos starts
+- One day a friend (the same guy who introduced me to Guix) tells me the Guix
+ mailing list is looking for help to make a RISC-V port. I decide to raise my
+ hand.
+- Now I'm involved in RISC-V porting effort somehow.
+- One day Andy Wingo, the Guile maintainer, mentions it would be interesting to
+ port Lightening, Guile's JIT code generation library to RISC-V.
+
+
+
+# Now I'm working on the Lightening port somehow
+
+Lightening is a machine code generation library. It's a fork of GNU Lightning,
+made for Guile, that aims to be simple.
+
+## The experience
+- My C programming skills are rusty
+- 0 documentation: only the one inherited from GNU Lightning
+- Dead code
+- Andy Wingo helped me take the good direction and made everything easier
+
+# Lightening: Things learned
+- How to assemble instructions by hand *
+- Code is data. I'm a lisp guy, I already knew that! *
+- Some cool GDB debugging tricks I already forgot
+- Machine code generation is not that complex
+- Relocations and immediates are painful[^more]
+
+[^more]: Read more: <https://ekaitz.elenq.tech/machine-code-generation.html>
+
+# Lightening: Assemble by hand
+
+```
+addi a0, zero, 56
+```
+
+- Opcode `addi`: `0010011`
+- Destination register `a0`: `01010`
+- `funct3`: `000`
+- Source register `zero`: `00000`
+- The immediate `56`: `000000111000`
+
+`000000111000 | 00000 | 000 | 01010 | 0010011`
+
+All together: `00000011100000000000010100010011`
+(In hex: `0x3800513`)
+
+
+# Lightening: Code is data
+
+``` c
+#include<stdint.h>
+#include<stdio.h>
+
+typedef int f0(void);
+
+int main(int argc, char* argv[]){
+ uint32_t instructions[2];
+
+ instructions[0] = 0x03800513; // addi a0, zero, 56
+ instructions[1] = 0x00008067; // jalr zero, ra, 0
+
+ // Reinterpret the array address as a function
+ f0 *load_56 = (f0*) instructions;
+
+ int a = load_56();
+ printf("%d\n", a);
+}
+```
+
+
+# Moving to the bootstrap system
+
+There was a chance to work on Guix's RISC-V support via NlNet and the
+guys involved in the porting effort told me I should send a proposal.
+
+I had to learn about the full-source bootstrap project for this so I ended up
+taking part on it.
+
+The proposal was rejected, but the learning was already done. *And what now?*
+
+# Stage0
+
+Stage0 is a full source bootstrap system.
+
+Stage0's steps:
+
+1. Hex0: Hex encoded raw ELF file with comments
+2. Hex1: Hex0 + one character labels and some extras
+3. Hex2: Hex1 + proper labels and reasonable basics
+4. M0 (macro system): A simple macro system
+5. M2-Planet: A C subset that uses M0 as output
+6. C compilers (i.e. GNU Mes's `mescc`)
+
+
+# Stage0
+
+## The experience
+
+![](img/better_documentation.png)
+
+# Hex0
+
+Hex0 is a simple assembler written in Hex0. It just converts a Hexadecimal
+encoded ELF file to binary.
+
+It's heavily commented so anyone can decode the instructions and make sure that
+it works as expected. It looks like this:
+
+```
+# :_start ; (0x0600078)
+
+; Open input file and store FD in s2
+93 08 80 03 # RD_A7 !56 ADDI ; sys_openat
+13 05 C0 F9 # RD_A0 !-100 ADDI ; AT_FDCWD
+93 05 06 00 # RD_A1 RS1_A2 MV ; input file
+13 06 00 00 # RD_A2 MV ; read only
+73 00 00 00 # ECALL
+13 09 05 00 # RD_S2 RS1_A0 MV ; Save fd
+
+```
+
+# Hex0
+
+I wanted to make the first version of the POSIX based Hex0 for RV64. I just
+needed to:
+
+1. Write it in assembly first
+2. Assemble everything by hand...
+
+![](img/drake.jpg)
+
+
+
+# Hex0: Abandoned projects that add entropy: pysc-v
+
+While I was working on Lightening I started a RISC-V assembler in Python.
+
+*[I abandoned the project](http://git.elenq.tech/pysc-v/)*
+
+But the backend was reusable so I could generate all the instructions in the
+Hex0 with the format I wanted!
+
+
+# Hex0: disassembly tricks
+
+I still need to calculate addresses by hand though.
+
+*But wait!* I learned how to disassemble when I worked on Lightening so I could
+obtain each instructions address easily, without all the counting.
+
+# Hex0
+
+## The experience
+
+- It was rewarding to see that I could write assembly.
+- I reused all the GDB tricks from Lightening to check that everything was
+ working correctly.
+- The documentation is weird and there are too many subprojects that make the
+ project hard to understand for newcomers. It's hard to understand the reasons
+ behind some decisions and everything looks fragile.
+- But `#bootstrappable` at `libera.chat` is a good place to ask questions and
+ learn from others.
+
+
+# Hex0 extra: embrace boredom
+
+Sunday morning. I'm bored.
+
+I reviewed the status of the project and saw RV32 is not ready yet, even if it
+is similar to RV64.
+
+I start a discussion on IRC and in less than half an hour and with the help of
+the Wikipedia we replace the ELF headers and make the Hex0 support for RV32.
+
+
+# Status of the projects
+- **Lightening**: is passing all the test but needs testing. [The
+ code][lightening] is available for anyone to read and improve.
+- **Stage0**: included [my small RISC-V contribution to Hex0][stage0] and other
+ contributors expanded my work to every stage.
+
+[lightening]: https://gitlab.com/wingo/lightening/-/merge_requests/14/commits
+[stage0]: https://github.com/oriansj/bootstrap-seeds/pull/2
+
+
+
+# My status
+
+I tried again with NlNet, with a proposal for some RISC-V porting efforts on
+GNU Mes and other bootstrap related projects.
+
+They look interested on a full-source-bootstrap for RISC-V!
+
+*I might end up working on a compiler*
+
+
+# Conclusions
+- All this is just random work, done without a plan or purpose
+- Embrace the chaos of life, stay curious and you may reach interesting places
+- If you can, learn from people: it's faster and better
+- You don't need to be a genius: most of the things are easy once you know the
+ context.
+
+---
+
+## Just try, and let it happen
diff --git a/Fosdem2022/img/better_documentation.png b/Fosdem2022/img/better_documentation.png
new file mode 100644
index 0000000..b8348dc
--- /dev/null
+++ b/Fosdem2022/img/better_documentation.png
Binary files differ
diff --git a/Fosdem2022/img/drake.jpg b/Fosdem2022/img/drake.jpg
new file mode 100644
index 0000000..10a1e74
--- /dev/null
+++ b/Fosdem2022/img/drake.jpg
Binary files differ
diff --git a/Fosdem2022/template.tex b/Fosdem2022/template.tex
new file mode 100644
index 0000000..31b2bf7
--- /dev/null
+++ b/Fosdem2022/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 = Lato-Bold.ttf,
+ ItalicFont = Lato-Italic.ttf,
+ BoldItalicFont = Lato-BoldItalic.ttf
+]{Lato-Regular.ttf}
+\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}