Skip to content

Commit 8362f9e

Browse files
authored
flambda-backend: Speed up builds (#585)
1 parent a527cab commit 8362f9e

File tree

18 files changed

+89
-160
lines changed

18 files changed

+89
-160
lines changed

debugger/dune

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,9 @@
1818
(executable
1919
(name main)
2020
(modes byte)
21-
(flags (:standard -principal -w -9
22-
-nostdlib -cclib "-I ../runtime" -cclib "-L ../runtime" -cclib -lcamlrun))
23-
(link_deps (file ../stdlib/camlheader) (file ../runtime/libcamlrun.a))
21+
(flags (:standard -principal -w -9))
2422
(modules_without_implementation parser_aux)
25-
(libraries ocamlcommon ocamltoplevel stdlib unix dynlink_internal))
23+
(libraries ocamlcommon ocamltoplevel unix dynlink_internal))
2624

2725
(install
2826
(files (main.bc as ocamldebug))

dune

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@
3434
(name ocamlcommon)
3535
(wrapped false)
3636
(flags (
37-
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
37+
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
3838
-warn-error A -bin-annot -safe-string -strict-formats
3939
-w -67
4040
; remove -w -67 by adding the camlinternalMenhirLib hack like the Makefile
4141
))
4242
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
4343
(library_flags -linkall)
44-
(libraries stdlib)
4544
(modules_without_implementation
4645
annot asttypes cmo_format outcometree parsetree debug_event)
4746
(modules
@@ -88,11 +87,11 @@
8887
(name ocamlbytecomp)
8988
(wrapped false)
9089
(flags (
91-
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
90+
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
9291
-warn-error A -bin-annot -safe-string -strict-formats
9392
))
9493
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
95-
(libraries stdlib ocamlcommon)
94+
(libraries ocamlcommon)
9695
(modules
9796
;; bytecomp/
9897
bytegen bytelibrarian bytelink bytepackager emitcode printinstr
@@ -105,28 +104,21 @@
105104
(executable
106105
(name main)
107106
(modes byte)
108-
; We need to use ocamlmklib in "custom" mode for the runtime library
109-
; in bytecode otherwise the compiler will end up looking for dllruntime.so
110-
; which doesn't exist. Since we don't seem to be able to do this, we
111-
; currently don't add "runtime_byte" as a "libraries" dependency, but
112-
; instead explicitly provide "-cclib" flags to pull it in.
113107
(flags (
114-
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
108+
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
115109
-warn-error A -bin-annot -safe-string -strict-formats
116-
-cclib "-I runtime" -cclib "-L runtime" -cclib -lcamlrun
117110
))
118-
(link_deps (file stdlib/camlheader) (file runtime/libcamlrun.a))
119-
(libraries ocamlbytecomp ocamlcommon stdlib)
111+
(libraries ocamlbytecomp ocamlcommon)
120112
(modules main))
121113

122114
(executable
123115
(name main_native)
124116
(modes native)
125117
(flags (
126-
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
118+
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
127119
-warn-error A -bin-annot -safe-string -strict-formats
128120
))
129-
(libraries ocamlbytecomp ocamlcommon runtime_native stdlib)
121+
(libraries ocamlbytecomp ocamlcommon)
130122
(modules main_native))
131123

132124
(data_only_dirs yacc)
@@ -137,7 +129,7 @@
137129
(action
138130
(no-infer
139131
(progn
140-
(chdir yacc (run make -j8))
132+
(chdir yacc (run make -sj8 OCAMLYACC_INCLUDE_PATH=%{ocaml_where}))
141133
(copy yacc/ocamlyacc ocamlyacc)))))
142134

143135
(install
@@ -160,7 +152,6 @@
160152
(install
161153
(files
162154
(main.bc as ocamlc.byte)
163-
(main_native.exe as ocamlc)
164155
(main_native.exe as ocamlc.opt)
165156
)
166157
(section bin)

lex/dune

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
(name ocamllex_lib)
1616
(wrapped false)
1717
(modes byte native)
18-
(flags (:standard -principal -nostdlib))
18+
(flags (:standard -principal))
1919
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
20-
(libraries stdlib)
2120
(modules
2221
common
2322
compact
@@ -33,10 +32,8 @@
3332
(executable
3433
(name main)
3534
(modes byte)
36-
(flags (:standard -principal -nostdlib
37-
-cclib "-I runtime" -cclib "-L runtime" -cclib -lcamlrun))
38-
(link_deps (file ../stdlib/camlheader) (file ../runtime/libcamlrun.a))
39-
(libraries ocamllex_lib stdlib)
35+
(flags (:standard -principal))
36+
(libraries ocamllex_lib)
4037
(modules main))
4138

4239
(rule
@@ -46,16 +43,10 @@
4643
(executable
4744
(name main_native)
4845
(modes native)
49-
(flags (:standard -principal -nostdlib))
50-
(libraries ocamllex_lib stdlib runtime_native)
46+
(flags (:standard -principal))
47+
(libraries ocamllex_lib)
5148
(modules main_native))
5249

53-
; For some reason if we install files as "ocamllex" then dune claims there
54-
; is a circular dependency, which there should not be, since ocamllex from
55-
; the "ocamllex" stanza above should be the one on the PATH and not from the
56-
; build directory. For the moment we do the copy to "ocamllex" in the
57-
; Flambda backend Makefile.
58-
5950
(install
6051
(files
6152
(main.bc as ocamllex.byte)

ocamldoc/dune

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
(name odoc_lib)
2323
(modes byte native)
2424
(wrapped false)
25-
(flags (:standard -nostdlib -w -9-32))
25+
(flags (:standard -w -9-32))
2626
(modules
2727
odoc_analyse
2828
odoc_args
@@ -72,15 +72,15 @@
7272
odoc_types
7373
odoc_value
7474
)
75-
(libraries dynlink_internal ocamlcommon stdlib str unix))
75+
(libraries dynlink_internal ocamlcommon str unix))
7676

7777
(executable
7878
(name odoc_byte)
7979
(modes byte)
8080
; See note in the toplevel dune file about this.
81-
(flags (:standard -nostdlib -cclib "-L ../runtime" -cclib -lcamlrun))
81+
(flags (:standard -cclib "-L ../runtime" -cclib -lcamlrun))
8282
(modules odoc_byte)
83-
(libraries odoc_lib stdlib))
83+
(libraries odoc_lib))
8484

8585
(rule
8686
(targets odoc_byte.ml)
@@ -89,9 +89,8 @@
8989
(executable
9090
(name odoc_native)
9191
(modes native)
92-
(flags -nostdlib)
9392
(modules odoc_native)
94-
(libraries odoc_lib runtime_native dynlink_internal stdlib))
93+
(libraries odoc_lib dynlink_internal))
9594

9695
(rule
9796
(targets odoc_native.ml)
@@ -100,7 +99,6 @@
10099
(install
101100
(files
102101
; (odoc_byte.bc as ocamldoc.byte)
103-
(odoc_native.exe as ocamldoc)
104102
(odoc_native.exe as ocamldoc.opt))
105103
(section bin)
106104
(package ocaml))

ocamltest/dune

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
Makefile
3232
./ocamltest_config.ml.in
3333
./getocamloptdefaultflags)
34-
(action (run make %{targets} COMPUTE_DEPS=false)))
34+
(action (run make -s %{targets} COMPUTE_DEPS=false)))
3535

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

5554
(rule
5655
(targets empty.ml)
@@ -60,9 +59,9 @@
6059
(executable
6160
(name main)
6261
(modes byte)
63-
(flags (:standard -principal -nostdlib
62+
(flags (:standard -principal
6463
-cclib "-I%{project_root}/ocaml/runtime"))
6564
(modules options main)
66-
(libraries ocamltest_core_and_plugin runtime_byte stdlib))
65+
(libraries ocamltest_core_and_plugin))
6766

6867
(rule (copy main.exe ocamltest.byte))

otherlibs/bigarray/dune

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
(wrapped false)
1818
(modes byte native)
1919
(flags (
20-
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
20+
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
2121
-warn-error A -bin-annot -safe-string -strict-formats
2222
))
2323
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
24-
(library_flags (:standard -linkall))
25-
(libraries stdlib))
24+
(library_flags (:standard -linkall)))
2625

2726
(install
2827
(files

otherlibs/dynlink/dune

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
(wrapped true)
1818
(modes byte native)
1919
(flags (
20-
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48
20+
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48
2121
-warn-error A -bin-annot -safe-string -strict-formats
2222
))
2323
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
@@ -73,8 +73,7 @@
7373
outcometree
7474
cmo_format
7575
cmxs_format
76-
debug_event)
77-
(libraries stdlib))
76+
debug_event))
7877

7978
;(install
8079
; (files
@@ -198,7 +197,7 @@
198197
(wrapped false)
199198
(modes byte native)
200199
(modules dynlink dynlink_common dynlink_types dynlink_platform_intf)
201-
(libraries dynlink_compilerlibs stdlib))
200+
(libraries dynlink_compilerlibs))
202201

203202
; The non-installed version of dynlink.cmi is needed to build other parts
204203
; of the tree.
@@ -212,7 +211,6 @@
212211
(deps dynlink_internal.cma)
213212
(action
214213
(run %{ocamlc}
215-
-nostdlib
216214
-g -a
217215
%{read:natdynlinkops1}
218216
%{read:natdynlinkops2}
@@ -274,7 +272,6 @@
274272
(deps dynlink_internal.cmxa)
275273
(action
276274
(run %{ocamlopt}
277-
-nostdlib
278275
-g -a
279276
%{read:natdynlinkops1}
280277
%{read:natdynlinkops2}
@@ -334,12 +331,10 @@
334331
(executable
335332
(name extract_crc)
336333
(modes byte)
337-
(flags (:standard -principal -nostdlib
338-
-cclib "-I ../../runtime" -cclib "-L ../../runtime" -cclib -lcamlrun))
339-
(link_deps (file ../../stdlib/camlheader) (file ../../runtime/libcamlrun.a))
334+
(flags (:standard -principal))
340335
(libraries
341336
dynlink_internal
342-
stdlib)
337+
)
343338
(modules extract_crc))
344339

345340
(install

otherlibs/str/dune

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,15 @@
1717
(wrapped false)
1818
(modes byte native)
1919
(flags (
20-
-nostdlib -strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
20+
-strict-sequence -principal -absname -w +a-4-9-40-41-42-44-45-48-66
2121
-warn-error A -bin-annot -safe-string -strict-formats
2222
))
2323
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
2424
(library_flags (:standard -linkall))
25-
(libraries stdlib)
2625
(foreign_stubs (language c) (names strstubs)
2726
(flags ((:include %{project_root}/oc_cflags.sexp)
2827
(:include %{project_root}/sharedlib_cflags.sexp)
29-
(:include %{project_root}/oc_cppflags.sexp)))
30-
(include_dirs %{project_root}/ocaml/runtime)))
28+
(:include %{project_root}/oc_cppflags.sexp)))))
3129

