Skip to content
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

Fix the build system when using dune 3.11 and above #2114

Merged
merged 5 commits into from
May 10, 2024
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
5 changes: 1 addition & 4 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ To rebuild after making changes, you can just type `make`. You need to
have a working OCaml 4.14 or 4.14.1 compiler on your PATH before doing so,
e.g. installed via OPAM. You also need to have dune and menhir.

<!-- CR someone: investigate this -->
The build currently fails when using the latest version of `dune` (3.11.1).
To install a known-good dune, run `opam pin add dune 3.8.1`. `menhir` should be pinned to a specific
version as well: `opam pin add menhir 20210419`.
`menhir` should be pinned to a specific version: `opam pin add menhir 20210419`.

There is a special target `make hacking` which starts Dune in polling mode. The rebuild
performed here is equivalent to `make ocamlopt` in the upstream distribution: it rebuilds the
Expand Down
2 changes: 1 addition & 1 deletion ocaml/HACKING.jst.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,4 @@ Then build the compiler &mdash; the following command will build the compiler us
We can now benchmark our compiler against `typecore.ml`. The following `_bootinstall` is built using the opam switch and has FP enabled.

$ cd _build/main
$ perf stat -r 5 ../_bootinstall/bin/ocamlc.opt -strict-sequence -principal -w +a-4-9-40-41-42-44-45-48-66-70 -warn-error A -bin-annot -safe-string -strict-formats -w -67 -g -bin-annot -I .ocamlcommon.objs/byte -I ../install/runtime_stdlib/lib/ocaml_runtime_stdlib/ -intf-suffix .ml -no-alias-deps -o .ocamlcommon.objs/byte/typecore.cmo -c -impl typecore.ml
$ perf stat -r 5 ../_bootinstall/bin/ocamlc.opt -strict-sequence -principal -w +a-4-9-40-41-42-44-45-48-66-70 -warn-error A -bin-annot -safe-string -strict-formats -w -67 -g -bin-annot -I .ocamlcommon.objs/byte -I ../runtime_stdlib_install/lib/ocaml_runtime_stdlib/ -intf-suffix .ml -no-alias-deps -o .ocamlcommon.objs/byte/typecore.cmo -c -impl typecore.ml
15 changes: 10 additions & 5 deletions ocaml/Makefile.common-jst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ define dune_main_context
(profile $(main_build_profile))
(paths
(PATH ("$(CURDIR)/_build/_bootinstall/bin" :standard))
(OCAMLLIB ("$(CURDIR)/_build/install/runtime_stdlib/lib/ocaml_runtime_stdlib")))
(OCAMLLIB ("$(CURDIR)/_build/runtime_stdlib_install/lib/ocaml_runtime_stdlib")))
(env (_
(flags (:standard -warn-error +A))
(env-vars ("OCAMLPARAM" "$(BUILD_OCAMLPARAM)"))))))
Expand All @@ -70,8 +70,12 @@ boot-runtest: boot-compiler

runtime-stdlib: boot-compiler
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_runstd) --only-package=ocaml_runtime_stdlib @install
# dune does not believe the compiler can make .cmxs unless the following file exists
@touch _build/install/runtime_stdlib/lib/ocaml_runtime_stdlib/dynlink.cmxa
rm -rf _build/runtime_stdlib_install
# Dune 3.11+ clears `_build/install` before building, move the runtime stdlib
# to a separate directory.
$(cpl) -R _build/install/runtime_stdlib _build/runtime_stdlib_install
# Dune does not believe the compiler can make .cmxs unless the following file exists.
@touch _build/runtime_stdlib_install/lib/ocaml_runtime_stdlib/dynlink.cmxa

compiler: runtime-stdlib
RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_main) --only-package=ocaml @install \
Expand Down Expand Up @@ -164,9 +168,10 @@ cpl=$(if $(filter linux,$(SYSTEM)),cp -l,cp -L)
_install: compiler
rm -rf _install
mkdir -p _install/{bin,lib/ocaml}
$(cpl) _build/install/{runtime_stdlib,main}/bin/* _install/bin/
$(cpl) _build/runtime_stdlib_install/bin/* _install/bin/
$(cpl) _build/install/main/bin/* _install/bin/
( cd _install/bin; for i in *.opt; do ln -s $$i $${i%.opt}; done )
$(cpl) -R _build/install/runtime_stdlib/lib/ocaml_runtime_stdlib/* _install/lib/ocaml/
$(cpl) -R _build/runtime_stdlib_install/lib/ocaml_runtime_stdlib/* _install/lib/ocaml/
rm -f _install/lib/ocaml/{META,dune-package,Makefile.config,dynlink.cmxa}
$(cpl) -R _build/install/main/lib/ocaml/* _install/lib/ocaml/
if [ "x$(legacy_layout)" == "xyes" ] ; \
Expand Down
Loading