summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Refis <refis.thomas@gmail.com>2018-10-10 16:16:00 +0100
committerGitHub <noreply@github.com>2018-10-10 16:16:00 +0100
commitd68e0e207765350eb42fed37444d643669f98cee (patch)
tree5b5b289543b450cdbadacc15518876c60f87f86e
parent8e801959e84e73219190dedad0b5b62b1f4f50a3 (diff)
downloadocaml-d68e0e207765350eb42fed37444d643669f98cee.tar.gz
Provide a way to build the bytecode compiler using Dune (#2093)
-rw-r--r--.gitignore2
-rw-r--r--.merlin59
-rw-r--r--Makefile75
-rw-r--r--asmcomp/dune44
-rw-r--r--bytecomp/dune28
-rwxr-xr-xbytecomp/generate_runtimedef.sh25
-rw-r--r--debugger/dune25
-rw-r--r--driver/dune6
-rw-r--r--dune175
-rw-r--r--dune-project2
-rw-r--r--ocamldoc/dune25
-rw-r--r--ocamltest/dune52
-rw-r--r--otherlibs/dynlink/dune26
-rw-r--r--otherlibs/str/dune20
-rw-r--r--otherlibs/unix/dune33
-rw-r--r--parsing/dune48
-rw-r--r--runtime/caml/dune29
-rw-r--r--runtime/dune58
-rwxr-xr-xruntime/gen_primitives.sh28
-rw-r--r--stdlib/dune91
-rw-r--r--stdlib/expand_module_aliases.awk6
-rw-r--r--tools/dune25
-rw-r--r--toplevel/dune98
-rw-r--r--utils/Makefile83
-rw-r--r--utils/dune21
25 files changed, 953 insertions, 131 deletions
diff --git a/.gitignore b/.gitignore
index a6c56dfea4..48b479bf19 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,6 +34,8 @@
_ocamltest
_ocamltestd
*.odoc
+.merlin
+_build
# local to root directory
diff --git a/.merlin b/.merlin
deleted file mode 100644
index 7355c7ac0d..0000000000
--- a/.merlin
+++ /dev/null
@@ -1,59 +0,0 @@
-S ./asmcomp
-B ./asmcomp
-
-S ./asmcomp/debug
-B ./asmcomp/debug
-
-S ./middle_end
-B ./middle_end
-
-S ./middle_end/base_types
-B ./middle_end/base_types
-
-S ./bytecomp
-B ./bytecomp
-
-S ./driver
-B ./driver
-
-S ./lex
-B ./lex
-
-S ./otherlibs/bigarray
-B ./otherlibs/bigarray
-
-S ./otherlibs/dynlink
-B ./otherlibs/dynlink
-
-S ./otherlibs/graph
-B ./otherlibs/graph
-
-S ./otherlibs/str
-B ./otherlibs/str
-
-S ./otherlibs/systhreads
-B ./otherlibs/systhreads
-
-S ./otherlibs/threads
-B ./otherlibs/threads
-
-S ./otherlibs/unix
-B ./otherlibs/unix
-
-S ./parsing
-B ./parsing
-
-STDLIB ./stdlib
-FLG -open Stdlib -nopervasives
-
-S ./toplevel
-B ./toplevel
-
-S ./typing
-B ./typing
-
-S ./utils
-B ./utils
-
-S ./ocamltest
-B ./ocamltest
diff --git a/Makefile b/Makefile
index d6986cdb39..58a21ba025 100644
--- a/Makefile
+++ b/Makefile
@@ -298,68 +298,8 @@ endif
# The configuration file
-# SUBST generates the sed substitution for the variable *named* in $1
-# SUBST_QUOTE does the same, adding double-quotes around non-empty strings
-# (see FLEXDLL_DIR which must empty if FLEXDLL_DIR is empty but an OCaml
-# string otherwise)
-SUBST_ESCAPE=$(subst ",\\",$(subst \,\\,$(if $2,$2,$($1))))
-SUBST=-e 's|%%$1%%|$(call SUBST_ESCAPE,$1,$2)|'
-SUBST_QUOTE2=-e 's|%%$1%%|$(if $2,"$2")|'
-SUBST_QUOTE=$(call SUBST_QUOTE2,$1,$(call SUBST_ESCAPE,$1,$2))
-FLEXLINK_LDFLAGS=$(if $(OC_LDFLAGS), -link "$(OC_LDFLAGS)")
-utils/config.ml: utils/config.mlp Makefile.config Makefile
- sed $(call SUBST,AFL_INSTRUMENT) \
- $(call SUBST,ARCH) \
- $(call SUBST,ARCMD) \
- $(call SUBST,ASM) \
- $(call SUBST,ASM_CFI_SUPPORTED) \
- $(call SUBST,BYTECCLIBS) \
- $(call SUBST,CC) \
- $(call SUBST,CCOMPTYPE) \
- $(call SUBST,CC_PROFILE) \
- $(call SUBST,OUTPUTOBJ) \
- $(call SUBST,EXT_ASM) \
- $(call SUBST,EXT_DLL) \
- $(call SUBST,EXE) \
- $(call SUBST,EXT_LIB) \
- $(call SUBST,EXT_OBJ) \
- $(call SUBST,FLAMBDA) \
- $(call SUBST,WITH_FLAMBDA_INVARIANTS) \
- $(call SUBST,FLEXLINK_FLAGS) \
- $(call SUBST_QUOTE,FLEXDLL_DIR) \
- $(call SUBST,HOST) \
- $(call SUBST,LIBDIR) \
- $(call SUBST,LIBUNWIND_AVAILABLE) \
- $(call SUBST,LIBUNWIND_LINK_FLAGS) \
- $(call SUBST,MKDLL) \
- $(call SUBST,MKEXE) \
- $(call SUBST,FLEXLINK_LDFLAGS) \
- $(call SUBST,MKMAINDLL) \
- $(call SUBST,MODEL) \
- $(call SUBST,NATIVECCLIBS) \
- $(call SUBST,OCAMLC_CFLAGS) \
- $(call SUBST,OCAMLC_CPPFLAGS) \
- $(call SUBST,OCAMLOPT_CFLAGS) \
- $(call SUBST,OCAMLOPT_CPPFLAGS) \
- $(call SUBST,PACKLD) \
- $(call SUBST,PROFILING) \
- $(call SUBST,PROFINFO_WIDTH) \
- $(call SUBST,RANLIBCMD) \
- $(call SUBST,FORCE_SAFE_STRING) \
- $(call SUBST,DEFAULT_SAFE_STRING) \
- $(call SUBST,WINDOWS_UNICODE) \
- $(call SUBST,SUPPORTS_SHARED_LIBRARIES) \
- $(call SUBST,SYSTEM) \
- $(call SUBST,SYSTHREAD_SUPPORT) \
- $(call SUBST,TARGET) \
- $(call SUBST,WITH_FRAME_POINTERS) \
- $(call SUBST,WITH_PROFINFO) \
- $(call SUBST,WITH_SPACETIME) \
- $(call SUBST,ENABLE_CALL_COUNTS) \
- $(call SUBST,FLAT_FLOAT_ARRAY) \
- $(call SUBST,CC_HAS_DEBUG_PREFIX_MAP) \
- $(call SUBST,AS_HAS_DEBUG_PREFIX_MAP) \
- $< > $@
+utils/config.ml:
+ $(MAKE) -C utils config.ml
ifeq "$(UNIX_OR_WIN32)" "unix"
.PHONY: reconfigure
@@ -908,14 +848,9 @@ $(COMMON:.cmo=.cmx) $(BYTECOMP:.cmo=.cmx) $(OPTCOMP:.cmo=.cmx): ocamlopt
runtime/primitives:
$(MAKE) -C runtime primitives
-bytecomp/runtimedef.ml: runtime/primitives runtime/caml/fail.h
- (echo 'let builtin_exceptions = [|'; \
- cat runtime/caml/fail.h | tr -d '\r' | \
- sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$$| \1;|p'; \
- echo '|]'; \
- echo 'let builtin_primitives = [|'; \
- sed -e 's/.*/ "&";/' runtime/primitives; \
- echo '|]') > $@
+bytecomp/runtimedef.ml: bytecomp/generate_runtimedef.sh runtime/caml/fail.h \
+ runtime/primitives
+ $^ > $@
partialclean::
rm -f bytecomp/runtimedef.ml
diff --git a/asmcomp/dune b/asmcomp/dune
new file mode 100644
index 0000000000..aea36976f0
--- /dev/null
+++ b/asmcomp/dune
@@ -0,0 +1,44 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(rule
+ (targets arch.ml CSE.ml proc.ml reload.ml scheduling.ml selection.ml)
+ (mode fallback)
+ (deps (:conf ../Makefile.config)
+ (glob_files amd64/*.ml)
+ (glob_files arm/*.ml)
+ (glob_files arm64/*.ml)
+ (glob_files i386/*.ml)
+ (glob_files power/*.ml)
+ (glob_files s390x/*.ml))
+ (action (bash "cp `grep 'ARCH=' %{conf} | cut -d'=' -f2`/*.ml .")))
+
+(rule
+ (targets emit.ml)
+ (mode fallback)
+ (deps (:conf ../Makefile.config)
+ amd64/emit.mlp
+ arm/emit.mlp
+ arm64/emit.mlp
+ i386/emit.mlp
+ power/emit.mlp
+ s390x/emit.mlp)
+ (action
+ (progn
+ (with-stdout-to contains-input-name
+ (bash "echo `grep 'ARCH=' %{conf} | cut -d'=' -f2`/emit.mlp"))
+ (with-stdout-to %{targets}
+ (progn
+ (bash "echo \\# 1 \\\"`cat contains-input-name`\\\"")
+ (bash "%{dep:../tools/cvt_emit.exe} < `cat contains-input-name`"))))))
diff --git a/bytecomp/dune b/bytecomp/dune
new file mode 100644
index 0000000000..b2409cf4f1
--- /dev/null
+++ b/bytecomp/dune
@@ -0,0 +1,28 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(rule
+ (targets opcodes.ml)
+ (mode fallback)
+ (deps (:instr (file ../runtime/caml/instruct.h)))
+ (action
+ (bash "%{dep:../tools/make_opcodes.exe} -opcodes < %{instr} > %{targets}")))
+
+(rule
+ (targets runtimedef.ml)
+ (mode fallback)
+ (deps (:fail (file ../runtime/caml/fail.h))
+ (:prim (file ../runtime/primitives)))
+ (action (with-stdout-to %{targets}
+ (run ./generate_runtimedef.sh %{fail} %{prim}))))
diff --git a/bytecomp/generate_runtimedef.sh b/bytecomp/generate_runtimedef.sh
new file mode 100755
index 0000000000..e4e58da064
--- /dev/null
+++ b/bytecomp/generate_runtimedef.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+#**************************************************************************
+#* *
+#* OCaml *
+#* *
+#* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
+#* *
+#* Copyright 1999 Institut National de Recherche en Informatique et *
+#* en Automatique. *
+#* *
+#* All rights reserved. This file is distributed under the terms of *
+#* the GNU Lesser General Public License version 2.1, with the *
+#* special exception on linking described in the file LICENSE. *
+#* *
+#**************************************************************************
+
+echo 'let builtin_exceptions = [|'
+cat "$1" | tr -d '\r' | \
+ sed -n -e 's|.*/\* \("[A-Za-z_]*"\) \*/$| \1;|p'
+echo '|]'
+
+echo 'let builtin_primitives = [|'
+sed -e 's/.*/ "&";/' "$2"
+echo '|]'
diff --git a/debugger/dune b/debugger/dune
new file mode 100644
index 0000000000..9756094370
--- /dev/null
+++ b/debugger/dune
@@ -0,0 +1,25 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(ocamllex lexer)
+(ocamlyacc parser)
+
+(executable
+ (name main)
+ (modes byte)
+ (flags (:standard -w -9))
+ (modules_without_implementation parser_aux)
+ (libraries ocamlcommon ocamltoplevel runtime stdlib unix))
+
+(rule (copy main.exe ocamldebug.byte))
diff --git a/driver/dune b/driver/dune
new file mode 100644
index 0000000000..9fecb0bf1a
--- /dev/null
+++ b/driver/dune
@@ -0,0 +1,6 @@
+(rule
+ (targets compdynlink.ml)
+ (deps (:ml (file ../otherlibs/dynlink/dynlink.ml)))
+ (action
+ (with-stdout-to %{targets}
+ (bash "grep -v 'REMOVE_ME for ../../debugger/dynlink.ml' %{ml}"))))
diff --git a/dune b/dune
new file mode 100644
index 0000000000..57843d9efb
--- /dev/null
+++ b/dune
@@ -0,0 +1,175 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(env
+ (dev (flags (:standard -w +a-4-9-41-42-44-45-48)))
+ (release (flags (:standard -w +a-4-9-41-42-44-45-48))))
+
+;; Too annoying to get to work. Use (copy_files# ...) instead
+; (include_subdirs unqualified)
+; (ignored_subdirs (lex yacc testsuite ocamldoc ocamltest toplevel otherlibs))
+
+(copy_files# utils/*.ml{,i})
+(copy_files# parsing/*.ml{,i})
+(copy_files# typing/*.ml{,i})
+(copy_files# bytecomp/*.ml{,i})
+(copy_files# driver/*.ml{,i})
+(copy_files# asmcomp/*.ml{,i})
+(copy_files# asmcomp/debug/*.ml{,i})
+(copy_files# middle_end/*.ml{,i})
+(copy_files# middle_end/base_types/*.ml{,i})
+
+(library
+ (name ocamlcommon)
+ (wrapped false)
+ (flags (:standard -principal -nostdlib))
+ (libraries stdlib)
+ (modules_without_implementation
+ annot asttypes cmo_format outcometree parsetree)
+ (modules
+ ;; UTILS
+ config build_path_prefix_map misc identifiable numbers arg_helper clflags
+ profile terminfo ccomp warnings consistbl strongly_connected_components
+ targetint
+
+ ;; PARSING
+ location longident docstrings syntaxerr ast_helper camlinternalMenhirLib
+ parser lexer parse printast pprintast ast_mapper ast_iterator attr_helper
+ builtin_attributes ast_invariants depend
+ ; manual update: mli only files
+ asttypes parsetree
+
+ ;; TYPING
+ ident path primitive types btype oprint subst predef datarepr cmi_format env
+ typedtree printtyped ctype printtyp includeclass mtype envaux includecore
+ typedtreeIter typedtreeMap tast_mapper cmt_format untypeast includemod
+ typetexp printpat parmatch stypes typedecl typeopt rec_check typecore
+ typeclass typemod
+ ; manual update: mli only files
+ annot outcometree
+
+ ;; COMP
+ lambda printlambda semantics_of_primitives switch matching translobj
+ translattribute translprim translcore translclass translmod simplif
+ runtimedef meta opcodes bytesections dll symtable pparse main_args compenv
+ compmisc compdynlink compplugin makedepend compile_common
+ ; manual update: mli only files
+ cmo_format
+ ; manual update: this is required.
+ instruct
+ ))
+
+(library
+ (name ocamlbytecomp)
+ (wrapped false)
+ (flags (:standard -principal -nostdlib))
+ (libraries stdlib ocamlcommon)
+ (modules
+ bytegen printinstr emitcode bytelink bytelibrarian bytepackager errors
+ compile))
+
+(library
+ (name ocamloptcomp)
+ (wrapped false)
+ (flags (:standard -principal -nostdlib))
+ (libraries stdlib ocamlcommon)
+ (modules_without_implementation
+ cmx_format x86_ast backend_intf inlining_decision_intf
+ simplify_boxed_integer_ops_intf)
+ (modules
+ ;; ASMCOMP
+ arch backend_var cmm printcmm reg reg_with_debug_info reg_availability_set
+ mach proc clambda printclambda export_info export_info_for_pack compilenv
+ closure traverse_for_exported_symbols build_export_info closure_offsets
+ flambda_to_clambda import_approx un_anf afl_instrument strmatch cmmgen
+ interval printmach selectgen spacetime_profiling selection comballoc CSEgen
+ CSE liveness spill split interf coloring linscan reloadgen reload deadcode
+ printlinear linearize available_regs schedgen scheduling
+ branch_relaxation_intf branch_relaxation emitaux emit asmgen asmlink
+ asmlibrarian asmpackager opterrors optcompile
+ ; manual update: mli only files
+ cmx_format
+
+ ; arch specific files: we always include them even though depending on the
+ ; target architecture they might not be used.
+ x86_ast
+ x86_proc
+ x86_dsl
+ x86_gas
+ x86_masm
+
+ ;; MIDDLE_END
+ int_replace_polymorphic_compare debuginfo tag linkage_name compilation_unit
+ internal_variable_names variable mutable_variable id_types set_of_closures_id
+ set_of_closures_origin closure_element closure_id closure_origin
+ var_within_closure static_exception export_id symbol pass_wrapper
+ allocated_const parameter projection flambda flambda_iterators flambda_utils
+ inlining_cost effect_analysis freshening simple_value_approx lift_code
+ closure_conversion_aux closure_conversion initialize_symbol_to_let_symbol
+ lift_let_to_initialize_symbol find_recursive_functions invariant_params
+ inconstant_idents alias_analysis lift_constants share_constants
+ simplify_common remove_unused_arguments remove_unused_closure_vars
+ remove_unused_program_constructs simplify_boxed_integer_ops
+ simplify_primitives inlining_stats_types inlining_stats
+ inline_and_simplify_aux remove_free_vars_equal_to_args extract_projections
+ augment_specialised_args unbox_free_vars_of_closures unbox_specialised_args
+ unbox_closures inlining_transforms inlining_decision inline_and_simplify
+ ref_to_variables flambda_invariants middle_end
+ ; manual update: mli only files
+ backend_intf inlining_decision_intf simplify_boxed_integer_ops_intf
+ )
+)
+
+;;;;;;;;;;;;;;
+;;; ocamlc ;;;
+;;;;;;;;;;;;;;
+
+(executable
+ (name main)
+ (modes byte)
+ (flags (:standard -principal -nostdlib))
+ (libraries ocamlbytecomp ocamlcommon runtime stdlib)
+ (modules main))
+
+(rule
+ (copy main.exe ocamlc.byte))
+
+;;;;;;;;;;;;;;;;
+;;; ocamlopt ;;;
+;;;;;;;;;;;;;;;;
+
+(executable
+ (name optmain)
+ (modes byte)
+ (flags (:standard -principal -nostdlib))
+ (libraries ocamloptcomp ocamlcommon runtime stdlib)
+ (modules optmain))
+
+(rule
+ (copy optmain.exe ocamlopt.byte))
+
+;;;;;;;;;;;;;;;
+;;; aliases ;;;
+;;;;;;;;;;;;;;;
+
+(alias
+ (name world)
+ (deps ocamlc.byte
+ ocamlopt.byte
+ debugger/ocamldebug.byte
+ ocamldoc/ocamldoc.byte
+ ocamltest/ocamltest.byte
+ toplevel/ocaml.byte
+ toplevel/expunge.exe
+ ))
diff --git a/dune-project b/dune-project
new file mode 100644
index 0000000000..ce151941ee
--- /dev/null
+++ b/dune-project
@@ -0,0 +1,2 @@
+(lang dune 1.3)
+(using experimental_building_ocaml_compiler_with_dune 0.1)
diff --git a/ocamldoc/dune b/ocamldoc/dune
new file mode 100644
index 0000000000..be7a042f96
--- /dev/null
+++ b/ocamldoc/dune
@@ -0,0 +1,25 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(ocamllex odoc_lexer odoc_ocamlhtml odoc_see_lexer odoc_text_lexer)
+(ocamlyacc odoc_parser odoc_text_parser)
+
+(executable
+ (name odoc)
+ (modes byte)
+ (flags (:standard -nostdlib -w -9-32))
+ (libraries dynlink ocamlcommon stdlib runtime str unix))
+
+(rule
+ (copy odoc.exe ocamldoc.byte))
diff --git a/ocamltest/dune b/ocamltest/dune
new file mode 100644
index 0000000000..9d3361a298
--- /dev/null
+++ b/ocamltest/dune
@@ -0,0 +1,52 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(ocamllex
+ (modules tsl_lexer)
+ (mode fallback))
+
+(ocamlyacc
+ (modules tsl_parser)
+ (mode fallback))
+
+(rule
+ (targets ocamltest_config.ml)
+ (deps ../Makefile.config ../Makefile.common Makefile
+ ./ocamltest_config.ml.in ./getocamloptdefaultflags)
+ (action (run make %{targets})))
+
+;; FIXME: handle UNIX_OR_WIN32 or something similar
+(library
+ (name ocamltest_core_and_plugin)
+ (modes byte)
+ (wrapped false)
+ (flags (:standard -nostdlib))
+ (libraries ocamlcommon stdlib)
+ (modules (:standard \ options main))
+ (c_flags (-DCAML_INTERNALS -I%{project_root}/runtime)) ; fixme
+ (c_names run_unix run_stubs ocamltest_stdlib_stubs))
+
+(rule
+ (targets empty.ml)
+ (deps (source_tree %{project_root}/runtime/caml))
+ (action (write-file %{targets} "(* hack *)")))
+
+(executable
+ (name main)
+ (modes byte)
+ (flags (:standard -nostdlib))
+ (modules options main)
+ (libraries ocamltest_core_and_plugin runtime stdlib))
+
+(rule (copy main.exe ocamltest.byte))
diff --git a/otherlibs/dynlink/dune b/otherlibs/dynlink/dune
new file mode 100644
index 0000000000..ebc140bbe1
--- /dev/null
+++ b/otherlibs/dynlink/dune
@@ -0,0 +1,26 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(library
+ (name dynlink)
+ (wrapped false)
+ (modules dynlink dynlinkaux)
+ ; the -33 is specific to the hackery done with dune.
+ (flags (:standard -nostdlib -w -33))
+ (libraries ocamlcommon stdlib))
+
+(rule
+ (targets dynlinkaux.ml)
+ (action (write-file %{targets}
+ "(* empty because we are linking with ocamlcommon *)")))
diff --git a/otherlibs/str/dune b/otherlibs/str/dune
new file mode 100644
index 0000000000..0c96b6385a
--- /dev/null
+++ b/otherlibs/str/dune
@@ -0,0 +1,20 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(library
+ (name str)
+ (modes byte)
+ (flags (:standard -nostdlib))
+ (libraries stdlib)
+ (c_names strstubs))
diff --git a/otherlibs/unix/dune b/otherlibs/unix/dune
new file mode 100644
index 0000000000..eadac1a27e
--- /dev/null
+++ b/otherlibs/unix/dune
@@ -0,0 +1,33 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(library
+ (name unix)
+ (wrapped false)
+ (modes byte)
+ (flags (:standard -nostdlib -nolabels))
+ (c_flags (-I %{project_root}/runtime))
+ (libraries stdlib)
+ (c_names
+ accept access addrofstr alarm bind channels chdir chmod chown chroot close
+ fsync closedir connect cst2constr cstringv dup dup2 envir errmsg execv execve
+ execvp exit fchmod fchown fcntl fork ftruncate getaddrinfo getcwd getegid
+ geteuid getgid getgr getgroups gethost gethostname getlogin getnameinfo
+ getpeername getpid getppid getproto getpw gettimeofday getserv getsockname
+ getuid gmtime initgroups isatty itimer kill link listen lockf lseek mkdir
+ mkfifo mmap mmap_ba nice open opendir pipe putenv read readdir readlink
+ rename rewinddir rmdir select sendrecv setgid setgroups setsid setuid
+ shutdown signals sleep socket socketaddr socketpair sockopt stat strofaddr
+ symlink termios time times truncate umask unixsupport unlink utimes wait
+ write))
diff --git a/parsing/dune b/parsing/dune
new file mode 100644
index 0000000000..4198c6b1ba
--- /dev/null
+++ b/parsing/dune
@@ -0,0 +1,48 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+;; We're just reusing the stuff from boot/ here.
+;; One could add a dune file in boot/menhir/ with the appropriate rules if we
+;; want to regenerate the parser while building with dune, but it doesn't seem
+;; essential right now.
+
+(rule
+ (targets camlinternalMenhirLib.ml)
+ (mode fallback)
+ (action (copy# ../boot/menhir/menhirLib.ml %{targets})))
+
+(rule
+ (targets camlinternalMenhirLib.mli)
+ (mode fallback)
+ (action (copy# ../boot/menhir/menhirLib.mli %{targets})))
+
+(rule
+ (targets parser.ml)
+ (mode fallback)
+ (deps (:dep ../boot/menhir/parser.ml))
+ (action
+ (with-stdout-to %{targets}
+ (bash "cat %{dep} | sed 's/MenhirLib/CamlinternalMenhirLib/g'"))))
+
+(rule
+ (targets parser.mli)
+ (mode fallback)
+ (deps (:dep ../boot/menhir/parser.mli))
+ (action
+ (with-stdout-to %{targets}
+ (bash "cat %{dep} | sed 's/MenhirLib/CamlinternalMenhirLib/g'"))))
+
+(ocamllex
+ (modules lexer)
+ (mode fallback))
diff --git a/runtime/caml/dune b/runtime/caml/dune
new file mode 100644
index 0000000000..5b6c7cb20d
--- /dev/null
+++ b/runtime/caml/dune
@@ -0,0 +1,29 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(rule
+ (targets jumptbl.h)
+ (mode fallback)
+ (deps (:h instruct.h))
+ (action
+ (with-stdout-to %{targets}
+ (bash "cat %{h} | tr -d '\\r' | \
+ sed -n -e '/^ /s/ \\([A-Z]\\)/ \\&\\&lbl_\\1/gp' -e '/^}/q'"))))
+
+(rule
+ (targets version.h)
+ (mode fallback)
+ (action
+ (with-stdout-to %{targets}
+ (run %{dep:../../tools/make-version-header.sh} %{dep:../../VERSION}))))
diff --git a/runtime/dune b/runtime/dune
new file mode 100644
index 0000000000..8e8a116ba3
--- /dev/null
+++ b/runtime/dune
@@ -0,0 +1,58 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(rule
+ (targets primitives)
+ (mode fallback)
+ (deps alloc.c array.c compare.c extern.c floats.c gc_ctrl.c hash.c intern.c
+ interp.c ints.c io.c lexing.c md5.c meta.c obj.c parsing.c signals.c
+ str.c sys.c callback.c weak.c finalise.c stacks.c dynlink.c
+ backtrace_byt.c backtrace.c spacetime_byt.c afl.c bigarray.c)
+ (action (with-stdout-to %{targets} (run %{dep:gen_primitives.sh}))))
+
+(rule
+ (targets libcamlrun.a)
+ (mode fallback)
+ (deps ../Makefile.config ../Makefile.common Makefile
+ (glob_files caml/*.h)
+ interp.c misc.c stacks.c fix_code.c startup_aux.c startup_byt.c
+ freelist.c major_gc.c minor_gc.c memory.c alloc.c roots_byt.c
+ globroots.c fail_byt.c signals.c signals_byt.c printexc.c
+ backtrace_byt.c backtrace.c compare.c ints.c floats.c str.c array.c
+ io.c extern.c intern.c hash.c sys.c meta.c parsing.c gc_ctrl.c md5.c
+ obj.c lexing.c callback.c debugger.c weak.c compact.c finalise.c
+ custom.c dynlink.c spacetime_byt.c afl.c unix.c win32.c bigarray.c
+ main.c)
+ (action
+ (progn
+ (bash "touch .depend") ; hack.
+ (run make %{targets})
+ (bash "rm .depend"))))
+
+;; HACK
+(library
+ (name runtime)
+ (modes byte)
+ (wrapped false)
+ (modules runtime)
+ (flags (-nostdlib -nopervasives))
+ (self_build_stubs_archive (runtime)))
+
+(rule
+ (targets libruntime_stubs.a)
+ (action (copy libcamlrun.a %{targets})))
+
+(rule
+ (targets runtime.ml)
+ (action (write-file %{targets} "let linkme = ()")))
diff --git a/runtime/gen_primitives.sh b/runtime/gen_primitives.sh
new file mode 100755
index 0000000000..046aa8399d
--- /dev/null
+++ b/runtime/gen_primitives.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+#**************************************************************************
+#* *
+#* OCaml *
+#* *
+#* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
+#* *
+#* Copyright 1999 Institut National de Recherche en Informatique et *
+#* en Automatique. *
+#* *
+#* All rights reserved. This file is distributed under the terms of *
+#* the GNU Lesser General Public License version 2.1, with the *
+#* special exception on linking described in the file LICENSE. *
+#* *
+#**************************************************************************
+
+# duplicated from $(ROOTDIR)/runtime/Makefile
+
+(
+ for prim in \
+ alloc array compare extern floats gc_ctrl hash intern interp ints io \
+ lexing md5 meta obj parsing signals str sys callback weak finalise \
+ stacks dynlink backtrace_byt backtrace spacetime_byt afl bigarray
+ do
+ sed -n -e "s/CAMLprim value \([a-z0-9_][a-z0-9_]*\).*/\1/p" "$prim.c"
+ done
+) | LC_ALL=C sort | uniq
diff --git a/stdlib/dune b/stdlib/dune
new file mode 100644
index 0000000000..eff4b70975
--- /dev/null
+++ b/stdlib/dune
@@ -0,0 +1,91 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(library
+ (name stdlib)
+ (stdlib
+ (exit_module std_exit)
+ (internal_modules Camlinternal*)
+ (modules_before_stdlib
+ camlinternalFormatBasics))
+ (flags (:standard -w -9))
+ ;; We're listing the modules here to avoid building the Labels ones.
+ (modules
+ spacetime
+ arg
+ array
+ bigarray
+ buffer
+ bytes
+ callback
+ camlinternalFormat
+ camlinternalFormatBasics
+ camlinternalLazy
+ camlinternalMod
+ camlinternalOO
+ char
+ complex
+ digest
+ ephemeron
+ filename
+ float
+ format
+ gc
+ genlex
+ hashtbl
+ int32
+ int64
+ lazy
+ lexing
+ list
+ map
+ marshal
+ nativeint
+ obj
+ oo
+ option
+ parsing
+ pervasives
+ printexc
+ printf
+ queue
+ random
+ result
+ scanf
+ seq
+ set
+ stack
+ stdlib
+ stream
+ string
+ sys
+ uchar
+ weak
+ ;; booh
+ std_exit
+ )
+ (preprocess
+ (per_module
+ ((action
+ (run awk -v dune_wrapped=true
+ -f %{dep:expand_module_aliases.awk} %{input-file}))
+ stdlib))))
+
+(rule
+ (targets sys.ml)
+ (deps (:version ../VERSION) (:p sys.mlp))
+ (action
+ (with-stdout-to %{targets}
+ (bash
+ "sed -e \"s|%%VERSION%%|`sed -e 1q %{version} | tr -d '\r'`|\" %{p}"))))
diff --git a/stdlib/expand_module_aliases.awk b/stdlib/expand_module_aliases.awk
index 98d34d30ec..7f1e49ba85 100644
--- a/stdlib/expand_module_aliases.awk
+++ b/stdlib/expand_module_aliases.awk
@@ -23,8 +23,10 @@ NR == 1 { printf ("# 1 \"%s\"\n", FILENAME) }
state=2;
else if ($1 == "module")
{ if (ocamldoc!="true") printf("\n(** @canonical %s *)", $2);
- printf("\nmodule %s = Stdlib__%s%s\n", $2,
- tolower(substr($4,1,1)), substr($4,2));
+ first_letter=substr($4,1,1);
+ if (dune_wrapped!="true")
+ first_letter=tolower(first_letter);
+ printf("\nmodule %s = Stdlib__%s%s\n", $2, first_letter, substr($4,2));
}
else
print
diff --git a/tools/dune b/tools/dune
new file mode 100644
index 0000000000..91a71fdc43
--- /dev/null
+++ b/tools/dune
@@ -0,0 +1,25 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(executables
+ (names make_opcodes cvt_emit)
+ (modules make_opcodes cvt_emit))
+
+(ocamllex
+ (modules make_opcodes)
+ (mode fallback))
+
+(ocamllex
+ (modules cvt_emit)
+ (mode fallback))
diff --git a/toplevel/dune b/toplevel/dune
new file mode 100644
index 0000000000..476274b9ad
--- /dev/null
+++ b/toplevel/dune
@@ -0,0 +1,98 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(library
+ (name ocamltoplevel)
+ (wrapped false)
+ (flags (:standard -principal -nostdlib))
+ (libraries stdlib ocamlcommon ocamlbytecomp)
+ (modules genprintval toploop trace topdirs topmain))
+
+(executable
+ (name topstart)
+ (modes byte)
+ (flags (:standard -principal -nostdlib))
+ (libraries ocamlbytecomp ocamlcommon ocamltoplevel runtime stdlib)
+ (modules topstart))
+
+(executable
+ (name expunge)
+ (modes byte)
+ (flags (:standard -principal -nostdlib))
+ (libraries ocamlbytecomp ocamlcommon runtime stdlib)
+ (modules expunge))
+
+(rule
+ (targets ocaml.byte)
+ (action (run %{ocaml_where}/expunge %{dep:topstart.exe} %{targets}
+ ; FIXME: inlined $(STDLIB_MODULES) ... minus Labels ones ...
+ stdlib__Spacetime
+ stdlib__Arg
+ stdlib__Array
+ ; stdlib__ArrayLabels
+ stdlib__Bigarray
+ stdlib__Buffer
+ stdlib__Bytes
+ ; stdlib__BytesLabels
+ stdlib__Callback
+ camlinternalFormat
+ camlinternalFormatBasics
+ camlinternalLazy
+ camlinternalMod
+ camlinternalOO
+ stdlib__Char
+ stdlib__Complex
+ stdlib__Digest
+ stdlib__Ephemeron
+ stdlib__Filename
+ stdlib__Float
+ stdlib__Format
+ stdlib__Gc
+ stdlib__Genlex
+ stdlib__Hashtbl
+ stdlib__Int32
+ stdlib__Int64
+ stdlib__Lazy
+ stdlib__Lexing
+ stdlib__List
+ ; stdlib__ListLabels
+ stdlib__Map
+ stdlib__Marshal
+ ; stdlib__MoreLabels
+ stdlib__Nativeint
+ stdlib__Obj
+ stdlib__Oo
+ stdlib__Option
+ stdlib__Parsing
+ stdlib__Pervasives
+ stdlib__Printexc
+ stdlib__Printf
+ stdlib__Queue
+ stdlib__Random
+ stdlib__Result
+ stdlib__Scanf
+ stdlib__Seq
+ stdlib__Set
+ stdlib__Stack
+ ; stdlib__StdLabels
+ stdlib
+ stdlib__Stream
+ stdlib__String
+ ; stdlib__StringLabels
+ stdlib__Sys
+ stdlib__Uchar
+ stdlib__Weak
+ ; the rest
+ outcometree topdirs toploop
+ )))
diff --git a/utils/Makefile b/utils/Makefile
new file mode 100644
index 0000000000..8a05ef722c
--- /dev/null
+++ b/utils/Makefile
@@ -0,0 +1,83 @@
+#**************************************************************************
+#* *
+#* OCaml *
+#* *
+#* Xavier Leroy, projet Cristal, INRIA Rocquencourt *
+#* *
+#* Copyright 1999 Institut National de Recherche en Informatique et *
+#* en Automatique. *
+#* *
+#* All rights reserved. This file is distributed under the terms of *
+#* the GNU Lesser General Public License version 2.1, with the *
+#* special exception on linking described in the file LICENSE. *
+#* *
+#**************************************************************************
+
+# The Makefile for generating the configuration file
+
+ROOTDIR = ..
+
+include $(ROOTDIR)/Makefile.config
+
+# SUBST generates the sed substitution for the variable *named* in $1
+# SUBST_QUOTE does the same, adding double-quotes around non-empty strings
+# (see FLEXDLL_DIR which must empty if FLEXDLL_DIR is empty but an OCaml
+# string otherwise)
+SUBST_ESCAPE=$(subst ",\\",$(subst \,\\,$(if $2,$2,$($1))))
+SUBST=-e 's|%%$1%%|$(call SUBST_ESCAPE,$1,$2)|'
+SUBST_QUOTE2=-e 's|%%$1%%|$(if $2,"$2")|'
+SUBST_QUOTE=$(call SUBST_QUOTE2,$1,$(call SUBST_ESCAPE,$1,$2))
+FLEXLINK_LDFLAGS=$(if $(OC_LDFLAGS), -link "$(OC_LDFLAGS)")
+config.ml: config.mlp $(ROOTDIR)/Makefile.config
+ sed $(call SUBST,AFL_INSTRUMENT) \
+ $(call SUBST,ARCH) \
+ $(call SUBST,ARCMD) \
+ $(call SUBST,ASM) \
+ $(call SUBST,ASM_CFI_SUPPORTED) \
+ $(call SUBST,BYTECCLIBS) \
+ $(call SUBST,CC) \
+ $(call SUBST,CCOMPTYPE) \
+ $(call SUBST,CC_PROFILE) \
+ $(call SUBST,OUTPUTOBJ) \
+ $(call SUBST,EXT_ASM) \
+ $(call SUBST,EXT_DLL) \
+ $(call SUBST,EXE) \
+ $(call SUBST,EXT_LIB) \
+ $(call SUBST,EXT_OBJ) \
+ $(call SUBST,FLAMBDA) \
+ $(call SUBST,WITH_FLAMBDA_INVARIANTS) \
+ $(call SUBST,FLEXLINK_FLAGS) \
+ $(call SUBST_QUOTE,FLEXDLL_DIR) \
+ $(call SUBST,HOST) \
+ $(call SUBST,LIBDIR) \
+ $(call SUBST,LIBUNWIND_AVAILABLE) \
+ $(call SUBST,LIBUNWIND_LINK_FLAGS) \
+ $(call SUBST,MKDLL) \
+ $(call SUBST,MKEXE) \
+ $(call SUBST,FLEXLINK_LDFLAGS) \
+ $(call SUBST,MKMAINDLL) \
+ $(call SUBST,MODEL) \
+ $(call SUBST,NATIVECCLIBS) \
+ $(call SUBST,OCAMLC_CFLAGS) \
+ $(call SUBST,OCAMLC_CPPFLAGS) \
+ $(call SUBST,OCAMLOPT_CFLAGS) \
+ $(call SUBST,OCAMLOPT_CPPFLAGS) \
+ $(call SUBST,PACKLD) \
+ $(call SUBST,PROFILING) \
+ $(call SUBST,PROFINFO_WIDTH) \
+ $(call SUBST,RANLIBCMD) \
+ $(call SUBST,FORCE_SAFE_STRING) \
+ $(call SUBST,DEFAULT_SAFE_STRING) \
+ $(call SUBST,WINDOWS_UNICODE) \
+ $(call SUBST,SUPPORTS_SHARED_LIBRARIES) \
+ $(call SUBST,SYSTEM) \
+ $(call SUBST,SYSTHREAD_SUPPORT) \
+ $(call SUBST,TARGET) \
+ $(call SUBST,WITH_FRAME_POINTERS) \
+ $(call SUBST,WITH_PROFINFO) \
+ $(call SUBST,WITH_SPACETIME) \
+ $(call SUBST,ENABLE_CALL_COUNTS) \
+ $(call SUBST,FLAT_FLOAT_ARRAY) \
+ $(call SUBST,CC_HAS_DEBUG_PREFIX_MAP) \
+ $(call SUBST,AS_HAS_DEBUG_PREFIX_MAP) \
+ $< > $@
diff --git a/utils/dune b/utils/dune
new file mode 100644
index 0000000000..e372dcf2a9
--- /dev/null
+++ b/utils/dune
@@ -0,0 +1,21 @@
+;**************************************************************************
+;* *
+;* OCaml *
+;* *
+;* Thomas Refis, Jane Street Europe *
+;* *
+;* Copyright 2018 Jane Street Group LLC *
+;* *
+;* All rights reserved. This file is distributed under the terms of *
+;* the GNU Lesser General Public License version 2.1, with the *
+;* special exception on linking described in the file LICENSE. *
+;* *
+;**************************************************************************
+
+(rule
+ (targets config.ml)
+ (mode fallback)
+ (deps (:mk Makefile)
+ ../Makefile.config
+ config.mlp)
+ (action (system "make -f %{mk} %{targets}")))