3230
(install
3331
(files

otherlibs/systhreads/dune

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
thread)
2525
(flags -w +33..39 -warn-error A -g -bin-annot -safe-string)
2626
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
27-
(libraries stdlib unix)
27+
(libraries unix)
2828
(library_flags -linkall)
2929
(c_library_flags -lpthread)
3030
(foreign_stubs
@@ -33,17 +33,15 @@
3333
(mode byte)
3434
(flags ((:include %{project_root}/oc_cflags.sexp)
3535
(:include %{project_root}/sharedlib_cflags.sexp)
36-
(:include %{project_root}/oc_cppflags.sexp)))
37-
(include_dirs %{project_root}/ocaml/runtime))
36+
(:include %{project_root}/oc_cppflags.sexp))))
3837
(foreign_stubs
3938
(language c)
4039
(names st_stubs_native)
4140
(mode native)
4241
(flags ((-DNATIVE_CODE)
4342
(:include %{project_root}/oc_cflags.sexp)
4443
(:include %{project_root}/sharedlib_cflags.sexp)
45-
(:include %{project_root}/oc_cppflags.sexp)))
46-
(include_dirs %{project_root}/ocaml/runtime)))
44+
(:include %{project_root}/oc_cppflags.sexp)))))
4745

4846
(rule
4947
(targets st_stubs_byte.c)

otherlibs/unix/dune

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717
(wrapped false)
1818
(modes byte native)
1919
(flags (
20-
-nostdlib -absname -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot
20+
-absname -w +a-4-9-41-42-44-45-48 -warn-error A -bin-annot
2121
-g -safe-string -strict-sequence -strict-formats
2222
))
2323
(ocamlopt_flags (:include %{project_root}/ocamlopt_flags.sexp))
2424
(library_flags (:standard -linkall))
25-
(libraries stdlib)
2625
(foreign_stubs (language c) (names
2726
accept access addrofstr alarm bind channels chdir chmod chown chroot close
2827
fsync closedir connect cst2constr cstringv dup dup2 envir errmsg execv execve
@@ -38,7 +37,6 @@
3837
(flags ((:include %{project_root}/oc_cflags.sexp)
3938
(:include %{project_root}/sharedlib_cflags.sexp)
4039
(:include %{project_root}/oc_cppflags.sexp)))
41-
(include_dirs %{project_root}/ocaml/runtime)
4240
))
4341

4442
(install

runtime/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,12 @@ ld.conf: $(ROOTDIR)/Makefile.config
236236

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

243247
prims.c : primitives

0 commit comments

Comments
 (0)