Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into flatten-regions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukemaurer committed Apr 12, 2023
2 parents 5b62db1 + e138734 commit 6126e9e
Show file tree
Hide file tree
Showing 928 changed files with 75,273 additions and 28,586 deletions.
74 changes: 41 additions & 33 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ jobs:
use_runtime: d
ocamlrunparam: "v=0,V=1"

- name: closure_cfg_local
config: --enable-middle-end=closure --enable-stack-allocation
- name: closure_cfg
config: --enable-middle-end=closure --enable-poll-insertion
os: ubuntu-latest
ocamlparam: _,ocamlcfg=1

Expand All @@ -28,29 +28,41 @@ jobs:
ocamlparam: ''

- name: flambda1_frame_pointers
config: --enable-middle-end=flambda --enable-frame-pointers
config: --enable-middle-end=flambda --enable-frame-pointers --enable-poll-insertion
os: ubuntu-latest
ocamlparam: ''

- name: flambda1_cfg_local
config: --enable-middle-end=flambda --enable-stack-allocation
- name: flambda1_cfg
config: --enable-middle-end=flambda --enable-poll-insertion
os: ubuntu-latest
ocamlparam: _,ocamlcfg=1

- name: flambda2
- name: flambda2_debug_runtime
config: --enable-middle-end=flambda2
os: ubuntu-latest
ocamlparam: ''
use_runtime: d
ocamlrunparam: "v=0,V=1"

- name: flambda2_debug_runtime_nnp
config: --enable-middle-end=flambda2 --disable-naked-pointers
os: ubuntu-latest
ocamlparam: ''
use_runtime: d
ocamlrunparam: "v=0,V=1"

- name: flambda2_nnp
config: --enable-middle-end=flambda2 --disable-naked-pointers
os: ubuntu-latest
ocamlparam: ''

- name: flambda2_frame_pointers
config: --enable-middle-end=flambda2 --enable-frame-pointers
config: --enable-middle-end=flambda2 --enable-frame-pointers --enable-poll-insertion
os: ubuntu-latest
ocamlparam: ''

- name: flambda2_cfg_local
config: --enable-middle-end=flambda2 --enable-stack-allocation
- name: flambda2_cfg
config: --enable-middle-end=flambda2
os: ubuntu-latest
ocamlparam: _,ocamlcfg=1

Expand All @@ -67,15 +79,15 @@ jobs:
irc_split: off
irc_spilling_heuristics: flat_uses

- name: build_upstream-32-bit
config: --enable-middle-end=closure CC="gcc -m32" AS="as --32" ASPP="gcc -m32 -c" -host i386-linux PARTIALLD="ld -r -melf_i386"
os: ubuntu-latest
- name: build_upstream_closure
config: --enable-middle-end=closure
os: ubuntu-20.04

env:
J: "3"
# On macOS, the testsuite is slow, so run only on push to main (#507)
run_testsuite: "${{matrix.os != 'macos-latest' || (github.event_name == 'push' && github.event.ref == 'refs/heads/main')}}"
build_upstream: "${{matrix.name == 'build_upstream-32-bit'}}"
build_upstream: "${{matrix.name == 'build_upstream_closure'}}"
REGISTER_ALLOCATOR: "${{matrix.register_allocator}}"
IRC_SPLIT: "${{matrix.irc_split}}"
IRC_SPILLING_HEURISTICS: "${{matrix.irc_spilling_heuristics}}"
Expand All @@ -86,68 +98,64 @@ jobs:
with:
path: 'flambda_backend'

- name: Cache OCaml 4.12 and dune
- name: Cache OCaml 4.14 and dune
uses: actions/cache@v1
id: cache
with:
path: ${{ github.workspace }}/ocaml-412/_install
key: ${{ matrix.os }}-cache-ocaml-412-dune-341
path: ${{ github.workspace }}/ocaml-414/_install
key: ${{ matrix.os }}-cache-ocaml-414-dune-361

