Skip to content

Commit d68e0e2

Browse files
authored
Provide a way to build the bytecode compiler using Dune (ocaml#2093)
1 parent 8e80195 commit d68e0e2

File tree

25 files changed

+953
-131
lines changed

25 files changed

+953
-131
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
_ocamltest
3535
_ocamltestd
3636
*.odoc
37+
.merlin
38+
_build
3739

3840
# local to root directory
3941

.merlin

Lines changed: 0 additions & 59 deletions
This file was deleted.

Makefile

Lines changed: 5 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -298,68 +298,8 @@ endif
298298

299299
# The configuration file
300300

301-
# SUBST generates the sed substitution for the variable *named* in $1
302-
# SUBST_QUOTE does the same, adding double-quotes around non-empty strings
303-
# (see FLEXDLL_DIR which must empty if FLEXDLL_DIR is empty but an OCaml
304-
# string otherwise)
305-
SUBST_ESCAPE=$(subst ",\\",$(subst \,\\,$(if $2,$2,$($1))))
306-
SUBST=-e 's|%%$1%%|$(call SUBST_ESCAPE,$1,$2)|'
307-
SUBST_QUOTE2=-e 's|%%$1%%|$(if $2,"$2")|'
308-
SUBST_QUOTE=$(call SUBST_QUOTE2,$1,$(call SUBST_ESCAPE,$1,$2))
309-
FLEXLINK_LDFLAGS=$(if $(OC_LDFLAGS), -link "$(OC_LDFLAGS)")
310-
utils/config.ml: utils/config.mlp Makefile.config Makefile
311-
sed $(call SUBST,AFL_INSTRUMENT) \
312-
$(call SUBST,ARCH) \
313-
$(call SUBST,ARCMD) \
314-
$(call SUBST,ASM) \
315-
$(call SUBST,ASM_CFI_SUPPORTED) \
316-
$(call SUBST,BYTECCLIBS) \
317-
$(call SUBST,CC) \
318-
$(call SUBST,CCOMPTYPE) \
319-
$(call SUBST,CC_PROFILE) \
320-
$(call SUBST,OUTPUTOBJ) \
321-
$(call SUBST,EXT_ASM) \
322-
$(call SUBST,EXT_DLL) \
323-
$(call SUBST,EXE) \
324-
$(call SUBST,EXT_LIB) \
325-
$(call SUBST,EXT_OBJ) \
326-
$(call SUBST,FLAMBDA) \
327-
$(call SUBST,WITH_FLAMBDA_INVARIANTS) \
328-
$(call SUBST,FLEXLINK_FLAGS) \
329-
$(call SUBST_QUOTE,FLEXDLL_DIR) \
330-
$(call SUBST,HOST) \
331-
$(call SUBST,LIBDIR) \
332-
$(call SUBST,LIBUNWIND_AVAILABLE) \
333-
$(call SUBST,LIBUNWIND_LINK_FLAGS) \
334-
$(call SUBST,MKDLL) \
335-
$(call SUBST,MKEXE) \
336-
$(call SUBST,FLEXLINK_LDFLAGS) \
337-
$(call SUBST,MKMAINDLL) \
338-
$(call SUBST,MODEL) \
339-
$(call SUBST,NATIVECCLIBS) \
340-
$(call SUBST,OCAMLC_CFLAGS) \
341-
$(call SUBST,OCAMLC_CPPFLAGS) \
342-
$(call SUBST,OCAMLOPT_CFLAGS) \
343-
$(call SUBST,OCAMLOPT_CPPFLAGS) \
344-
$(call SUBST,PACKLD) \
345-
$(call SUBST,PROFILING) \
346-
$(call SUBST,PROFINFO_WIDTH) \
347-
$(call SUBST,RANLIBCMD) \
348-
$(call SUBST,FORCE_SAFE_STRING) \
349-
$(call SUBST,DEFAULT_SAFE_STRING) \
350-
$(call SUBST,WINDOWS_UNICODE) \
351-
$(call SUBST,SUPPORTS_SHARED_LIBRARIES) \
352-
$(call SUBST,SYSTEM) \
353-
$(call SUBST,SYSTHREAD_SUPPORT) \
354-
$(call SUBST,TARGET) \
355-
$(call SUBST,WITH_FRAME_POINTERS) \
356-
$(call SUBST,WITH_PROFINFO) \
357-
$(call SUBST,WITH_SPACETIME) \
358-
$(call SUBST,ENABLE_CALL_COUNTS) \
359-
$(call SUBST,FLAT_FLOAT_ARRAY) \
360-
$(call SUBST,CC_HAS_DEBUG_PREFIX_MAP) \
361-
$(call SUBST,AS_HAS_DEBUG_PREFIX_MAP) \
362-
$< > $@
301+
utils/config.ml:
302+
$(MAKE) -C utils config.ml
363303

364304
ifeq "$(UNIX_OR_WIN32)" "unix"
365305
.PHONY: reconfigure
@@ -908,14 +848,9 @@ $(COMMON:.cmo=.cmx) $(BYTECOMP:.cmo=.cmx) $(OPTCOMP:.cmo=.cmx): ocamlopt
908848
runtime/primitives:
909849
$(MAKE) -C runtime primitives
910850

911-
bytecomp/runtimedef.ml: runtime/primitives runtime/caml/fail.h
912-
(echo 'let builtin_exceptions = [|'; \
913-
cat runtime/caml/fail.h | tr -d '\r' | \
914-
sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$$| \1;|p'; \
915-
echo '|]'; \
916-
echo 'let builtin_primitives = [|'; \
917-
sed -e 's/.*/ "&";/' runtime/primitives; \
918-
echo '|]') > $@
851+
bytecomp/runtimedef.ml: bytecomp/generate_runtimedef.sh runtime/caml/fail.h \
852+
runtime/primitives
853+
$^ > $@
919854

920855
partialclean::
921856
rm -f bytecomp/runtimedef.ml

asmcomp/dune

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
;**************************************************************************
2+
;* *
3+
;* OCaml *
4+
;* *
5+
;* Thomas Refis, Jane Street Europe *
6+
;* *
7+
;* Copyright 2018 Jane Street Group LLC *
8+
;* *
9+
;* All rights reserved. This file is distributed under the terms of *
10+
;* the GNU Lesser General Public License version 2.1, with the *
11+
;* special exception on linking described in the file LICENSE. *
12+
;* *
13+
;**************************************************************************
14+
15+
(rule
16+
(targets arch.ml CSE.ml proc.ml reload.ml scheduling.ml selection.ml)
17+
(mode fallback)
18+
(deps (:conf ../Makefile.config)
19+
(glob_files amd64/*.ml)
20+
(glob_files arm/*.ml)
21+
(glob_files arm64/*.ml)
22+
(glob_files i386/*.ml)
23+
(glob_files power/*.ml)
24+
(glob_files s390x/*.ml))
25+
(action (bash "cp `grep 'ARCH=' %{conf} | cut -d'=' -f2`/*.ml .")))
26+
27+
(rule
28+
(targets emit.ml)
29+
(mode fallback)
30+
(deps (:conf ../Makefile.config)
31+
amd64/emit.mlp
32+
arm/emit.mlp
33+
arm64/emit.mlp
34+
i386/emit.mlp
35+
power/emit.mlp
36+
s390x/emit.mlp)
37+
(action
38+
(progn
39+
(with-stdout-to contains-input-name
40+
(bash "echo `grep 'ARCH=' %{conf} | cut -d'=' -f2`/emit.mlp"))
41+
(with-stdout-to %{targets}
42+
(progn
43+
(bash "echo \\# 1 \\\"`cat contains-input-name`\\\"")
44+
(bash "%{dep:../tools/cvt_emit.exe} < `cat contains-input-name`"))))))

bytecomp/dune

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
;**************************************************************************
2+
;* *
3+
;* OCaml *
4+
;* *
5+
;* Thomas Refis, Jane Street Europe *
6+
;* *
7+
;* Copyright 2018 Jane Street Group LLC *
8+
;* *
9+
;* All rights reserved. This file is distributed under the terms of *
10+
;* the GNU Lesser General Public License version 2.1, with the *
11+
;* special exception on linking described in the file LICENSE. *
12+
;* *
13+
;**************************************************************************
14+
15+
(rule
16+
(targets opcodes.ml)
17+
(mode fallback)
18+
(deps (:instr (file ../runtime/caml/instruct.h)))
19+
(action
20+
(bash "%{dep:../tools/make_opcodes.exe} -opcodes < %{instr} > %{targets}")))
21+
22+
(rule
23+
(targets runtimedef.ml)
24+
(mode fallback)
25+
(deps (:fail (file ../runtime/caml/fail.h))
26+
(:prim (file ../runtime/primitives)))
27+
(action (with-stdout-to %{targets}
28+
(run ./generate_runtimedef.sh %{fail} %{prim}))))

bytecomp/generate_runtimedef.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
#**************************************************************************
4+
#* *
5+
#* OCaml *
6+
#* *
7+
#* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
8+
#* *
9+
#* Copyright 1999 Institut National de Recherche en Informatique et *
10+
#* en Automatique. *
11+
#* *
12+
#* All rights reserved. This file is distributed under the terms of *
13+
#* the GNU Lesser General Public License version 2.1, with the *
14+
#* special exception on linking described in the file LICENSE. *
15+
#* *
16+
#**************************************************************************
17+
18+
echo 'let builtin_exceptions = [|'
19+
cat "$1" | tr -d '\r' | \
20+
sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$| \1;|p'
21+
echo '|]'
22+
23+
echo 'let builtin_primitives = [|'
24+
sed -e 's/.*/ "&";/' "$2"
25+
echo '|]'

debugger/dune

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
;**************************************************************************
2+
;* *
3+
;* OCaml *
4+
;* *
5+
;* Thomas Refis, Jane Street Europe *
6+
;* *
7+
;* Copyright 2018 Jane Street Group LLC *
8+
;* *
9+
;* All rights reserved. This file is distributed under the terms of *
10+
;* the GNU Lesser General Public License version 2.1, with the *
11+
;* special exception on linking described in the file LICENSE. *
12+
;* *
13+
;**************************************************************************
14+
15+
(ocamllex lexer)
16+
(ocamlyacc parser)
17+
18+
(executable
19+
(name main)
20+
(modes byte)
21+
(flags (:standard -w -9))
22+
(modules_without_implementation parser_aux)
23+
(libraries ocamlcommon ocamltoplevel runtime stdlib unix))
24+
25+
(rule (copy main.exe ocamldebug.byte))

driver/dune

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(rule
2+
(targets compdynlink.ml)
3+
(deps (:ml (file ../otherlibs/dynlink/dynlink.ml)))
4+
(action
5+
(with-stdout-to %{targets}
6+
(bash "grep -v 'REMOVE_ME for ../../debugger/dynlink.ml' %{ml}"))))

0 commit comments

Comments
 (0)