Skip to content

Commit

Permalink
flambda-backend: Speed up builds (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan authored May 23, 2022
1 parent a527cab commit 8362f9e
Show file tree
Hide file tree
Showing 18 changed files with 89 additions and 160 deletions.
6 changes: 2 additions & 4 deletions debugger/dune
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
(executable
(name main)
(modes byte)
(flags (:standard -principal -w -9
-nostdlib -cclib "-I ../runtime" -cclib "-L ../runtime" -cclib -lcamlrun))
(link_deps (file ../stdlib/camlheader) (file ../runtime/libcamlrun.a))
(flags (:standard -principal -w -9))
(modules_without_implementation parser_aux)
(libraries ocamlcommon ocamltoplevel stdlib unix dynlink_internal))
(libraries ocamlcommon ocamltoplevel unix dynlink_internal))

(install
(files (main.bc as ocamldebug))
Expand Down
25 changes: 8 additions & 17 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
(name ocamlcommon)
(wrapped false)
(flags (
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-warn-error A -bin-annot -safe-string -strict-formats
-w -67
; remove -w -67 by adding the camlinternalMenhirLib hack like the Makefile
))
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
(library_flags -linkall)
(libraries stdlib)
(modules_without_implementation
annot asttypes cmo_format outcometree parsetree debug_event)
(modules
Expand Down Expand Up @@ -88,11 +87,11 @@
(name ocamlbytecomp)
(wrapped false)
(flags (
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-warn-error A -bin-annot -safe-string -strict-formats
))
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
(libraries stdlib ocamlcommon)
(libraries ocamlcommon)
(modules
;; bytecomp/
bytegen bytelibrarian bytelink bytepackager emitcode printinstr
Expand All @@ -105,28 +104,21 @@
(executable
(name main)
(modes byte)
; We need to use ocamlmklib in "custom" mode for the runtime library
; in bytecode otherwise the compiler will end up looking for dllruntime.so
; which doesn't exist. Since we don't seem to be able to do this, we
; currently don't add "runtime_byte" as a "libraries" dependency, but
; instead explicitly provide "-cclib" flags to pull it in.
(flags (
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-warn-error A -bin-annot -safe-string -strict-formats
-cclib "-I runtime" -cclib "-L runtime" -cclib -lcamlrun
))
(link_deps (file stdlib/camlheader) (file runtime/libcamlrun.a))
(libraries ocamlbytecomp ocamlcommon stdlib)
(libraries ocamlbytecomp ocamlcommon)
(modules main))

(executable
(name main_native)
(modes native)
(flags (
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-warn-error A -bin-annot -safe-string -strict-formats
))
(libraries ocamlbytecomp ocamlcommon runtime_native stdlib)
(libraries ocamlbytecomp ocamlcommon)
(modules main_native))

(data_only_dirs yacc)
Expand All @@ -137,7 +129,7 @@
(action
(no-infer
(progn
(chdir yacc (run make -j8))
(chdir yacc (run make -sj8 OCAMLYACC_INCLUDE_PATH=%{ocaml_where}))
(copy yacc/ocamlyacc ocamlyacc)))))

(install
Expand All @@ -160,7 +152,6 @@
(install
(files
(main.bc as ocamlc.byte)
(main_native.exe as ocamlc)
(main_native.exe as ocamlc.opt)
)
(section bin)
Expand Down
19 changes: 5 additions & 14 deletions lex/dune
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
(name ocamllex_lib)
(wrapped false)
(modes byte native)
(flags (:standard -principal -nostdlib))
(flags (:standard -principal))
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
(libraries stdlib)
(modules
common
compact
Expand All @@ -33,10 +32,8 @@
(executable
(name main)
(modes byte)
(flags (:standard -principal -nostdlib
-cclib "-I runtime" -cclib "-L runtime" -cclib -lcamlrun))
(link_deps (file ../stdlib/camlheader) (file ../runtime/libcamlrun.a))
(libraries ocamllex_lib stdlib)
(flags (:standard -principal))
(libraries ocamllex_lib)
(modules main))

(rule
Expand All @@ -46,16 +43,10 @@
(executable
(name main_native)
(modes native)
(flags (:standard -principal -nostdlib))
(libraries ocamllex_lib stdlib runtime_native)
(flags (:standard -principal))
(libraries ocamllex_lib)
(modules main_native))

; For some reason if we install files as "ocamllex" then dune claims there
; is a circular dependency, which there should not be, since ocamllex from
; the "ocamllex" stanza above should be the one on the PATH and not from the
; build directory. For the moment we do the copy to "ocamllex" in the
; Flambda backend Makefile.

(install
(files
(main.bc as ocamllex.byte)
Expand Down
12 changes: 5 additions & 7 deletions ocamldoc/dune
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
(name odoc_lib)
(modes byte native)
(wrapped false)
(flags (:standard -nostdlib -w -9-32))
(flags (:standard -w -9-32))
(modules
odoc_analyse
odoc_args
Expand Down Expand Up @@ -72,15 +72,15 @@
odoc_types
odoc_value
)
(libraries dynlink_internal ocamlcommon stdlib str unix))
(libraries dynlink_internal ocamlcommon str unix))

(executable
(name odoc_byte)
(modes byte)
; See note in the toplevel dune file about this.
(flags (:standard -nostdlib -cclib "-L ../runtime" -cclib -lcamlrun))
(flags (:standard -cclib "-L ../runtime" -cclib -lcamlrun))
(modules odoc_byte)
(libraries odoc_lib stdlib))
(libraries odoc_lib))

(rule
(targets odoc_byte.ml)
Expand All @@ -89,9 +89,8 @@
(executable
(name odoc_native)
(modes native)
(flags -nostdlib)
(modules odoc_native)
(libraries odoc_lib runtime_native dynlink_internal stdlib))
(libraries odoc_lib dynlink_internal))

(rule
(targets odoc_native.ml)
Expand All @@ -100,7 +99,6 @@
(install
(files
; (odoc_byte.bc as ocamldoc.byte)
(odoc_native.exe as ocamldoc)
(odoc_native.exe as ocamldoc.opt))
(section bin)
(package ocaml))
Expand Down
13 changes: 6 additions & 7 deletions ocamltest/dune
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
Makefile
./ocamltest_config.ml.in
./getocamloptdefaultflags)
(action (run make %{targets} COMPUTE_DEPS=false)))
(action (run make -s %{targets} COMPUTE_DEPS=false)))

;; FIXME: handle UNIX_OR_WIN32 or something similar
(library
Expand All @@ -40,17 +40,16 @@
(wrapped false)
; -linkall so we don't fail to include e.g. ocaml_modifiers.ml, which only
; has top-level side effects.
(flags (:standard -nostdlib -linkall))
(libraries ocamlcommon stdlib
(flags (:standard -linkall))
(libraries ocamlcommon
(select ocamltest_unix.ml from
(unix -> ocamltest_unix.real.ml)
(-> ocamltest_unix.dummy.ml)))
(modules (:standard \ options main))
(foreign_stubs (language c) (names run_unix run_stubs)
(flags ((-DCAML_INTERNALS)
(:include %{project_root}/oc_cflags.sexp)
(:include %{project_root}/oc_cppflags.sexp)))
(include_dirs %{project_root}/ocaml/runtime)))
(:include %{project_root}/oc_cppflags.sexp)))))

