2 @c -*- mode: texinfo; -*-
6 @documentencoding UTF-8
7 @settitle GNU Mes Reference Manual
12 @c Identifier of the OpenPGP key used to sign tarballs and such.
13 @set OPENPGP-SIGNING-KEY-ID 1A858392E331EAFDB8C27FFBF3C1A0D9C1D65273
16 Copyright @copyright{} 2018 Jan (janneke) Nieuwenhuizen@*
18 Permission is granted to copy, distribute and/or modify this document
19 under the terms of the GNU Free Documentation License, Version 1.3 or
20 any later version published by the Free Software Foundation; with no
21 Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A
22 copy of the license is included in the section entitled ``GNU Free
23 Documentation License''.
26 @dircategory Bootstrapping
28 * Mes: (mes). A system bootstrap worthy of GNU.
31 * mes: (mes)Invoking mes. Running Mes, a minimalist Guile lookalike.
32 * mescc: (mes)Invoking MesCC. Running the MesCC bootstrap compiler.
36 @title GNU Mes Reference Manual
37 @subtitle Full Source Bootstrapping of the GNU GuixSD Operating System
38 @author Jan (janneke) Nieuwenhuizen
41 @vskip 0pt plus 1filll
42 Edition @value{EDITION} @*
50 @c *********************************************************************
54 This document describes GNU Mes version @value{VERSION}, a bootstrappable
55 Scheme interpreter and C compiler written for bootstrapping the GNU system.
58 * Introduction:: What is Mes about?
59 * Installation:: Installing Mes.
60 * Bootstrapping:: Would you strap my boots?
61 * Contributing:: Your help needed!
62 * Acknowledgments:: Thanks!
64 * GNU Free Documentation License:: The license of this manual.
65 * Concept Index:: Concepts.
66 * Programming Index:: Data types, functions, and variables.
69 --- The Detailed Node Listing ---
73 * Reproducible Builds:: Reproducibility and free software.
74 * Bootstrappable Builds:: The freedom to build a software without binary seed.
75 * Full Source Bootstrap:: Software dependencies worthy of GNU.
79 * Regular Requirements:: Software needed to build and run Mes.
80 * Bootstrap Requirements:: Software needed to bootstrap Mes.
81 * Running the Test Suites:: Testing Mes.
85 * The Mes Bootstrap Process:: How Mes will make you yogurt from pure milk.
86 * Invoking Mes:: Running Mes, a minimalist Guile lookalike.
87 * Invoking MesCC:: Running the MesCC bootstrap compiler.
91 * Environment Variables:: If the bits won't change, change their habitat.
95 * MesCC Environment Variables:: There's no NIX like POSIX.
99 * Building from Git:: The latest and greatest.
100 * Running Mes From the Source Tree:: Hacker tricks.
101 * The Perfect Setup:: The right tools.
102 * Coding Style:: Hygiene of the contributor.
103 * Submitting Patches:: Share your work.
108 @c *********************************************************************
110 @chapter Introduction
113 These were “Maxwell’s Equations of Software!”
118 The purpose of GNU Mes@footnote{``Mes'' is an acronym for the Maxwell
119 Equations of Software.} is to help create a computer operating system
122 Mes consists of a mutual self-hosting Scheme interpreter written in C
123 and a Nyacc-based (see @pxref{NYACC User's Guide,,, nyacc-ug, NYACC
124 User's Guide}) C compiler written in Scheme. The Scheme interpreter
125 @file{mes.c} is about 5000LOC of restricted C and intended to be
126 bootstrappable using a very simple C compiler.
128 If we want to trust our computers to do what we instructed them to do
129 then we need to be able to inspect all instructions---all
130 softwares---that we have given it to run.
132 @section Software Freedom
134 The four essential Freedoms of Software are at the core of our GNU
135 community. Quoting the GNU philosophy@footnote{The four essential
136 freedoms @url{https://www.gnu.org/philosophy/free-sw.html}}
139 A program is free software if the program's users have the four
144 The freedom to run the program as you wish, for any purpose (freedom 0).
147 The freedom to study how the program works, and change it so it does
148 your computing as you wish (freedom 1). Access to the source code is
149 a precondition for this.
152 The freedom to redistribute copies so you can help others (freedom
156 The freedom to distribute copies of your modified versions to others
157 (freedom 3). By doing this you can give the whole community a chance
158 to benefit from your changes. Access to the source code is a
159 precondition for this.
163 A computer operating system that respects the user's freedom is one
164 essential ingredient for building a reliable, trustable computing
165 system. There are about a dozen general purpose operating systems that
166 can be trusted in this way, see
167 @url{https://www.gnu.org/distros/free-distros.html, Free Distributions}.
168 For all softwares on such a system we have the full source code and
169 build recipes available.
171 @c The Free System Distribution Guidelines (GNU FSDG)@footnote{Examples of
172 @c free operating systems are GNU GuixSD, GNU Parabola and Trisquel, see
173 @c https://www.gnu.org/distros/free-system-distribution-guidelines.html}
174 @c can serve as help to create such a system
176 So we have access to all the software, we have studied it, possibly
177 modified it, then we built it and we installed it on a computer or some
178 device or appliance. How can we trust that when we run the program we
179 are indeed running the untainted product of the source code that we
180 studied? Unless we are certain of this we cannot really enjoy
184 * Reproducible Builds:: Reproducibility and free software.
185 * Bootstrappable Builds:: The freedom to build a software without binary seed.
186 * Full Source Bootstrap:: Software dependencies worthy of GNU.
189 @node Reproducible Builds
190 @section Reproducible Builds
192 The current Reproducible Builds effort incubated in the Debian
193 project@footnote{@url{http://debian.org, The Debian Project}} and was
194 organized by Lunar. Quoting the Reproducible Builds
195 website@footnote{@url{https://reproducible-builds.org/,Reproducible
199 A build is reproducible if given the same source code, build environment
200 and build instructions, any party can recreate bit-by-bit identical
201 copies of all specified artifacts.
204 @subsection Can we trust our freedom?
206 Now consider the opposite, that a second build of a piece of source code
207 produces a different binary program. Upon further investigation we
208 might find that the only difference is probably harmless: a timestamp
209 that was embedded in the binary, or perhaps the name of the user that
210 built it or directory it was built in. Such investigations can be
211 nontrivial and are highly unpractical. And what if the binary
212 difference is not so trivial, cannot be easily accounted for?
214 A piece of software that cannot be built bit-by-bit reproducible is
215 probably not a good community member in the world of software freedom.
216 We think the importance of reproducibility should not be underestimated
217 largely because failing that precondition makes justifable trust in
218 binaries provided suspect at best and downright dangerous in reality.
220 It becomes clear that a bit-by-bit reproducible build of all our
221 sofwares is essential if we value our Freedom 1.
223 @subsection An Old Idea
225 The idea of reproducible builds is not very new. It was implemented for
226 GNU tools in the early 1990s (which we learned, much later in 2017). In
227 the Debian world it was mentioned first in 2000 and then more explicitly
229 debian-devel@footnote{@url{https://lists.debian.org/debian-devel/2007/09/msg00746.html,Martin Uecker on debian-devel on bit-reproducibility}}
232 I think it would be really cool if the Debian policy required that
233 packages could be rebuild bit-identical from source.
235 @author Martin Uecker
238 @node Bootstrappable Builds
239 @section Bootstrappable Builds
241 Software distributions that take reproducible builds seriously are
242 currently shipping well over 90% reproducible packages.
244 That a package builds bit-by-bit reproducibly however is not enough to
245 guarantee Freedom 1. There is another factor that is often overlooked:
246 opaque ascii or binary @emph{seeds} that are injected during build
247 time. Yes, a package may build reproduciblly from all inspectable
248 sourcess...but what functionality is programmed in the opaque seed?
250 @subsection Bootstrap Binaries
251 Possibly one of the most harmless, but certainly by far the biggest
252 binary seed that all software distributions inject are the so called
253 @emph{bootstrap binaries}. Bootstrap binaries are the initial binary
254 seeds that are used to start building the distribution.
256 The GNU GuixSD operating system has a relatively small closure of
257 bootstrap binaries: GNU binutils, GNU gcc, GNU Libc, GNU Guile, and
258 ``Static binaries'' (think: bash, bzip2, coreutils, gawk, grep, gzip,
259 patch, sed, tar, xz).
262 $ du -schx $(readlink $(guix build bootstrap-tarballs)/*)
263 2.1M /gnu/store/9623n4bq6iq5c8cwwdq99qb7d0xj93ym-binutils-static-stripped-tarball-2.28.1/binutils-static-stripped-2.28.1-x86_64-linux.tar.xz
264 18M /gnu/store/437xwygmmwwpkddcyy1qvjcv4hak89pb-gcc-stripped-tarball-5.5.0/gcc-stripped-5.5.0-x86_64-linux.tar.xz
265 1.8M /gnu/store/55ccx18a0d1x5y6a575jf1yr0ywizvdg-glibc-stripped-tarball-2.26.105-g0890d5379c/glibc-stripped-2.26.105-g0890d5379c-x86_64-linux.tar.xz
266 5.7M /gnu/store/bqf0ajclbvnbm0a46819f30804y3ilx0-guile-static-stripped-tarball-2.2.3/guile-static-stripped-2.2.3-x86_64-linux.tar.xz
267 5.8M /gnu/store/j8yzjmh9sy4gbdfwjrhw46zca43aah6x-static-binaries-tarball-0/static-binaries-0-x86_64-linux.tar.xz
271 only a 33MB download that unpacks to 252BM of opaque binaries, that we
272 most probably have the source of, shall we review these together? ;-)
275 $ for i in $(readlink $(guix build bootstrap-tarballs)/*);\
276 do sudo tar xf $i; done
286 @node Full Source Bootstrap
287 @section Full Source Bootstrap
289 There is an obvious solution: we cannot allow any binary seeds in our
290 software stack. Not even in the bootstrap binaries. Maybe that is a
291 bit too strong: we want to have the absolute minimum of binary seeds and
292 all binary seeds need to be inspectable and must be reviewed. How big
293 would the absolute minimal set be?
295 @subsection The Magical Self-Hosting Hex Assembler
297 June 2016 I learnt about
298 @url{https://github.com/oriansj/stage0/,Stage0}. Jeremiah Orians
299 created @file{hex0} a ~500 byte self-hosting hex assembler. The source
300 code is well documented and the binary is the exact mirror of the source
301 code. I was inspired.
303 Here is an example of what the @file{hex0} program looks like; the start
304 of the @var{hex} function
307 00000060: 4883 f830 7c6f 4883 f83a 7c5a 4883 f841 H..0|oH..:|ZH..A
309 000000d0: 48c7 c0ff ffff ffc3 0000 0000 0000 0000 H...............
310 000000e0: 4883 e830 c300 0000 0000 0000 0000 0000 H..0............
313 All computer programs look like this: an opaque list of computer codes.
314 The initial programs that we take for granted---the bootstrap
315 binaries---are about 250MB of such numbers: think 250,000 pages full of
318 Most computers work pretty well so apparently there is not a pressing
319 need to inspect and study all of these codes. At the same time it is
320 tricky to fully trust@footnote{ Ken Thompson's 1984 Turing award
322 @url{http://www.ece.cmu.edu/~ganger/712.fall02/papers/p761-thompson.pdf,
323 Reflections on Trusting Tust}.} a computer that was bootstrapped in this
326 Here is what the source code of the @file{hex0} assembler looks like
330 48 83 f8 30 # cmp $0x30,%rax
331 7c 6f # jl 6000f3 <ascii_other>
332 48 83 f8 3a # cmp $0x3a,%rax
333 7c 5a # jl 6000e4 <ascii_num>
334 48 83 f8 41 # cmp $0x41,%rax
336 ## function: ascii_other
337 48 c7 c0 ff ff ff ff # mov $0xffffffffffffffff,%rax
340 ## function: ascii_num
341 48 83 e8 30 # sub $0x30,%rax
345 While it may be hard to understand what this piece of the program does,
346 it should be possible for anyone to verify that the computer codes above
347 correspond to the source code with comments.
349 One step beyond these annotated codes is Assembly language. To write a
350 program in Assembly, you only need to provide the instructions; the
351 codes are computed by the @file{assembler} program.
355 # deal all ascii less than 0
370 More readable still, a similar program text in the C programming language.
376 if (c >= '0' && c <= '9')
382 What if we could bootstrap our entire system from only this one
383 @file{hex0} assembler binary seed? We would only ever need to inspect
384 these 500 bytes of computer codes. Every@footnote{Some program
385 languages have become very hard or practically impossible to bootstrap.
386 Instead of depending on a simple language such as C, they depend on a
387 recent version of itself, or on other binary or ASCII seeds, on other
388 recent programs written in that language, or even on manual
389 intervention. Programs written in a language that cannot be
390 bootstrapped can still run on our systems, but cannot enjoy any of the
391 trust we intend to create.} later program is written in a more friendly
392 programming language: Assembly, C, @dots{} Scheme.
394 Inspecting all these programs is a lot of work, but it can certainly be
395 done. We might be able to create a fully inspectable path from almost
396 nothing to all of the programs that our computer runs. Something that
397 seemed to be an impossible dream is suddenly starting to look like
398 ``just a couple years of work''.
400 @subsection LISP as Maxwell's Equations of Software
402 As fate would have it, I stumbled upon this
403 @url{https://queue.acm.org/detail.cfm?id=1039523, interview with Alan
404 Kay}, where he shares a revelation he had when reading John McCarthy's
405 @url{http://www.softwarepreservation.org/projects/LISP/book/LISP%201.5%20Programmers%20Manual.pdf,
409 that was the big revelation to me @dots{} when I finally understood that
410 the half page of code on the bottom of page 13 of the Lisp 1.5 manual
411 was Lisp in itself. These were “Maxwell’s Equations of Software!” This
412 is the whole world of programming in a few lines that I can put my hand
418 Our starting point is @file{hex0}, a 500 byte hex assembler and we need
419 to somehow close the gap to building the bootstrap binaries, esp. GNU
420 Gcc and the GNU C Library. What better way to do that than by
421 leveraging the powers of LISP?
423 GNU Mes is a Scheme@footnote{Scheme is a modern LISP} interpreter that
424 will be indirectly bootstrapped from @file{hex0} and that wields the
425 magical powers of LISP to close the bootstrap gap, asserting we can
426 enjoy software Freedom 1.
428 @c *********************************************************************
430 @chapter Installation
432 @cindex installing Mes
433 Mes is available for download from its website at
434 @url{http://www.gnu.org/pub/gnu/mes/}. This section describes the
435 software requirements of Mes, as well as how to install it and get ready
440 * Regular Requirements:: Software needed to build and run Mes.
441 * Bootstrap Requirements:: Software needed to bootstrap Mes.
442 * Running the Test Suites:: Testing Mes.
445 @node Regular Requirements
446 @section Regular Requirements
448 This section lists requirements when building Mes from source. The
449 build procedure for Mes is the same as for other GNU software, and is
450 not covered here. Please see the files @file{README} and @file{INSTALL}
451 in the Mes source tree for additional details.
453 GNU Mes depends on the following packages:
456 @item @url{http://gnu.org/software/guile/, GNU Guile}, version 2.0.13 or
457 later, including 2.2.x;
458 @item @url{http://www.gnu.org/software/make/, GNU Make}.
459 @item @url{https://savannah.gnu.org/projects/nyacc/, NYACC}, 0.86.0 is known to work.
460 @item @url{http://gcc.gnu.org, GCC's gcc}, version 2.95.3 or later.
463 The following dependencies are optional:
467 Installing @url{https://github.com/oriansj/mescc-tools/, mescc-tools},
468 version 0.5 or later, will allow you to have MesCC assemble and link.
471 @cindex Guile, compatibility
472 Mes is compatible with GNU Guile, so it is possible to share the same
473 Scheme code between both. Of course, Mes only supports the minimal
474 subset of R5RS and Guile extensions to run MesCC.
476 @node Bootstrap Requirements
477 @section Bootstrap Requirements
479 This section lists requirements when building Mes as a bootstrap
480 package. The bootstrap build procedure for Mes is similar to building
481 GNU software and goes like this
484 export prefix=/usr/local # for example
485 export MES_SEED=../mes # for example
486 # optionally set some other environment variables
492 See @file{build.sh} for inspiration on what environment variables to
495 Bootstrapping Mes depends on the following packages:
498 @item a POSIX-compatible shell
499 @item @url{https://github.com/oriansj/mescc-tools/, mescc-tools}, version 0.5 or later.
500 @item @url{http://gitlab.com/janneke/mes-seed/, mes-seed}, version 0.17 or later.
503 @node Running the Test Suites
504 @section Running the Test Suites
507 After a successful @command{configure} and @code{make} run, it is a good
508 idea to run the test suites.
514 Run Mes Scheme language semantics tests (@file{scaffold/boot}) only
517 build-aux/check-boot.sh
520 Run a single Mes boot test
523 MES_BOOT=scaffold/boot/00-zero.scm src/mes
526 Run a single Mes Scheme test
529 ./pre-inst-env tests/boot.test
530 MES=guile ./pre-inst-env tests/boot.test
536 build-aux/check-mescc.sh
539 Run a single MesCC test
542 CC=gcc CC32=i686-unknown-linux-gnu-gcc MES=guile \
543 build-aux/test.sh scaffold/tests/00-exit-0
547 @chapter Bootstrapping
550 Recipe for yogurt: Add yogurt to milk.
555 The bootstrap problem we have set out to solve is that none of our
556 modern software distributions, and GuixSD in particular, can be created
557 all from source code. In addition to the carefully signed source code
558 of all the programs (the `milk') an opaque binary seed (the `yogurt') is
559 injected as an essential dependency.
561 Why would this be a problem, I hear you ask? This is how it is done, we
562 always did it this way, everyone does it like this! Indeed, a popular
563 way of handling the bootstrapping issue is by ignoring it.
566 Your compiler becoming self-hosting@dots{}a language creator's wet
572 It seems that writing a self-hosting compiler is considered to be a
573 language creator's ultimate goal. It means that their language and
574 compiler have become powerful enough to not depend on a pre-exising
575 language that possibly is---but certainly was until now---more
576 powerful; it feels like passing the rite to adulthood.
578 When you see the irony, you grasp what our bootstrapping effort means in
579 practice. Creating bootstrappable software is not hard; actually most
580 softwares' first releases are bootstrappable. The problem of
581 bootstrapping is not a technical one, it is a lack of awareness and
585 * The Mes Bootstrap Process:: How Mes will make you yogurt from pure milk.
586 * Invoking Mes:: Running Mes, a minimalist Guile lookalike.
587 * Invoking MesCC:: Running the MesCC bootstrap compiler.
590 @node The Mes Bootstrap Process
591 @section The Mes Bootstrap Process
593 The Mes full source bootstrap process@footnote{TBH, the current state of
594 affairs demands to label this a `Reduced Binary Seed bootstrap'} is
595 currently being developed in GuixSD@footnote{See
596 @file{gnu/packages/commencement.scm} in the @var{core-updates-next} branch in Guix
598 @url{http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/mes.scm?h=wip-bootstrap}}.
599 In it's intiial form it is only available for x86-linux.
601 Currently, it goes like this:
604 mescc-tools-source + mescc-tools-seed => mescc-tools
606 mes-source + mescc-tools + mescc-seed => mes
608 tcc-source + mes + tinycc-seed => tcc
610 binutils-source + mes + tcc => binutils0
612 gcc-source + tcc + binutils0 => gcc-core
614 glibc-source + kernel-headers-source + binutils0 + gcc => glibc0
616 binutils-source + binutils0 + gcc + glibc => binutils
618 gcc-source + binutils + gcc-core + glibc => gcc
620 glibc-source + binutils + gcc + glibc0 => glibc
623 @c This graph is generated from wip-bootstrap, doing:
625 @c ~/src/guix-boot/pre-inst-env guix graph --type=bag -e '(@@ (gnu packages commencement) gcc-mesboot)' doc/images/gcc-mesboot-graph.dot
626 @c dot -T png doc/images/gcc-mesboot-graph.dot > doc/images/gcc-mesboot-graph.png
628 Here's a generated dependency diagram to for the final bootstrap gcc
629 that builds the rest of GuixSD
631 @image{images/gcc-mesboot-graph,2in,,Reference graph of the gcc-mesboot}
633 Work is ongoing to remove these binary seeds that were intentionally
634 injected by our own doing as temporary shortcut
636 mescc-tools-seed, mes-seed, tinycc-seed
639 For now, these additional non-bootstrapped dependencies (i.e., binary
640 seeds) are taken for granted
643 BOOTSTRAP-GUILE, bash, bzip2, coreutils, gawk, grep, gzip, patch, sed,
647 Although we think these are less essential and thus less interesting
648 than the GNU toolchain triplet that we focussed on initially, our next
649 priority is to eleminate these one by one.
652 @section Invoking Mes
655 The @command{mes} command is the Scheme interpreter whose prime
656 directive is to run the @command{MesCC} program.
658 For convenience and testing purposes, @command{mes} tries to mimic
662 mes @var{option}@dots{} @file{FILE}@dots{}
665 The @var{option}s can be among the following:
669 @item -s @var{script} @var{arg}@dots{}
671 By default, Mes will read a file named on the command line as a script.
672 Any command-line arguments @var{arg}@dots{} following @var{script}
673 become the script's arguments; the @code{command-line} function returns
674 a list of strings of the form @code{(@var{script} @var{arg}@dots{})}.
676 Scripts are read and evaluated as Scheme source code just as the
677 @code{load} function would. After loading @var{script}, Mes exits.
679 @item -c @var{expr} @var{arg}@dots{}
680 @cindex evaluate expression, command-line argument
681 Evaluate @var{expr} as Scheme code, and then exit. Any command-line
682 arguments @var{arg}@dots{}) following @var{expr} become command-line
683 arguments; the @code{command-line} function returns a list of strings of
684 the form @code{(@var{guile} @var{arg}@dots{})}, where @var{mes} is the
685 path of the Mes executable.
687 @item -- @var{arg}@dots{}
688 Run interactively, prompting the user for expressions and evaluating
689 them. Any command-line arguments @var{arg}@dots{} following the
690 @option{--} become command-line arguments for the interactive session;
691 the @code{command-line} function returns a list of strings of the form
692 @code{(@var{guile} @var{arg}@dots{})}, where @var{mes} is the path of the
695 @item -L,--load-path=@var{directory}
696 Add @var{directory} to the front of Mes module load path. The given
697 directories are searched in the order given on the command line and
698 before any directories in the @env{GUILE_LOAD_PATH} environment
701 @item -C,--compiled-path=@var{directory}
702 Accepted and ignored for Guile compatibility.
705 dump binary program to stdout
708 Load Scheme source code from @var{file}, and continue processing the
711 @item -e,--main=@var{function}
712 Make @var{function} the @dfn{entry point} of the script. After loading
713 the script file (with @option{-s}) or evaluating the expression (with
714 @option{-c}), apply @var{function} to a list containing the program name
715 and the command-line arguments---the list provided by the
716 @code{command-line} function.
719 Display help on invoking Mes, and then exit.
722 load binary program [module/mes/boot-0.32-mo]
724 @item -v@r{, }--version
725 Display the current version of Mes, and then exit.
730 * Environment Variables:: If the bits won't change, change their habitat.
733 @node Environment Variables
734 @subsection Environment Variables
735 @cindex environment variables
737 @cindex initialization
739 @c Hmm, I expected this paragraph in the Guix manual?
740 Here are the environment variables (see @pxref{Environment Variables,,,
741 guile, Guile Reference}) that affect the run-time behavior of
748 Set @env{MES_BOOT} to change the initial Scheme program that Mes runs.
753 The initial size of the arena @pxref{5.3,,, sicp, SICP} in cells. Default: 20,000.
756 @vindex MES_MAX_ARENA
758 The maximum size of the arena in cells. Default: 100,000,000.
768 @item included SCM modules and sources
769 @item result of program
770 @item gc stats at exit
781 @item parsed, expanded program
782 @item list of builtins
784 @item opened input strings
789 usage of opened input strings
793 @item GUILE_LOAD_PATH
794 @vindex GUILE_LOAD_PATH
795 This variable may be used to augment the path that is searched for
796 Scheme files when loading. Its value should be a colon-separated list
797 of directories. If it contains the special path component @code{...}
798 (ellipsis), then the default path is put in place of the ellipsis,
799 otherwise the default path is placed at the end. The result is stored
800 in @code{%load-path}.
802 Mes uses @var{@strong{GUILE}_LOAD_PATH} for compatibility with Guile.
807 @section Invoking MesCC
810 mescc @var{option}@dots{} @file{FILE}@dots{}
813 The @var{option}s can be among the following:
819 preprocess, compile and assemble only; do not link
821 @item -D @var{DEFINE}[=@var{VALUE}]
822 @cindex define DEFINE [VALUE=1]
825 preprocess only; do not compile, assemble or link
828 add @command{blood-elf} debug info
830 This enables GDB setting breakpoints on function names, and to have the
831 GDB backtrace command to show the function call stack.
834 display this help and exit
837 append DIR to include path
840 append DIR to library path
849 preprocess and compile only; do not assemble or link
852 display version and exit
854 @item -w,--write=TYPE
855 dump Nyacc AST using TYPE @{pretty-print,write@}
860 * MesCC Environment Variables:: There's no NIX like POSIX.
863 @node MesCC Environment Variables
864 @subsection MesCC Environment Variables
870 Setting @env{MES} to a mes-compatible Scheme will run MesCC using that
872 MES=guile mescc -c scaffold/main.c
875 See, now Guile has become compatible with Mes, instead of the other way
879 @vindex C_INCLUDE_PATH
887 Setting @env{NYACC_DEBUG} makes nyacc print names of function
888 during the parsing phase.
893 @c *********************************************************************
895 @chapter Contributing
898 * Building from Git:: The latest and greatest.
899 * Running Mes From the Source Tree:: Hacker tricks.
900 * The Perfect Setup:: The right tools.
901 * Coding Style:: Hygiene of the contributor.
902 * Submitting Patches:: Share your work.
905 @node Building from Git
906 @section Building from Git
908 If you want to hack GNU Mes itself, it is recommended to use the latest
909 version from the Git repository:
912 git clone git://git.savannah.gnu.org/mes.git
915 The easiest way to set up a development environment for Mes is, of
916 course, by using Guix! The following command starts a new shell where
917 all the dependencies and appropriate environment variables are set up to
921 guix environment -l guix.scm
924 Finally, you have to invoke @code{make check} to run tests
925 (@pxref{Running the Test Suites}). If anything fails, take a look at
926 installation instructions (@pxref{Installation}) or send a message to
927 the @email{bug-mes@@gnu.org} mailing list.
929 @node Running Mes From the Source Tree
930 @section Running Mes From the Source Tree
932 First, you need to have an environment with all the dependencies
933 available (@pxref{Building from Git}), and then simply prefix each
934 command by @command{./pre-inst-env} (the @file{pre-inst-env} script
935 lives in the top build tree of Mes).
937 @node The Perfect Setup
938 @section The Perfect Setup
940 The Perfect Setup to hack on Mes is basically the perfect setup used
941 for Guile hacking (@pxref{Using Guile in Emacs,,, guile, Guile Reference
942 Manual}). First, you need more than an editor, you need
943 @url{http://www.gnu.org/software/emacs, Emacs}, empowered by the
944 wonderful @url{http://nongnu.org/geiser/, Geiser}.
946 Geiser allows for interactive and incremental development from within
947 Emacs: code compilation and evaluation from within buffers, access to
948 on-line documentation (docstrings), context-sensitive completion,
949 @kbd{M-.} to jump to an object definition, a REPL to try out your code,
950 and more (@pxref{Introduction,,, geiser, Geiser User Manual}).
953 @section Coding Style
955 In general our code follows the GNU Coding Standards (@pxref{Top,,,
956 standards, GNU Coding Standards}). However, they do not say much about
957 Scheme, so here are some additional rules.
959 @subsection Programming Paradigm
961 Scheme code in Mes is written in a purely functional style.
963 @subsection Formatting Code
965 @cindex formatting code
967 When writing Scheme code, we follow common wisdom among Scheme
968 programmers. In general, we follow the
969 @url{http://mumble.net/~campbell/scheme/style.txt, Riastradh's Lisp
970 Style Rules}. This document happens to describe the conventions mostly
971 used in Guile’s code too. It is very thoughtful and well written, so
974 @cindex indentation, of code
975 @cindex formatting, of code
976 If you do not use Emacs, please make sure to let your editor knows these
979 Additionally, in Mes we prefer to format @code{if} statements like this
981 (if foo? trivial-then
982 (let ((bar (the-longer @dots{})))
988 @node Submitting Patches
989 @section Submitting Patches
991 Development is done using the Git distributed version control system.
992 Thus, access to the repository is not strictly necessary. We welcome
993 contributions in the form of patches as produced by @code{git
994 format-patch} sent to the @email{guix-patches@@gnu.org} mailing list.
996 Please write commit logs in the ChangeLog format (@pxref{Change Logs,,,
997 standards, GNU Coding Standards}); you can check the commit history for
1000 @subsection Reporting Bugs
1002 Encountering a problem or bug can be very frustrating for you as a user
1003 or potential contributor. For us as Mes maintainers, the preferred bug
1004 report includes a beautiful and tested patch that we can integrate
1007 However, please don't let our preference stop you from reporting a bug.
1008 There's one thing @emph{much} worse for us than getting a bug report
1009 without a patch: Reading a complaint or rant online about your
1010 frustrations and how our work sucks, without having heard directly what
1013 So if you report a problem, will it be fixed? And @strong{when}? The
1014 most honest answer is: It depends. Let's curry that informationless
1015 honesty with a more helpful and more blunt reminder of a mantra of free
1021 When will it be finished?
1024 It will be ready sooner if you help.
1027 @author Richard Stallman
1030 @cindex contact, irc, mailing list
1031 Join us on @code{#bootstrappable} on the Freenode IRC network or on
1032 @email{guix-devel@@gnu.org} to share your experience---good or bad.
1034 @cindex bug, bug report, reporting a bug
1035 Please send bug reports with full details to @email{bug-mes@@gnu.org}.
1037 @c *********************************************************************
1038 @node Acknowledgments
1039 @chapter Acknowledgments
1041 We would like to thank the following people for their help: Jeremiah
1042 Orians, Peter de Wachter, rain1, Ricardo Wurmus, Rutger van Beusekom.
1044 We also thank Ludovic Courtès for creating GuixSD and making the
1045 bootstrap problem so painfully visible, John McCarthy for creating
1046 LISP-1.5 and Alan Kay for their inspiring comment on
1047 @url{https://queue.acm.org/detail.cfm?id=1039523, Page 13}.
1049 @c *********************************************************************
1056 @url{https://bootstrappable.org, Bootstrappable Builds} Minimize the
1057 amount and size of opaque binary seeds we need to swallow.
1060 @url{https://reproducible-builds.org, Reproducible Builds}
1061 Provide a verifiable path from source code to binary.
1064 @url{https://gitlab.com/oriansj/stage0, Stage0}
1065 If we want, it could all start with a ~500 byte self-hosting hex
1069 @url{https://bootstrapping.miraheze.org, Bootstrapping wiki} An amazing
1070 collection of small/bootstrappable compilers, operating systems,
1074 @url{irc.freenode.net, #bootstrappable} The bootstrapping community home
1075 at the freenode IRC network.
1078 @file{guix-devel@@gnu.org} The Guix mailing list, where it all started.
1079 @url{https://lists.gnu.org/archive/html/guix-devel/, guix-devel archives}.
1083 @c *********************************************************************
1084 @node GNU Free Documentation License
1085 @appendix GNU Free Documentation License
1086 @cindex license, GNU Free Documentation License
1087 @include fdl-1.3.texi
1089 @c *********************************************************************
1091 @unnumbered Concept Index
1094 @node Programming Index
1095 @unnumbered Programming Index
1103 @c ispell-local-dictionary: "american";