33This page is intended to keep track of useful information for people who
44want to modify the Flambda backend. Jump to:
55
6- - [ Branches, pull requests, etc.] ( #branches-pull-requests-etc )
7- - [ Upstream subtree] ( #upstream-subtree )
8- - [ Code formatting] ( #code-formatting )
9- - [ Rebuilding during dev work] ( #rebuilding-during-dev-work )
10- - [ Updating magic numbers] ( #updating-magic-numbers )
11- - [ Running tests] ( #running-tests )
12- - [ Running only part of the upstream testsuite] ( #running-only-part-of-the-upstream-testsuite )
13- - [ Running tests with coverage analysis] ( #running-tests-with-coverage-analysis )
14- - [ Running the compiler produced by "make hacking" on an example without the stdlib] ( #running-the-compiler-produced-by-make-hacking-on-an-example-without-the-stdlib )
15- - [ Using the OCaml debugger to debug the compiler] ( #using-the-ocaml-debugger-to-debug-the-compiler )
16- - [ Alternative debugger workflow] ( #alternative-debugger-workflow )
17- - [ Getting the compilation command for a stdlib file] ( #getting-the-compilation-command-for-a-stdlib-file )
18- - [ Bootstrapping the ocaml subtree] ( #bootstrapping-the-ocaml-subtree )
19- - [ Testing the compiler built locally with OPAM (new method)] ( #testing-the-compiler-built-locally-with-opam-new-method )
20- - [ Testing the compiler built locally with OPAM (old method)] ( #testing-the-compiler-built-locally-with-opam-old-method )
21- - [ Pulling changes onto a release branch] ( #pulling-changes-onto-a-release-branch )
22- - [ Rebasing to a new major version of the upstream compiler] ( #rebasing-to-a-new-major-version-of-the-upstream-compiler )
23- - [ How to add a new intrinsic to the compiler] ( #how-to-add-a-new-intrinsic-to-the-compiler )
24- - [ How to add a new command line option] ( #how-to-add-a-new-command-line-option )
25- - [ Installation tree comparison script] ( #installation-tree-comparison-script )
6+ - [ Hacking on the Flambda backend] ( #hacking-on-the-flambda-backend )
7+ - [ Branches, pull requests, etc.] ( #branches-pull-requests-etc )
8+ - [ Code formatting] ( #code-formatting )
9+ - [ Rebuilding during dev work] ( #rebuilding-during-dev-work )
10+ - [ Updating magic numbers] ( #updating-magic-numbers )
11+ - [ Running tests] ( #running-tests )
12+ - [ Running only part of the upstream testsuite] ( #running-only-part-of-the-upstream-testsuite )
13+ - [ Running tests with coverage analysis] ( #running-tests-with-coverage-analysis )
14+ - [ Running the compiler produced by "make hacking" on an example without the stdlib] ( #running-the-compiler-produced-by-make-hacking-on-an-example-without-the-stdlib )
15+ - [ Using the OCaml debugger to debug the compiler] ( #using-the-ocaml-debugger-to-debug-the-compiler )
16+ - [ Alternative debugger workflow] ( #alternative-debugger-workflow )
17+ - [ Getting the compilation command for a stdlib file] ( #getting-the-compilation-command-for-a-stdlib-file )
18+ - [ Bootstrapping] ( #bootstrapping )
19+ - [ Testing the compiler built locally with OPAM (new method)] ( #testing-the-compiler-built-locally-with-opam-new-method )
20+ - [ Testing the compiler built locally with OPAM (old method)] ( #testing-the-compiler-built-locally-with-opam-old-method )
21+ - [ How to add a new intrinsic to the compiler] ( #how-to-add-a-new-intrinsic-to-the-compiler )
22+ - [ How to add a new command line option] ( #how-to-add-a-new-command-line-option )
23+ - [ Installation tree comparison script] ( #installation-tree-comparison-script )
2624
2725## Branches, pull requests, etc.
2826
@@ -32,21 +30,10 @@ PRs should not be merged unless all CI checks have passed unless there is a good
3230reason. It is not necessary to wait for CI checks to pass after genuinely trivial
3331changes to a PR that was previously passing CI.
3432
35- There are also release branches (e.g. ` release-4.12 ` ) which are used for cutting
36- production releases (which are all marked by git tags). These branches should not be
37- committed to without approval from the person responsible for the next release.
38-
39- ## Upstream subtree
40-
41- The ` ocaml/ ` directory contains a patched version of the upstream OCaml compiler
42- around which is built the Flambda backend. This directory is currently handled as
43- a git subtree (not a submodule).
44-
45- Patches to the ` ocaml/ ` subdirectory should be minimised and in the majority of cases
46- be suitable for upstream submission.
47-
48- We are planning to move to a model where the patched upstream compiler is maintained
49- in a normal upstream-style repository (i.e. forked from [ ` ocaml/ocaml ` ] ( https://github.com/ocaml/ocaml ) ).
33+ There are also release microbranches (e.g. ` 5.2.0minus-1-microbranch ` ) which are
34+ used for cutting production releases (which are all marked by git tags). These
35+ branches should not be committed to without approval from the person responsible
36+ for the next release.
5037
5138## Code formatting
5239
@@ -105,34 +92,9 @@ This target is likely what you want for development of large features in the mid
10592backend. Rebuild times for this target should be very fast. (` make hacking ` can be
10693run directly after ` configure ` , there is no need to do a full ` make ` first.)
10794
108- The aim is to minimise patches against the upstream compiler (the
109- contents of the ocaml/ subdirectory), but you can configure and build
110- in that directory as you would for upstream. If a bootstrap is
111- required, the normal bootstrapping commands should also work: from
112- within the ocaml/ subdirectory, follow the instructions in
113- [ ocaml/BOOTSTRAP.adoc] ( ocaml/BOOSTRAP.adoc ) ; the newly-bootstrapped
114- compiler will be picked up the next time that the Flambda backend is
115- built from the toplevel directory of the checkout.
116-
117- Any changes in ` ocaml/asmcomp ` and ` ocaml/middle_end ` directories
118- should also be applied to the corresponding directories ` backend ` and
119- ` middle_end ` .
120-
12195## Updating magic numbers
12296
123- Start from a completely clean tree. Then change into the ` ocaml ` subdirectory
124- and proceed as follows:
125- ```
126- ./configure
127- make coldstart
128- make coreall
129- ```
130- Then edit ` runtime/caml/exec.h ` and ` utils/config.mlp ` to bump the numbers. Then:
131- ```
132- make coreall
133- make bootstrap
134- ```
135- and commit the result.
97+ We should be able to use ` tools/bump-magic-numbers ` going forward.
13698
13799## Running tests
138100
@@ -148,10 +110,8 @@ There is also a `make ci` target which does a full build and test run.
148110Some of our tests are expect tests run using a custom tool called ` flexpect ` .
149111Corrected outputs can be promoted using ` make promote ` .
150112
151- See ` ocaml/HACKING.jst.adoc ` for documentation on additional test-related
152- targets. When that documentation says to run (say) ` make -f Makefile.jst test-one `
153- from the ` ocaml ` subdirectory, you should instead run ` make test-one ` from the
154- root of the repo. Here are some examples of commands you can run:
113+ See ` HACKING.jst.adoc ` for documentation on additional test-related
114+ targets. Here are some examples of commands you can run:
155115
156116```
157117$ make test-one TEST=typing-local/local.ml
@@ -162,13 +122,13 @@ $ make promote-one-no-rebuild TEST=typing-local/local.ml
162122$ make promote-failed
163123# You can also use the full path from the root of the repo.
164124# This interacts better with tab completion.
165- $ make test-one TEST=ocaml/ testsuite/tests/typing-local/local.ml
125+ $ make test-one TEST=testsuite/tests/typing-local/local.ml
166126```
167127
168128## Running only part of the upstream testsuite
169129
170130This can be done from the ` _runtest ` directory after it has been initialised by a previous ` make runtest-upstream ` .
171- Any changes you have made to the tests in the real testsuite directory (` ocaml/ testsuite/` ) will need to be copied
131+ Any changes you have made to the tests in the real testsuite directory (` testsuite/ ` ) will need to be copied
172132into here first. Then you can do things like:
173133```
174134OCAMLSRCDIR=<FLAMBDA_BACKEND>/_runtest make one DIR=tests/runtime-errors
@@ -212,8 +172,8 @@ something like:
212172First, run ` make debug ` . This completes four steps:
213173
2141741 . ` make install `
215- 2 . Sets up the ` ocaml/ tools/debug_printers` script so that you can `source
216- ocaml/ tools/debug_printers` during a debugging session to see
175+ 2 . Sets up the ` tools/debug_printers ` script so that you can `source
176+ tools/debug_printers` during a debugging session to see
217177 otherwise-abstract variable values.
2181783 . Symlinks ` ./ocamlc ` and ` ./ocamlopt ` to point to the bytecode versions of
219179 those compilers. This is convenient for emacs integration, because emacs
@@ -313,7 +273,7 @@ ocamldebug emacs mode as follows:
313273 printing any value may produce ` Cannot find module Misc. ` or similar
314274 errors). If debugging ` ocamlc ` , run:
315275 ```
316- (ocd) directory _build/main/ocaml/ .ocamlcommon.objs/byte
276+ (ocd) directory _build/main/.ocamlcommon.objs/byte
317277 ```
318278 If debugging ` ocamlopt ` , you'll need various additional directories depending
319279 on your middle end. You can find the right directories by searching for cmo
@@ -327,18 +287,15 @@ above.
327287
328288For example because you need to get the ` -dflambda ` output because of a bug.
329289```
330- rm -f _build/runtime_stdlib/ocaml/ stdlib/.stdlib.objs/native/std_exit.cmx
331- <DUNE> build --workspace=duneconf/runtime_stdlib.ws --verbose ocaml/ stdlib/.stdlib.objs/native/std_exit.cmx
290+ rm -f _build/runtime_stdlib/stdlib/.stdlib.objs/native/std_exit.cmx
291+ <DUNE> build --workspace=duneconf/runtime_stdlib.ws --verbose stdlib/.stdlib.objs/native/std_exit.cmx
332292```
333293where ` <DUNE> ` is the path to the dune provided to ` configure ` .
334294
335- ## Bootstrapping the ocaml subtree
295+ ## Bootstrapping
336296
337- This can be done following the usual upstream procedures,
338- working entirely within the ` ocaml/ ` subdirectory. Thoroughly clean the tree (e.g. ` git clean -dfX ` ),
339- go into ` ocaml/ ` , then run the upstream configure script. After that perform the bootstrap (e.g.
340- ` make core ` followed by ` make bootstrap ` ). Before recompiling the Flambda backend as normal it would
341- be advisable to clean the whole tree again.
297+ Bootstrapping is not required in flambda-backend. The system compiler is used
298+ for the first stage.
342299
343300## Testing the compiler built locally with OPAM (new method)
344301
@@ -426,24 +383,6 @@ installation properly without deleting the whole switch; if the set of installed
426383files change between one ` make install_for_opam ` command and the next, strange
427384bugs might appear.
428385
429- ## Pulling changes onto a release branch
430-
431- This should only be done with the approval of the person responsible for the next release.
432- One way of doing it is as follows:
433- ```
434- git checkout -b release-4.12 flambda-backend/release-4.12
435- git reset --hard flambda-backend/main
436- git rebase -i flambda-backend/release-4.12
437- ```
438- assuming that ` flambda-backend ` is the git remote for the Flambda backend repo.
439-
440- The resulting local branch ` release-4.12 ` should _ not_ require a force push when pushed
441- to the remote.
442-
443- ## Rebasing to a new major version of the upstream compiler
444-
445- The procedure for this is still under development; talk to @poechsel or @mshinwell .
446-
447386## How to add a new intrinsic to the compiler
448387
449388The Flambda backend has a means of replacing calls to external functions
0 commit comments