- name: Checkout OCaml 4.12
- name: Checkout OCaml 4.14
uses: actions/checkout@master
if: steps.cache.outputs.cache-hit != 'true'
with:
repository: 'ocaml/ocaml'
path: 'ocaml-412'
ref: '4.12'
path: 'ocaml-414'
ref: '4.14'

- name: Build OCaml 4.12
- name: Build OCaml 4.14
if: steps.cache.outputs.cache-hit != 'true'
working-directory: ocaml-412
working-directory: ocaml-414
run: |
./configure --prefix=$GITHUB_WORKSPACE/ocaml-412/_install
./configure --prefix=$GITHUB_WORKSPACE/ocaml-414/_install
make -j $J world.opt
make install
# Remove unneeded parts to shrink cache file
rm -rf $GITHUB_WORKSPACE/ocaml-412/_install/{lib/ocaml/compiler-libs,lib/ocaml/expunge,bin/*.byte}
rm -rf $GITHUB_WORKSPACE/ocaml-414/_install/{lib/ocaml/compiler-libs,lib/ocaml/expunge,bin/*.byte}
- name: Checkout dune github repo
uses: actions/checkout@master
if: steps.cache.outputs.cache-hit != 'true'
with:
repository: 'ocaml/dune'
ref: '3.4.1'
ref: '3.6.1'
path: 'dune'

- name: Build dune
working-directory: dune
if: steps.cache.outputs.cache-hit != 'true'
run: |
PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH make release
cp dune.exe $GITHUB_WORKSPACE/ocaml-412/_install/bin/dune
PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH make release
cp _boot/dune.exe $GITHUB_WORKSPACE/ocaml-414/_install/bin/dune
- name: Install GNU parallel
if: matrix.os == 'macos-latest'
run: HOMEBREW_NO_INSTALL_CLEANUP=TRUE brew install parallel

- name: Install GCC 32-bit libraries
if: matrix.name == 'build_upstream-32-bit'
run: sudo apt-get install gcc-multilib gfortran-multilib

- name: Configure Flambda backend
working-directory: flambda_backend
run: |
autoconf
./configure \
--prefix=$GITHUB_WORKSPACE/_install \
--with-dune=$GITHUB_WORKSPACE/ocaml-412/_install/bin/dune \
--with-dune=$GITHUB_WORKSPACE/ocaml-414/_install/bin/dune \
${{ matrix.config }}
- name: Build, install and test Flambda backend
working-directory: flambda_backend
run: |
if [ $run_testsuite = true ]; then target=ci; else target=compiler; fi
export PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH
export PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH
if [ $build_upstream = true ]; then make -j$J build_and_test_upstream; else make $target; fi
env:
BUILD_OCAMLPARAM: ${{ matrix.ocamlparam }}
Expand All @@ -158,4 +166,4 @@ jobs:
working-directory: flambda_backend
if: matrix.check_arch == true
run: |
PATH=$GITHUB_WORKSPACE/ocaml-412/_install/bin:$PATH make check_all_arches
PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH make check_all_arches
15 changes: 4 additions & 11 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
path: 'flambda_backend'

# This adds a switch at $GITHUB_WORKSPACE/_opam
- name: Set up OCaml 4.12
- name: Set up OCaml 4.14
uses: ocaml/setup-ocaml@v2
with:
ocaml-compiler: 4.12
ocaml-compiler: 4.14
opam-pin: false
opam-depext: false

Expand All @@ -35,19 +35,12 @@ jobs:
id: cache
with:
path: ${{ github.workspace }}/_opam
key: ${{ matrix.os }}-cache-ocaml-412-dune-2.9.1-g7606d586

- name: Build Dune
if: steps.cache.outputs.cache-hit != 'true'
run: |
opam pin dune --yes \
git+https://github.com/ocaml-flambda/dune#special_dune
key: ${{ matrix.os }}-cache-ocaml-414-dune-2.9.1-g7606d586

- name: Build bisect_ppx
if: steps.cache.outputs.cache-hit != 'true'
run: |
# bisect_ppx fails to build with current ppxlib
opam pin ppxlib 0.23.0 --yes
opam pin ppxlib 0.25.1
opam pin bisect_ppx --yes \
git+https://github.com/lukemaurer/bisect_ppx#html-report-collate-fix
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ocamlformat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
matrix:
os: [ubuntu-latest]
ocaml-compiler:
- "4.12.0"
- "4.14.0"

steps:
- name: Checkout the Flambda backend repo
Expand All @@ -26,8 +26,8 @@ jobs:
- name: Install a recent version of re
run: opam install 're>=1.10.0'

- name: Install ocamlformat 0.19.0
run: opam pin -y ocamlformat 0.19.0
- name: Install ocamlformat 0.24.1
run: opam pin -y ocamlformat 0.24.1

- name: autoconf
working-directory: flambda_backend
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
*.lib
*.dll
*.la
*.cm[ioxat]
*.cm[ioxats]
*.cmx[as]
*.cmti
*.cmsi
*.annot
*.exe
*.exe.manifest
Expand Down
4 changes: 4 additions & 0 deletions .ocamlformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Please make a pull request to change this file.
# Each directory that enables ocamlformat sets its own options, so here we just
# disable it by default.
disable=true
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"ocaml.sandbox": {
"kind": "opam",
"switch": "4.12.0"
"switch": "4.14.1"
}
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"label": "Build & install Flambda backend",
"type": "shell",
"command": "opam exec --switch=4.11.1 make install",
"command": "opam exec --switch=4.14.0 make install",
"group": "build",
"problemMatcher": [
"$ocamlc"
Expand Down
61 changes: 39 additions & 22 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,23 @@
This page is intended to keep track of useful information for people who
want to modify the Flambda backend. Jump to:

- [Branches, pull requests, etc.](#branches-pull-requests-etc)
- [Upstream subtree](#upstream-subtree)
- [Code formatting](#code-formatting)
- [Rebuilding during dev work](#rebuilding-during-dev-work)
- [Running tests](#running-tests)
- [Running only part of the upstream testsuite](#running-only-part-of-the-upstream-testsuite)
- [Running tests with coverage analysis](#running-tests-with-coverage-analysis)
- [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)
- [Getting the compilation command for a stdlib file](#getting-the-compilation-command-for-a-stdlib-file)
- [Bootstrapping the ocaml subtree](#bootstrapping-the-ocaml-subtree)
- [Testing the compiler built locally with OPAM](#testing-the-compiler-built-locally-with-opam)
- [Pulling changes onto a release branch](#pulling-changes-onto-a-release-branch)
- [Rebasing to a new major version of the upstream compiler](#rebasing-to-a-new-major-version-of-the-upstream-compiler)
- [How to add a new intrinsic to the compiler](#how-to-add-a-new-intrinsic-to-the-compiler)
- [How to add a new command line option](#how-to-add-a-new-command-line-option)
- [Installation tree comparison script](#installation-tree-comparison-script)
- [Branches, pull requests, etc.](#branches-pull-requests-etc)
- [Upstream subtree](#upstream-subtree)
- [Code formatting](#code-formatting)
- [Rebuilding during dev work](#rebuilding-during-dev-work)
- [Updating magic numbers](#updating-magic-numbers)
- [Running tests](#running-tests)
- [Running only part of the upstream testsuite](#running-only-part-of-the-upstream-testsuite)
- [Running tests with coverage analysis](#running-tests-with-coverage-analysis)
- [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)
- [Getting the compilation command for a stdlib file](#getting-the-compilation-command-for-a-stdlib-file)
- [Bootstrapping the ocaml subtree](#bootstrapping-the-ocaml-subtree)
- [Testing the compiler built locally with OPAM](#testing-the-compiler-built-locally-with-opam)
- [Pulling changes onto a release branch](#pulling-changes-onto-a-release-branch)
- [Rebasing to a new major version of the upstream compiler](#rebasing-to-a-new-major-version-of-the-upstream-compiler)
- [How to add a new intrinsic to the compiler](#how-to-add-a-new-intrinsic-to-the-compiler)
- [How to add a new command line option](#how-to-add-a-new-command-line-option)
- [Installation tree comparison script](#installation-tree-comparison-script)

## Branches, pull requests, etc.

Expand Down Expand Up @@ -89,7 +90,7 @@ Depending on the initial changes, it might be necessary to do this multiple time
## Rebuilding during dev work

To rebuild after making changes, you can just type `make`. You need to
have a working OCaml 4.12 compiler on your PATH before doing so,
have a working OCaml 4.14 compiler on your PATH before doing so,
e.g. installed via OPAM.

There is a special target `make hacking` which starts Dune in polling mode. The rebuild
Expand All @@ -112,6 +113,22 @@ Any changes in `ocaml/asmcomp` and `ocaml/middle_end` directories
should also be applied to the corresponding directories `backend` and
`middle_end`.

## Updating magic numbers

Start from a completely clean tree. Then change into the `ocaml` subdirectory
and proceed as follows:
```
./configure
make coldstart
make coreall
```
Then edit `runtime/exec.h` and `utils/config.mlp` to bump the numbers. Then:
```
make coreall
make bootstrap
```
and commit the result.

## Running tests

Prior to `make install` you can do:
Expand Down Expand Up @@ -206,7 +223,7 @@ thoroughly (e.g. `git clean -dfX`) before reconfiguring with a different prefix.

Then build the compiler with the command `make _install` (this is the default
target plus some setup in preparation for installation). As usual when building,
a 4.12 compiler (and dune) need to be in the path.
a 4.14 compiler (and dune) need to be in the path.

Now the build part is done, we don't need to stay in the build environment
anymore; the switch creation will likely replace it if your terminal is setup
Expand All @@ -225,12 +242,12 @@ opam switch create flambda-backend --empty --repositories=flambda2=git+https://g
Then we can install the compiler. The recommended way is to use the `opam-custom-install`
plugin. See [here](https://gitlab.ocamlpro.com/louis/opam-custom-install)
for instructions. The plugin can be installed in any existing OPAM switch,
for example a 4.12 switch used for building. Once installed, the plugin will be
for example a 4.14 switch used for building. Once installed, the plugin will be
available whatever the current active switch is.
Once the plugin is installed, we can use it to install the compiler:

```shell
opam custom-install ocaml-variants.4.12.0+flambda2 -- make -C ${flambda-backend-root-dir} install_for_opam
opam custom-install ocaml-variants.4.14.0+flambda2 -- make -C ${flambda-backend-root-dir} install_for_opam
```
The `-C ${flambda-backend-dir}` part can be omitted if we're still in the build directory.

Expand All @@ -239,7 +256,7 @@ it is recommended to run the command `opam reinstall --forget-pending` after
every use of `opam custom-install`, otherwise any subsequent `opam` command
tries to rebuild the compiler from scratch.

To finish the installation, `opam install ocaml.4.12.0` will install the remaining
To finish the installation, `opam install ocaml.4.14.0` will install the remaining
auxiliary packages necessary for a regular switch. After that, normal opam
packages can be installed the usual way.

Expand All @@ -252,7 +269,7 @@ As `opam-custom-install` is still experimental, it can sometimes be hard to inst
In this case, it is possible to use the more fragile `opam install --fake` command:

```shell
opam install --fake ocaml-variants.4.12.0+flambda2
opam install --fake ocaml-variants.4.14.0+flambda2
make -C ${flambda-backend-root-dir} install_for_opam
```

Expand Down
Loading

0 comments on commit 6126e9e

Please sign in to comment.