(rule
(targets empty.ml)
Expand All @@ -60,9 +59,9 @@
(executable
(name main)
(modes byte)
(flags (:standard -principal -nostdlib
(flags (:standard -principal
-cclib "-I%{project_root}/ocaml/runtime"))
(modules options main)
(libraries ocamltest_core_and_plugin runtime_byte stdlib))
(libraries ocamltest_core_and_plugin))

(rule (copy main.exe ocamltest.byte))
5 changes: 2 additions & 3 deletions otherlibs/bigarray/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
(wrapped false)
(modes byte native)
(flags (
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-warn-error A -bin-annot -safe-string -strict-formats
))
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
(library_flags (:standard -linkall))
(libraries stdlib))
(library_flags (:standard -linkall)))

(install
(files
Expand Down
15 changes: 5 additions & 10 deletions otherlibs/dynlink/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
(wrapped true)
(modes byte native)
(flags (
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48
-warn-error A -bin-annot -safe-string -strict-formats
))
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
Expand Down Expand Up @@ -73,8 +73,7 @@
outcometree
cmo_format
cmxs_format
debug_event)
(libraries stdlib))
debug_event))

;(install
; (files
Expand Down Expand Up @@ -198,7 +197,7 @@
(wrapped false)
(modes byte native)
(modules dynlink dynlink_common dynlink_types dynlink_platform_intf)
(libraries dynlink_compilerlibs stdlib))
(libraries dynlink_compilerlibs))

