Skip to content

Configure flag to use the 5.x runtime; make the 5.x runtime build #2004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ jobs:
os: ubuntu-latest
build_ocamlparam: _,ocamlcfg=1

- name: flambda2_runtime5
config: --enable-middle-end=flambda2 --enable-runtime5
os: ubuntu-latest
expected_fail: true

- name: flambda2_debug_runtime
config: --enable-middle-end=flambda2
os: ubuntu-latest
Expand Down Expand Up @@ -99,11 +104,17 @@ jobs:
config: --enable-middle-end=closure
os: ubuntu-20.04

- name: build_upstream_closure_runtime5
config: --enable-middle-end=closure --enable-runtime5
os: ubuntu-20.04
expected_fail: true

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_closure'}}"
expected_fail: "${{matrix.expected_fail == true}}"

steps:
- name: Checkout the Flambda backend repo
Expand Down Expand Up @@ -210,7 +221,13 @@ jobs:
run: |
if [ $run_testsuite = true ]; then target=ci; else target=compiler; fi
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
if [ $build_upstream = true ]; then \
make -j$J build_and_test_upstream \
|| (if [ $expected_fail = true ]; then exit 0; else exit 1; fi); \
else \
make $target \
|| (if [ $expected_fail = true ]; then exit 0; else exit 1; fi); \
fi
env:
BUILD_OCAMLPARAM: ${{ matrix.build_ocamlparam }}
OCAMLPARAM: ${{ matrix.ocamlparam }}
Expand Down
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ ci-coverage: boot-runtest coverage
.PHONY: minimizer-upstream
minimizer-upstream:
cp chamelon/dune.upstream chamelon/dune
cd chamelon && $(dune) build
cd chamelon && RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build

.PHONY: minimizer
minimizer: _build/_bootinstall
cp chamelon/dune.jst chamelon/dune
cd chamelon && $(dune) build
cd chamelon && RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build

.PHONY: hacking-runtest
hacking-runtest: _build/_bootinstall
$(dune) build $(ws_boot) $(coverage_dune_flags) -w $(boot_targets) @runtest
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) $(coverage_dune_flags) -w $(boot_targets) @runtest

# Only needed for running the test tools by hand; runtest will take care of
# building them using Dune
.PHONY: test-tools
test-tools: runtime-stdlib
$(dune) build $(ws_main) @middle_end/flambda2/tests/tools/all
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_main) @middle_end/flambda2/tests/tools/all

ARCHES=amd64 arm64
.PHONY: check_all_arches
check_all_arches: _build/_bootinstall
for arch in $(ARCHES); do \
ARCH=$$arch $(dune) build $(ws_boot) ocamloptcomp.cma; \
ARCH=$$arch RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) ocamloptcomp.cma; \
done

# Compare the Flambda backend installation tree against the upstream one.
Expand Down Expand Up @@ -83,7 +83,7 @@ _compare/config.status: ocaml/config.status

.PHONY: promote
promote:
$(dune) promote $(ws_main)
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) promote $(ws_main)

.PHONY: fmt
fmt:
Expand All @@ -109,24 +109,24 @@ check-fmt:

.PHONY: regen-flambda2-parser
regen-flambda2-parser: $(dune_config_targets)
$(dune) build $(ws_boot) @middle_end/flambda2/parser/regen --auto-promote || true
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) @middle_end/flambda2/parser/regen --auto-promote || true
# Make sure regeneration is idempotent, and also check that the previous step
# worked (can't tell the difference between failure and successful
# auto-promotion)
$(dune) build $(ws_boot) @middle_end/flambda2/parser/regen
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) @middle_end/flambda2/parser/regen

.PHONY: regen-flambda2-tests
regen-flambda2-tests: boot-compiler regen-flambda2-test-dune-rules
$(dune) build $(ws_runstd) \
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_runstd) \
@middle_end/flambda2/tests/regen --auto-promote || true
$(dune) build $(ws_runstd) \
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_runstd) \
@middle_end/flambda2/tests/regen

.PHONY: regen-flambda2-test-dune-rules
regen-flambda2-test-dune-rules: $(dune_config_targets)
$(dune) build $(ws_boot) \
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) \
@middle_end/flambda2/tests/regen-dune-rules --auto-promote || true
$(dune) build $(ws_boot) \
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) \
@middle_end/flambda2/tests/regen-dune-rules

## Build upstream compiler.
Expand Down
10 changes: 5 additions & 5 deletions backend/amd64/emit.mlp
Original file line number Diff line number Diff line change
Expand Up @@ -1761,13 +1761,13 @@ let emit_instr fallthrough i =
load_label_addr lbl_handler r11;
I.push r11;
cfi_adjust_cfa_offset 8;
I.push (domain_field Domainstate.Domain_exception_pointer);
I.push (domain_field Domainstate.Domain_exn_handler);
cfi_adjust_cfa_offset 8;
I.mov rsp (domain_field Domainstate.Domain_exception_pointer);
I.mov rsp (domain_field Domainstate.Domain_exn_handler);
stack_offset := !stack_offset + 16;
| Lpoptrap ->
emit_pop_trap_label ();
I.pop (domain_field Domainstate.Domain_exception_pointer);
I.pop (domain_field Domainstate.Domain_exn_handler);
cfi_adjust_cfa_offset (-8);
I.add (int 8) rsp;
cfi_adjust_cfa_offset (-8);
Expand All @@ -1787,8 +1787,8 @@ let emit_instr fallthrough i =
(* BACKPORT END *)
record_frame Reg.Set.empty (Dbg_raise i.dbg)
| Lambda.Raise_notrace ->
I.mov (domain_field Domainstate.Domain_exception_pointer) rsp;
I.pop (domain_field Domainstate.Domain_exception_pointer);
I.mov (domain_field Domainstate.Domain_exn_handler) rsp;
I.pop (domain_field Domainstate.Domain_exn_handler);
I.pop r11;
I.jmp r11
end
Expand Down
10 changes: 8 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
AC_PREREQ([2.69])
AC_INIT([The Flambda backend for OCaml],
5.1.1+jst-runtime4,
5.1.1+jst,
[[email protected]],
[flambda_backend],
[http://github.com/ocaml-flambda/flambda_backend])
Expand Down Expand Up @@ -36,6 +36,12 @@ AC_ARG_ENABLE([middle-end],
[*], [AC_MSG_ERROR([Bad middle end (not closure, flambda or flambda2)])])],
[AC_MSG_ERROR([--enable-middle-end=closure|flambda|flambda2 must be provided])])

AC_ARG_ENABLE([runtime5],
[AS_HELP_STRING([--enable-runtime5],
[Use the OCaml 5 runtime])],
[runtime5_arg=--enable-runtime5],
[runtime5_arg=])

AC_ARG_ENABLE([coverage],
[AS_HELP_STRING([--enable-coverage],
[Run compiler tests instrumented to output coverage data using bisect_ppx
Expand All @@ -62,7 +68,7 @@ AC_SUBST([legacy_layout])
AC_DISABLE_OPTION_CHECKING

AX_SUBDIRS_CONFIGURE([ocaml],
[$middle_end_arg,-C,--disable-ocamldoc,--disable-stdlib-manpages,--enable-ocamltest],
[$middle_end_arg,$runtime5_arg,-C,--disable-ocamldoc,--disable-stdlib-manpages,--enable-ocamltest],
[],
[],
[])
Expand Down
3 changes: 3 additions & 0 deletions ocaml/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -358,3 +358,6 @@ META
/yacc/.gdb_history

/otherlibs/dynlink/natdynlinkops

dune.runtime_selection

Loading