; The non-installed version of dynlink.cmi is needed to build other parts
; of the tree.
Expand All @@ -212,7 +211,6 @@
(deps dynlink_internal.cma)
(action
(run %{ocamlc}
-nostdlib
-g -a
%{read:natdynlinkops1}
%{read:natdynlinkops2}
Expand Down Expand Up @@ -274,7 +272,6 @@
(deps dynlink_internal.cmxa)
(action
(run %{ocamlopt}
-nostdlib
-g -a
%{read:natdynlinkops1}
%{read:natdynlinkops2}
Expand Down Expand Up @@ -334,12 +331,10 @@
(executable
(name extract_crc)
(modes byte)
(flags (:standard -principal -nostdlib
-cclib "-I ../../runtime" -cclib "-L ../../runtime" -cclib -lcamlrun))
(link_deps (file ../../stdlib/camlheader) (file ../../runtime/libcamlrun.a))
(flags (:standard -principal))
(libraries
dynlink_internal
stdlib)
)
(modules extract_crc))

(install
Expand Down
6 changes: 2 additions & 4 deletions otherlibs/str/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,15 @@
(wrapped false)
(modes byte native)
(flags (
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
-warn-error A -bin-annot -safe-string -strict-formats
))
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
(library_flags (:standard -linkall))
(libraries stdlib)
(foreign_stubs (language c) (names strstubs)
(flags ((:include %{project_root}/oc_cflags.sexp)
(:include %{project_root}/sharedlib_cflags.sexp)
(:include %{project_root}/oc_cppflags.sexp)))
(include_dirs %{project_root}/ocaml/runtime)))
(:include %{project_root}/oc_cppflags.sexp)))))

(install
(files
Expand Down
8 changes: 3 additions & 5 deletions otherlibs/systhreads/dune
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
thread)
(flags -w +33..39 -warn-error A -g -bin-annot -safe-string)
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
(libraries stdlib unix)
(libraries unix)
(library_flags -linkall)
(c_library_flags -lpthread)
(foreign_stubs
Expand All @@ -33,17 +33,15 @@
(mode byte)
(flags ((:include %{project_root}/oc_cflags.sexp)
(:include %{project_root}/sharedlib_cflags.sexp)
(:include %{project_root}/oc_cppflags.sexp)))
(include_dirs %{project_root}/ocaml/runtime))
(:include %{project_root}/oc_cppflags.sexp))))
(foreign_stubs
(language c)
(names st_stubs_native)
(mode native)
(flags ((-DNATIVE_CODE)
(:include %{project_root}/oc_cflags.sexp)
(:include %{project_root}/sharedlib_cflags.sexp)
(:include %{project_root}/oc_cppflags.sexp)))
(include_dirs %{project_root}/ocaml/runtime)))
(:include %{project_root}/oc_cppflags.sexp)))))

(rule
(targets st_stubs_byte.c)
Expand Down
4 changes: 1 addition & 3 deletions otherlibs/unix/dune
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
(wrapped false)
(modes byte native)
(flags (
-nostdlib -absname -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot
-absname -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot
-g -safe-string -strict-sequence -strict-formats
))
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
(library_flags (:standard -linkall))
(libraries stdlib)
(foreign_stubs (language c) (names
accept access addrofstr alarm bind channels chdir chmod chown chroot close
fsync closedir connect cst2constr cstringv dup dup2 envir errmsg execv execve
Expand All @@ -38,7 +37,6 @@
(flags ((:include %{project_root}/oc_cflags.sexp)
(:include %{project_root}/sharedlib_cflags.sexp)
(:include %{project_root}/oc_cppflags.sexp)))
(include_dirs %{project_root}/ocaml/runtime)
))

(install
Expand Down
8 changes: 6 additions & 2 deletions runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,12 @@ ld.conf: $(ROOTDIR)/Makefile.config

# To speed up builds, we avoid changing "primitives" when files
# containing primitives change but the primitives table does not
primitives: $(shell ./gen_primitives.sh > primitives.new; \
cmp -s primitives primitives.new || echo primitives.new)
gen_prim_cmd = \
if [ -x gen_primitives.sh ]; then \
./gen_primitives.sh > primitives.new; \
cmp -s primitives primitives.new || echo primitives.new; \
else echo gen-primitives-unavailable; fi
primitives: $(shell $(gen_prim_cmd))
cp $^ $@

prims.c : primitives
Expand Down
Loading

0 comments on commit 8362f9e

Please sign in to comment.