diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6863bdf5e11..c631d37275f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -41,6 +41,11 @@ jobs: os: ubuntu-latest build_ocamlparam: _,ocamlcfg=1 + - name: flambda2_runtime5 + config: --enable-middle-end=flambda2 --enable-runtime5 + os: ubuntu-latest + expected_fail: true + - name: flambda2_debug_runtime config: --enable-middle-end=flambda2 os: ubuntu-latest @@ -99,11 +104,17 @@ jobs: config: --enable-middle-end=closure os: ubuntu-20.04 + - name: build_upstream_closure_runtime5 + config: --enable-middle-end=closure --enable-runtime5 + os: ubuntu-20.04 + expected_fail: true + env: J: "3" # On macOS, the testsuite is slow, so run only on push to main (#507) run_testsuite: "${{matrix.os != 'macos-latest' || (github.event_name == 'push' && github.event.ref == 'refs/heads/main')}}" build_upstream: "${{matrix.name == 'build_upstream_closure'}}" + expected_fail: "${{matrix.expected_fail == true}}" steps: - name: Checkout the Flambda backend repo @@ -210,7 +221,13 @@ jobs: run: | if [ $run_testsuite = true ]; then target=ci; else target=compiler; fi export PATH=$GITHUB_WORKSPACE/ocaml-414/_install/bin:$PATH - if [ $build_upstream = true ]; then make -j$J build_and_test_upstream; else make $target; fi + if [ $build_upstream = true ]; then \ + make -j$J build_and_test_upstream \ + || (if [ $expected_fail = true ]; then exit 0; else exit 1; fi); \ + else \ + make $target \ + || (if [ $expected_fail = true ]; then exit 0; else exit 1; fi); \ + fi env: BUILD_OCAMLPARAM: ${{ matrix.build_ocamlparam }} OCAMLPARAM: ${{ matrix.ocamlparam }} diff --git a/Makefile b/Makefile index 26a6deebd2d..968fdf967b7 100644 --- a/Makefile +++ b/Makefile @@ -32,28 +32,28 @@ ci-coverage: boot-runtest coverage .PHONY: minimizer-upstream minimizer-upstream: cp chamelon/dune.upstream chamelon/dune - cd chamelon && $(dune) build + cd chamelon && RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build .PHONY: minimizer minimizer: _build/_bootinstall cp chamelon/dune.jst chamelon/dune - cd chamelon && $(dune) build + cd chamelon && RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build .PHONY: hacking-runtest hacking-runtest: _build/_bootinstall - $(dune) build $(ws_boot) $(coverage_dune_flags) -w $(boot_targets) @runtest + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) $(coverage_dune_flags) -w $(boot_targets) @runtest # Only needed for running the test tools by hand; runtest will take care of # building them using Dune .PHONY: test-tools test-tools: runtime-stdlib - $(dune) build $(ws_main) @middle_end/flambda2/tests/tools/all + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_main) @middle_end/flambda2/tests/tools/all ARCHES=amd64 arm64 .PHONY: check_all_arches check_all_arches: _build/_bootinstall for arch in $(ARCHES); do \ - ARCH=$$arch $(dune) build $(ws_boot) ocamloptcomp.cma; \ + ARCH=$$arch RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) ocamloptcomp.cma; \ done # Compare the Flambda backend installation tree against the upstream one. @@ -83,7 +83,7 @@ _compare/config.status: ocaml/config.status .PHONY: promote promote: - $(dune) promote $(ws_main) + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) promote $(ws_main) .PHONY: fmt fmt: @@ -109,24 +109,24 @@ check-fmt: .PHONY: regen-flambda2-parser regen-flambda2-parser: $(dune_config_targets) - $(dune) build $(ws_boot) @middle_end/flambda2/parser/regen --auto-promote || true + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) @middle_end/flambda2/parser/regen --auto-promote || true # Make sure regeneration is idempotent, and also check that the previous step # worked (can't tell the difference between failure and successful # auto-promotion) - $(dune) build $(ws_boot) @middle_end/flambda2/parser/regen + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) @middle_end/flambda2/parser/regen .PHONY: regen-flambda2-tests regen-flambda2-tests: boot-compiler regen-flambda2-test-dune-rules - $(dune) build $(ws_runstd) \ + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_runstd) \ @middle_end/flambda2/tests/regen --auto-promote || true - $(dune) build $(ws_runstd) \ + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_runstd) \ @middle_end/flambda2/tests/regen .PHONY: regen-flambda2-test-dune-rules regen-flambda2-test-dune-rules: $(dune_config_targets) - $(dune) build $(ws_boot) \ + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) \ @middle_end/flambda2/tests/regen-dune-rules --auto-promote || true - $(dune) build $(ws_boot) \ + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) \ @middle_end/flambda2/tests/regen-dune-rules ## Build upstream compiler. diff --git a/backend/amd64/emit.mlp b/backend/amd64/emit.mlp index c3516d5dc9c..d671d568de1 100644 --- a/backend/amd64/emit.mlp +++ b/backend/amd64/emit.mlp @@ -1761,13 +1761,13 @@ let emit_instr fallthrough i = load_label_addr lbl_handler r11; I.push r11; cfi_adjust_cfa_offset 8; - I.push (domain_field Domainstate.Domain_exception_pointer); + I.push (domain_field Domainstate.Domain_exn_handler); cfi_adjust_cfa_offset 8; - I.mov rsp (domain_field Domainstate.Domain_exception_pointer); + I.mov rsp (domain_field Domainstate.Domain_exn_handler); stack_offset := !stack_offset + 16; | Lpoptrap -> emit_pop_trap_label (); - I.pop (domain_field Domainstate.Domain_exception_pointer); + I.pop (domain_field Domainstate.Domain_exn_handler); cfi_adjust_cfa_offset (-8); I.add (int 8) rsp; cfi_adjust_cfa_offset (-8); @@ -1787,8 +1787,8 @@ let emit_instr fallthrough i = (* BACKPORT END *) record_frame Reg.Set.empty (Dbg_raise i.dbg) | Lambda.Raise_notrace -> - I.mov (domain_field Domainstate.Domain_exception_pointer) rsp; - I.pop (domain_field Domainstate.Domain_exception_pointer); + I.mov (domain_field Domainstate.Domain_exn_handler) rsp; + I.pop (domain_field Domainstate.Domain_exn_handler); I.pop r11; I.jmp r11 end diff --git a/configure.ac b/configure.ac index 126930a762d..1ae33cf8312 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,6 @@ AC_PREREQ([2.69]) AC_INIT([The Flambda backend for OCaml], - 5.1.1+jst-runtime4, + 5.1.1+jst, [mshinwell@janestreet.com], [flambda_backend], [http://github.com/ocaml-flambda/flambda_backend]) @@ -36,6 +36,12 @@ AC_ARG_ENABLE([middle-end], [*], [AC_MSG_ERROR([Bad middle end (not closure, flambda or flambda2)])])], [AC_MSG_ERROR([--enable-middle-end=closure|flambda|flambda2 must be provided])]) +AC_ARG_ENABLE([runtime5], + [AS_HELP_STRING([--enable-runtime5], + [Use the OCaml 5 runtime])], + [runtime5_arg=--enable-runtime5], + [runtime5_arg=]) + AC_ARG_ENABLE([coverage], [AS_HELP_STRING([--enable-coverage], [Run compiler tests instrumented to output coverage data using bisect_ppx @@ -62,7 +68,7 @@ AC_SUBST([legacy_layout]) AC_DISABLE_OPTION_CHECKING AX_SUBDIRS_CONFIGURE([ocaml], - [$middle_end_arg,-C,--disable-ocamldoc,--disable-stdlib-manpages,--enable-ocamltest], + [$middle_end_arg,$runtime5_arg,-C,--disable-ocamldoc,--disable-stdlib-manpages,--enable-ocamltest], [], [], []) diff --git a/ocaml/.gitignore b/ocaml/.gitignore index 2bc1b7b4c7c..cc1fc4428b3 100644 --- a/ocaml/.gitignore +++ b/ocaml/.gitignore @@ -358,3 +358,6 @@ META /yacc/.gdb_history /otherlibs/dynlink/natdynlinkops + +dune.runtime_selection + diff --git a/ocaml/Makefile b/ocaml/Makefile index 69f13af70e4..70b7e5ea8e7 100644 --- a/ocaml/Makefile +++ b/ocaml/Makefile @@ -29,7 +29,7 @@ defaultentry: $(DEFAULT_BUILD_TARGET) include stdlib/StdlibModules -CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims runtime4/primitives +CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims $(RUNTIME_DIR)/primitives CAMLOPT=$(OCAMLRUN) ./ocamlopt$(EXE) $(STDLIBFLAGS) -I otherlibs/dynlink ARCHES=amd64 arm64 power s390x riscv VPATH = utils parsing typing bytecomp file_formats lambda middle_end \ @@ -84,11 +84,11 @@ utils/config_main.ml: utils/config.generated.ml utils/config.common.ml reconfigure: ac_read_git_config=true ./configure $(CONFIGURE_ARGS) -utils/domainstate.ml: utils/domainstate.ml.c runtime4/caml/domain_state.tbl - $(V_GEN)$(CPP) -I runtime4/caml $< > $@ +utils/domainstate.ml: utils/domainstate.ml.c $(RUNTIME_DIR)/caml/domain_state.tbl + $(V_GEN)$(CPP) -I $(RUNTIME_DIR)/caml $< > $@ -utils/domainstate.mli: utils/domainstate.mli.c runtime4/caml/domain_state.tbl - $(V_GEN)$(CPP) -I runtime4/caml $< > $@ +utils/domainstate.mli: utils/domainstate.mli.c $(RUNTIME_DIR)/caml/domain_state.tbl + $(V_GEN)$(CPP) -I $(RUNTIME_DIR)/caml $< > $@ configure: tools/autogen configure.ac aclocal.m4 build-aux/ocaml_version.m4 $< @@ -164,7 +164,7 @@ OCAML_NATIVE_PROGRAMS = ocamlnat tools/lintapidiff.opt $(foreach PROGRAM, $(OCAML_NATIVE_PROGRAMS),\ $(eval $(call OCAML_NATIVE_PROGRAM,$(PROGRAM)))) -USE_RUNTIME_PRIMS = -use-prims ../runtime4/primitives +USE_RUNTIME_PRIMS = -use-prims ../$(RUNTIME_DIR)/primitives USE_STDLIB = -nostdlib -I ../stdlib FLEXDLL_OBJECTS = \ @@ -176,7 +176,7 @@ FLEXDLL_SOURCE_FILES = \ $(wildcard $(FLEXDLL_SOURCES)/*.c) $(wildcard $(FLEXDLL_SOURCES)/*.h) \ $(wildcard $(FLEXDLL_SOURCES)/*.ml) -boot/ocamlruns$(EXE): runtime4/ocamlruns$(EXE) +boot/ocamlruns$(EXE): $(RUNTIME_DIR)/ocamlruns$(EXE) cp $< $@ boot/flexlink.byte$(EXE): $(FLEXDLL_SOURCE_FILES) @@ -191,20 +191,20 @@ boot/flexlink.byte$(EXE): $(FLEXDLL_SOURCE_FILES) # The process depends on whether FlexDLL is also being bootstrapped. # Normal procedure: # - Build the runtime -# - Build the standard library using runtime4/ocamlrun +# - Build the standard library using $(RUNTIME_DIR)/ocamlrun # FlexDLL procedure: # - Build ocamlruns # - Build the standard library using boot/ocamlruns # - Build flexlink and FlexDLL support objects # - Build the runtime -# runtime4/ocamlrun is then installed to boot/ocamlrun and the stdlib artefacts +# $(RUNTIME_DIR)/ocamlrun is then installed to boot/ocamlrun and the stdlib artefacts # are copied to boot/ .PHONY: coldstart coldstart: $(COLDSTART_DEPS) ifeq "$(BOOTSTRAPPING_FLEXDLL)" "false" $(MAKE) runtime-all $(MAKE) -C stdlib \ - OCAMLRUN='$$(ROOTDIR)/runtime4/ocamlrun$(EXE)' \ + OCAMLRUN='$$(ROOTDIR)/$(RUNTIME_DIR)/ocamlrun$(EXE)' \ CAMLC='$$(BOOT_OCAMLC) $(USE_RUNTIME_PRIMS)' all else $(MAKE) -C stdlib OCAMLRUN='$$(ROOTDIR)/boot/ocamlruns$(EXE)' \ @@ -213,10 +213,10 @@ else $(MAKE) runtime-all endif # ifeq "$(BOOTSTRAPPING_FLEXDLL)" "false" rm -f boot/ocamlrun$(EXE) - cp runtime4/ocamlrun$(EXE) boot/ocamlrun$(EXE) + cp $(RUNTIME_DIR)/ocamlrun$(EXE) boot/ocamlrun$(EXE) cd boot; rm -f $(LIBFILES) cd stdlib; cp $(LIBFILES) ../boot - cd boot; $(LN) ../runtime4/libcamlrun.$(A) . + cd boot; $(LN) ../$(RUNTIME_DIR)/libcamlrun.$(A) . # Recompile the core system using the bootstrap compiler .PHONY: coreall @@ -273,7 +273,7 @@ promote-cross: promote-common promote: PROMOTE = $(OCAMLRUN) tools/stripdebug -all promote: promote-common rm -f boot/ocamlrun$(EXE) - cp runtime4/ocamlrun$(EXE) boot/ocamlrun$(EXE) + cp $(RUNTIME_DIR)/ocamlrun$(EXE) boot/ocamlrun$(EXE) # Compile the native-code compiler .PHONY: opt-core @@ -315,16 +315,16 @@ ifeq "$(FLAT_FLOAT_ARRAY)" "true" coreboot: # Promote the new compiler but keep the old runtime # This compiler runs on boot/ocamlrun and produces bytecode for -# runtime4/ocamlrun +# $(RUNTIME_DIR)/ocamlrun $(MAKE) promote-cross -# Rebuild ocamlc and ocamllex (run on runtime4/ocamlrun) +# Rebuild ocamlc and ocamllex (run on $(RUNTIME_DIR)/ocamlrun) # utils/config.ml will have the fixed bootstrap configuration $(MAKE) partialclean $(MAKE) IN_COREBOOT_CYCLE=true ocamlc ocamllex ocamltools -# Rebuild the library (using runtime4/ocamlrun ./ocamlc) +# Rebuild the library (using $(RUNTIME_DIR)/ocamlrun ./ocamlc) $(MAKE) library-cross # Promote the new compiler and the new runtime - $(MAKE) OCAMLRUN=runtime4/ocamlrun$(EXE) promote + $(MAKE) OCAMLRUN=$(RUNTIME_DIR)/ocamlrun$(EXE) promote # Rebuild the core system # utils/config.ml must still have the fixed bootstrap configuration $(MAKE) partialclean @@ -409,7 +409,7 @@ flexlink: @false ifeq "$(wildcard ocamlopt.opt$(EXE))" "" - FLEXLINK_OCAMLOPT=../runtime4/ocamlrun$(EXE) ../ocamlopt$(EXE) + FLEXLINK_OCAMLOPT=../$(RUNTIME_DIR)/ocamlrun$(EXE) ../ocamlopt$(EXE) else FLEXLINK_OCAMLOPT=../ocamlopt.opt$(EXE) endif @@ -513,7 +513,7 @@ TOPFLAGS ?= OC_TOPFLAGS = $(STDLIBFLAGS) -I toplevel -noinit $(TOPINCLUDES) $(TOPFLAGS) # Note: Beware that, since this rule begins with a coldstart, both -# boot/ocamlrun and runtime4/ocamlrun will be the same when the toplevel +# boot/ocamlrun and $(RUNTIME_DIR)/ocamlrun will be the same when the toplevel # is run. .PHONY: runtop runtop: @@ -544,8 +544,8 @@ beforedepend:: parsing/lexer.ml # The predefined exceptions and primitives -lambda/runtimedef.ml: lambda/generate_runtimedef.sh runtime4/caml/fail.h \ - runtime4/primitives +lambda/runtimedef.ml: lambda/generate_runtimedef.sh $(RUNTIME_DIR)/caml/fail.h \ + $(RUNTIME_DIR)/primitives $(V_GEN)$^ > $@ partialclean:: @@ -603,11 +603,9 @@ expunge_MODULES = toplevel/expunge partialclean:: rm -f expunge expunge.exe -# The runtime system - -## Lists of source files +# Runtime system source files (v4) -runtime_COMMON_C_SOURCES = \ +runtime4_COMMON_C_SOURCES = \ afl \ alloc \ array \ @@ -657,7 +655,7 @@ runtime_COMMON_C_SOURCES = \ $(UNIX_OR_WIN32) \ weak -runtime_BYTECODE_ONLY_C_SOURCES = \ +runtime4_BYTECODE_ONLY_C_SOURCES = \ backtrace_byt \ fail_byt \ fix_code \ @@ -666,11 +664,8 @@ runtime_BYTECODE_ONLY_C_SOURCES = \ signals_byt \ stacks \ startup_byt -runtime_BYTECODE_C_SOURCES = \ - $(runtime_COMMON_C_SOURCES:%=runtime4/%.c) \ - $(runtime_BYTECODE_ONLY_C_SOURCES:%=runtime4/%.c) -runtime_NATIVE_ONLY_C_SOURCES = \ +runtime4_NATIVE_ONLY_C_SOURCES = \ backtrace_nat \ clambda_checks \ dynlink_nat \ @@ -678,44 +673,121 @@ runtime_NATIVE_ONLY_C_SOURCES = \ roots_nat \ startup_nat \ signals_nat + +# Runtime system source files (v5) + +runtime_COMMON_C_SOURCES = \ + addrmap \ + afl \ + alloc \ + array \ + backtrace \ + bigarray \ + callback \ + codefrag \ + compare \ + custom \ + debugger \ + domain \ + dynlink \ + extern \ + fiber \ + finalise \ + floats \ + gc_ctrl \ + gc_stats \ + globroots \ + hash \ + intern \ + ints \ + io \ + lexing \ + lf_skiplist \ + main \ + major_gc \ + md5 \ + memory \ + memprof \ + meta \ + minor_gc \ + misc \ + obj \ + parsing \ + platform \ + printexc \ + prng \ + roots \ + runtime_events \ + shared_heap \ + signals \ + skiplist \ + startup_aux \ + str \ + sync \ + sys \ + $(UNIX_OR_WIN32) \ + weak + +runtime_BYTECODE_ONLY_C_SOURCES = \ + backtrace_byt \ + fail_byt \ + fix_code \ + interp \ + startup_byt + +runtime_NATIVE_ONLY_C_SOURCES = \ + backtrace_nat \ + clambda_checks \ + dynlink_nat \ + fail_nat \ + frame_descriptors \ + startup_nat \ + signals_nat + +# The runtime system + +runtime_BYTECODE_C_SOURCES = \ + $(runtime$(RUNTIME_SUFFIX)_COMMON_C_SOURCES:%=$(RUNTIME_DIR)/%.c) \ + $(runtime$(RUNTIME_SUFFIX)_BYTECODE_ONLY_C_SOURCES:%=$(RUNTIME_DIR)/%.c) + runtime_NATIVE_C_SOURCES = \ - $(runtime_COMMON_C_SOURCES:%=runtime4/%.c) \ - $(runtime_NATIVE_ONLY_C_SOURCES:%=runtime4/%.c) + $(runtime$(RUNTIME_SUFFIX)_COMMON_C_SOURCES:%=$(RUNTIME_DIR)/%.c) \ + $(runtime$(RUNTIME_SUFFIX)_NATIVE_ONLY_C_SOURCES:%=$(RUNTIME_DIR)/%.c) ## Header files generated by configure -runtime_CONFIGURED_HEADERS = $(addprefix runtime4/caml/, m.h s.h version.h) +runtime_CONFIGURED_HEADERS = $(addprefix $(RUNTIME_DIR)/caml/, m.h s.h version.h) ## Header files generated by make -runtime_BUILT_HEADERS = $(addprefix runtime4/, \ +runtime_BUILT_HEADERS = $(addprefix $(RUNTIME_DIR)/, \ caml/opnames.h caml/jumptbl.h build_config.h) ## Targets to build and install -runtime_PROGRAMS = runtime4/ocamlrun$(EXE) -runtime_BYTECODE_STATIC_LIBRARIES = $(addprefix runtime4/, \ +runtime_PROGRAMS = $(RUNTIME_DIR)/ocamlrun$(EXE) +runtime_BYTECODE_STATIC_LIBRARIES = $(addprefix $(RUNTIME_DIR)/, \ ld.conf libcamlrun.$(A)) runtime_BYTECODE_SHARED_LIBRARIES = -runtime_NATIVE_STATIC_LIBRARIES = runtime4/libasmrun.$(A) +runtime_NATIVE_STATIC_LIBRARIES = $(RUNTIME_DIR)/libasmrun.$(A) runtime_NATIVE_SHARED_LIBRARIES = ifeq "$(RUNTIMED)" "true" -runtime_PROGRAMS += runtime4/ocamlrund$(EXE) -runtime_BYTECODE_STATIC_LIBRARIES += runtime4/libcamlrund.$(A) -runtime_NATIVE_STATIC_LIBRARIES += runtime4/libasmrund.$(A) +runtime_PROGRAMS += $(RUNTIME_DIR)/ocamlrund$(EXE) +runtime_BYTECODE_STATIC_LIBRARIES += $(RUNTIME_DIR)/libcamlrund.$(A) +runtime_NATIVE_STATIC_LIBRARIES += $(RUNTIME_DIR)/libasmrund.$(A) endif ifeq "$(INSTRUMENTED_RUNTIME)" "true" -runtime_PROGRAMS += runtime4/ocamlruni$(EXE) -runtime_BYTECODE_STATIC_LIBRARIES += runtime4/libcamlruni.$(A) -runtime_NATIVE_STATIC_LIBRARIES += runtime4/libasmruni.$(A) +runtime_PROGRAMS += $(RUNTIME_DIR)/ocamlruni$(EXE) +runtime_BYTECODE_STATIC_LIBRARIES += $(RUNTIME_DIR)/libcamlruni.$(A) +runtime_NATIVE_STATIC_LIBRARIES += $(RUNTIME_DIR)/libasmruni.$(A) endif ifeq "$(UNIX_OR_WIN32)" "unix" ifeq "$(SUPPORTS_SHARED_LIBRARIES)" "true" -runtime_BYTECODE_STATIC_LIBRARIES += runtime4/libcamlrun_pic.$(A) -runtime_BYTECODE_SHARED_LIBRARIES += runtime4/libcamlrun_shared.$(SO) -runtime_NATIVE_STATIC_LIBRARIES += runtime4/libasmrun_pic.$(A) -runtime_NATIVE_SHARED_LIBRARIES += runtime4/libasmrun_shared.$(SO) +runtime_BYTECODE_STATIC_LIBRARIES += $(RUNTIME_DIR)/libcamlrun_pic.$(A) +runtime_BYTECODE_SHARED_LIBRARIES += $(RUNTIME_DIR)/libcamlrun_shared.$(SO) +runtime_NATIVE_STATIC_LIBRARIES += $(RUNTIME_DIR)/libasmrun_pic.$(A) +runtime_NATIVE_SHARED_LIBRARIES += $(RUNTIME_DIR)/libasmrun_shared.$(SO) endif endif @@ -728,7 +800,7 @@ libcamlrun_non_shared_OBJECTS = \ $(libcamlrun_OBJECTS)) libcamlrund_OBJECTS = $(runtime_BYTECODE_C_SOURCES:.c=.bd.$(O)) \ - runtime4/instrtrace.bd.$(O) + $(RUNTIME_DIR)/instrtrace.bd.$(O) libcamlruni_OBJECTS = $(runtime_BYTECODE_C_SOURCES:.c=.bi.$(O)) @@ -748,7 +820,11 @@ libasmrunpic_OBJECTS = $(runtime_NATIVE_C_SOURCES:.c=.npic.$(O)) \ ## General (non target-specific) assembler and compiler flags -runtime_CPPFLAGS = -DCAMLDLLIMPORT= -DIN_CAML_RUNTIME -Wno-strict-prototypes -Wno-missing-prototypes -Wno-implicit-function-declaration -DCAML_NAME_SPACE +ifeq "$(RUNTIME_SUFFIX)" "4" + runtime_CPPFLAGS = -DCAMLDLLIMPORT= -DIN_CAML_RUNTIME -Wno-strict-prototypes -Wno-missing-prototypes -Wno-implicit-function-declaration -DCAML_NAME_SPACE +else + runtime_CPPFLAGS = -DCAMLDLLIMPORT= -DIN_CAML_RUNTIME +endif ocamlrund_CPPFLAGS = -DDEBUG ocamlruni_CPPFLAGS = -DCAML_INSTR @@ -770,7 +846,7 @@ endif ## Generated non-object files -runtime4/ld.conf: $(ROOTDIR)/Makefile.config +$(RUNTIME_DIR)/ld.conf: $(ROOTDIR)/Makefile.config $(V_GEN)echo "$(STUBLIBDIR)" > $@ && \ echo "$(LIBDIR)" >> $@ @@ -795,13 +871,20 @@ runtime4/ld.conf: $(ROOTDIR)/Makefile.config # To speed up builds, we avoid changing "primitives" when files # containing primitives change but the primitives table does not -runtime4/primitives: \ - $(shell (cd $(ROOTDIR)/runtime4 && ./gen_primitives.sh) > runtime4/primitives.new; \ - cmp -s runtime4/primitives runtime4/primitives.new || \ - echo runtime4/primitives.new) +ifeq "$(RUNTIME_SUFFIX)" "4" + GEN_PRIMS_DIR=$(RUNTIME_DIR) + GEN_PRIMS_REL=. +else + GEN_PRIMS_DIR= + GEN_PRIMS_REL=$(RUNTIME_DIR) +endif +$(RUNTIME_DIR)/primitives: \ + $(shell (cd $(ROOTDIR)/$(GEN_PRIMS_DIR) && $(GEN_PRIMS_REL)/gen_primitives.sh) > $(ROOTDIR)/$(RUNTIME_DIR)/primitives.new; \ + cmp -s $(RUNTIME_DIR)/primitives $(RUNTIME_DIR)/primitives.new || \ + echo $(RUNTIME_DIR)/primitives.new) $(V_GEN)cp $^ $@ -runtime4/prims.c : runtime4/primitives +$(RUNTIME_DIR)/prims.c : $(RUNTIME_DIR)/primitives $(V_GEN)export LC_ALL=C; \ (echo '#include "caml/config.h"'; \ echo 'typedef intnat value;'; \ @@ -817,7 +900,7 @@ runtime4/prims.c : runtime4/primitives sed -e 's/.*/ "&",/' $<; \ echo ' 0 };') > $@ -runtime4/caml/opnames.h : runtime4/caml/instruct.h +$(RUNTIME_DIR)/caml/opnames.h : $(RUNTIME_DIR)/caml/instruct.h $(V_GEN)tr -d '\r' < $< | \ sed -e '/\/\*/d' \ -e '/^#/d' \ @@ -825,8 +908,8 @@ runtime4/caml/opnames.h : runtime4/caml/instruct.h -e 's/{$$/[] = {/' \ -e 's/\([[:upper:]][[:upper:]_0-9]*\)/"\1"/g' > $@ -# runtime4/caml/jumptbl.h is required only if you have GCC 2.0 or later -runtime4/caml/jumptbl.h : runtime4/caml/instruct.h +# $(RUNTIME_DIR)/caml/jumptbl.h is required only if you have GCC 2.0 or later +$(RUNTIME_DIR)/caml/jumptbl.h : $(RUNTIME_DIR)/caml/instruct.h $(V_GEN)tr -d '\r' < $< | \ sed -n -e '/^ /s/ \([A-Z]\)/ \&\&lbl_\1/gp' \ -e '/^}/q' > $@ @@ -837,96 +920,96 @@ SAK_CC ?= $(CC) SAK_CFLAGS ?= $(OC_CFLAGS) $(CFLAGS) $(OC_CPPFLAGS) $(CPPFLAGS) SAK_LINK ?= $(MKEXE_VIA_CC) -$(SAK): runtime4/sak.$(O) +$(SAK): $(RUNTIME_DIR)/sak.$(O) $(V_MKEXE)$(call SAK_LINK,$@,$^) -runtime4/sak.$(O): runtime4/sak.c runtime4/caml/misc.h runtime4/caml/config.h +$(RUNTIME_DIR)/sak.$(O): $(RUNTIME_DIR)/sak.c $(RUNTIME_DIR)/caml/misc.h $(RUNTIME_DIR)/caml/config.h $(V_CC)$(SAK_CC) -c $(SAK_CFLAGS) $(OUTPUTOBJ)$@ $< C_LITERAL = $(shell $(SAK) encode-C-literal '$(1)') -runtime4/build_config.h: $(ROOTDIR)/Makefile.config $(SAK) +$(RUNTIME_DIR)/build_config.h: $(ROOTDIR)/Makefile.config $(SAK) $(V_GEN)echo '/* This file is generated from $(ROOTDIR)/Makefile.config */' > $@ && \ echo '#define OCAML_STDLIB_DIR $(call C_LITERAL,$(LIBDIR))' >> $@ && \ echo '#define HOST "$(HOST)"' >> $@ ## Runtime libraries and programs -runtime4/ocamlrun$(EXE): runtime4/prims.$(O) runtime4/libcamlrun.$(A) +$(RUNTIME_DIR)/ocamlrun$(EXE): $(RUNTIME_DIR)/prims.$(O) $(RUNTIME_DIR)/libcamlrun.$(A) $(V_MKEXE)$(MKEXE) -o $@ $^ $(BYTECCLIBS) -runtime4/ocamlruns$(EXE): runtime4/prims.$(O) runtime4/libcamlrun_non_shared.$(A) +$(RUNTIME_DIR)/ocamlruns$(EXE): $(RUNTIME_DIR)/prims.$(O) $(RUNTIME_DIR)/libcamlrun_non_shared.$(A) $(V_MKEXE)$(call MKEXE_VIA_CC,$@,$^ $(BYTECCLIBS)) -runtime4/libcamlrun.$(A): $(libcamlrun_OBJECTS) +$(RUNTIME_DIR)/libcamlrun.$(A): $(libcamlrun_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/libcamlrun_non_shared.$(A): $(libcamlrun_non_shared_OBJECTS) +$(RUNTIME_DIR)/libcamlrun_non_shared.$(A): $(libcamlrun_non_shared_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/ocamlrund$(EXE): runtime4/prims.$(O) runtime4/libcamlrund.$(A) +$(RUNTIME_DIR)/ocamlrund$(EXE): $(RUNTIME_DIR)/prims.$(O) $(RUNTIME_DIR)/libcamlrund.$(A) $(V_MKEXE)$(MKEXE) $(MKEXEDEBUGFLAG) -o $@ $^ $(BYTECCLIBS) -runtime4/libcamlrund.$(A): $(libcamlrund_OBJECTS) +$(RUNTIME_DIR)/libcamlrund.$(A): $(libcamlrund_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/ocamlruni$(EXE): runtime4/prims.$(O) runtime4/libcamlruni.$(A) +$(RUNTIME_DIR)/ocamlruni$(EXE): $(RUNTIME_DIR)/prims.$(O) $(RUNTIME_DIR)/libcamlruni.$(A) $(V_MKEXE)$(MKEXE) -o $@ $^ $(INSTRUMENTED_RUNTIME_LIBS) $(BYTECCLIBS) -runtime4/libcamlruni.$(A): $(libcamlruni_OBJECTS) +$(RUNTIME_DIR)/libcamlruni.$(A): $(libcamlruni_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/libcamlrun_pic.$(A): $(libcamlrunpic_OBJECTS) +$(RUNTIME_DIR)/libcamlrun_pic.$(A): $(libcamlrunpic_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/libcamlrun_shared.$(SO): $(libcamlrunpic_OBJECTS) +$(RUNTIME_DIR)/libcamlrun_shared.$(SO): $(libcamlrunpic_OBJECTS) $(V_MKDLL)$(MKDLL) -o $@ $^ $(BYTECCLIBS) -runtime4/libasmrun.$(A): $(libasmrun_OBJECTS) +$(RUNTIME_DIR)/libasmrun.$(A): $(libasmrun_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/libasmrund.$(A): $(libasmrund_OBJECTS) +$(RUNTIME_DIR)/libasmrund.$(A): $(libasmrund_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/libasmruni.$(A): $(libasmruni_OBJECTS) +$(RUNTIME_DIR)/libasmruni.$(A): $(libasmruni_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/libasmrun_pic.$(A): $(libasmrunpic_OBJECTS) +$(RUNTIME_DIR)/libasmrun_pic.$(A): $(libasmrunpic_OBJECTS) $(V_MKLIB)$(call MKLIB,$@, $^) -runtime4/libasmrun_shared.$(SO): $(libasmrunpic_OBJECTS) +$(RUNTIME_DIR)/libasmrun_shared.$(SO): $(libasmrunpic_OBJECTS) $(V_MKDLL)$(MKDLL) -o $@ $^ $(NATIVECCLIBS) ## Runtime target-specific preprocessor and compiler flags -runtime4/%.$(O): OC_CPPFLAGS += $(runtime_CPPFLAGS) -$(DEPDIR)/runtime4/%.$(D): OC_CPPFLAGS += $(runtime_CPPFLAGS) +$(RUNTIME_DIR)/%.$(O): OC_CPPFLAGS += $(runtime_CPPFLAGS) +$(DEPDIR)/$(RUNTIME_DIR)/%.$(D): OC_CPPFLAGS += $(runtime_CPPFLAGS) -runtime4/%.bd.$(O): OC_CPPFLAGS += $(ocamlrund_CPPFLAGS) -$(DEPDIR)/runtime4/%.bd.$(D): OC_CPPFLAGS += $(ocamlrund_CPPFLAGS) +$(RUNTIME_DIR)/%.bd.$(O): OC_CPPFLAGS += $(ocamlrund_CPPFLAGS) +$(DEPDIR)/$(RUNTIME_DIR)/%.bd.$(D): OC_CPPFLAGS += $(ocamlrund_CPPFLAGS) -runtime4/%.bi.$(O): OC_CPPFLAGS += $(ocamlruni_CPPFLAGS) -$(DEPDIR)/runtime4/%.bi.$(D): OC_CPPFLAGS += $(ocamlruni_CPPFLAGS) +$(RUNTIME_DIR)/%.bi.$(O): OC_CPPFLAGS += $(ocamlruni_CPPFLAGS) +$(DEPDIR)/$(RUNTIME_DIR)/%.bi.$(D): OC_CPPFLAGS += $(ocamlruni_CPPFLAGS) -runtime4/%.bpic.$(O): OC_CFLAGS += $(SHAREDLIB_CFLAGS) +$(RUNTIME_DIR)/%.bpic.$(O): OC_CFLAGS += $(SHAREDLIB_CFLAGS) -runtime4/%.n.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) -runtime4/%.n.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) -$(DEPDIR)/runtime4/%.n.$(D): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) +$(RUNTIME_DIR)/%.n.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) +$(RUNTIME_DIR)/%.n.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) +$(DEPDIR)/$(RUNTIME_DIR)/%.n.$(D): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) -runtime4/%.nd.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) -runtime4/%.nd.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) $(ocamlrund_CPPFLAGS) -$(DEPDIR)/runtime4/%.nd.$(D): \ +$(RUNTIME_DIR)/%.nd.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) +$(RUNTIME_DIR)/%.nd.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) $(ocamlrund_CPPFLAGS) +$(DEPDIR)/$(RUNTIME_DIR)/%.nd.$(D): \ OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) $(ocamlrund_CPPFLAGS) -runtime4/%.ni.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) -runtime4/%.ni.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) $(ocamlruni_CPPFLAGS) -$(DEPDIR)/runtime4/%.ni.$(D): \ +$(RUNTIME_DIR)/%.ni.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) +$(RUNTIME_DIR)/%.ni.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) $(ocamlruni_CPPFLAGS) +$(DEPDIR)/$(RUNTIME_DIR)/%.ni.$(D): \ OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) $(ocamlruni_CPPFLAGS) -runtime4/%.npic.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) $(SHAREDLIB_CFLAGS) -runtime4/%.npic.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) -$(DEPDIR)/runtime4/%.npic.$(D): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) +$(RUNTIME_DIR)/%.npic.$(O): OC_CFLAGS += $(OC_NATIVE_CFLAGS) $(SHAREDLIB_CFLAGS) +$(RUNTIME_DIR)/%.npic.$(O): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) +$(DEPDIR)/$(RUNTIME_DIR)/%.npic.$(D): OC_CPPFLAGS += $(OC_NATIVE_CPPFLAGS) ## Compilation of runtime C files @@ -943,9 +1026,9 @@ ifneq "$(1)" "%" # ones will not be generated. For this reason, we don't use -MG and # instead include $(runtime_BUILT_HEADERS) in the order only dependencies # to ensure that they exist before dependencies are computed. -$(DEPDIR)/$(1).$(D): runtime4/%.c | $(DEPDIR)/runtime $(runtime_BUILT_HEADERS) +$(DEPDIR)/$(1).$(D): $(RUNTIME_DIR)/%.c | $(DEPDIR)/$(RUNTIME_DIR) $(runtime_BUILT_HEADERS) $$(V_CCDEPS)$$(DEP_CC) $$(OC_CPPFLAGS) $$(CPPFLAGS) $$< -MT \ - 'runtime4/$$*$(subst runtime4/%,,$(1)).$(O)' -MF $$@ + '$(RUNTIME_DIR)/$$*$(subst $(RUNTIME_DIR)/%,,$(1)).$(O)' -MF $$@ endif # ifneq "$(1)" "%" $(1).$(O): $(2).c else @@ -966,17 +1049,17 @@ runtime_OBJECT_TYPES += %.n %.nd %.ni %.np %.npic endif $(foreach runtime_OBJECT_TYPE, $(runtime_OBJECT_TYPES), \ - $(eval $(call COMPILE_C_FILE,runtime4/$(runtime_OBJECT_TYPE),runtime4/%))) + $(eval $(call COMPILE_C_FILE,$(RUNTIME_DIR)/$(runtime_OBJECT_TYPE),$(RUNTIME_DIR)/%))) -runtime4/$(UNIX_OR_WIN32)_non_shared.%.$(O): \ +$(RUNTIME_DIR)/$(UNIX_OR_WIN32)_non_shared.%.$(O): \ OC_CPPFLAGS += -DBUILDING_LIBCAMLRUNS -$(eval $(call COMPILE_C_FILE,runtime4/$(UNIX_OR_WIN32)_non_shared.%, \ - runtime4/$(UNIX_OR_WIN32))) +$(eval $(call COMPILE_C_FILE,$(RUNTIME_DIR)/$(UNIX_OR_WIN32)_non_shared.%, \ + $(RUNTIME_DIR)/$(UNIX_OR_WIN32))) $(foreach runtime_OBJECT_TYPE,$(subst %,,$(runtime_OBJECT_TYPES)), \ $(eval \ - runtime4/dynlink$(runtime_OBJECT_TYPE).$(O): $(ROOTDIR)/Makefile.config)) + $(RUNTIME_DIR)/dynlink$(runtime_OBJECT_TYPE).$(O): $(ROOTDIR)/Makefile.config)) ## Compilation of runtime assembly files @@ -985,42 +1068,42 @@ ASPP_ERROR = \ echo "unhappy with the preprocessor. Check your assembler, or";\ echo "try producing $*.o by hand.";\ exit 2; } -runtime4/%.o: runtime4/%.S +$(RUNTIME_DIR)/%.o: $(RUNTIME_DIR)/%.S $(V_ASM)$(ASPP) $(OC_ASPPFLAGS) -o $@ $< || $(ASPP_ERROR) -runtime4/%.d.o: runtime4/%.S +$(RUNTIME_DIR)/%.d.o: $(RUNTIME_DIR)/%.S $(V_ASM)$(ASPP) $(OC_ASPPFLAGS) $(ocamlrund_CPPFLAGS) -o $@ $< || $(ASPP_ERROR) -runtime4/%.i.o: runtime4/%.S +$(RUNTIME_DIR)/%.i.o: $(RUNTIME_DIR)/%.S $(V_ASM)$(ASPP) $(OC_ASPPFLAGS) $(ocamlruni_CPPFLAGS) -o $@ $< || $(ASPP_ERROR) -runtime4/%_libasmrunpic.o: runtime4/%.S +$(RUNTIME_DIR)/%_libasmrunpic.o: $(RUNTIME_DIR)/%.S $(V_ASM)$(ASPP) $(OC_ASPPFLAGS) $(SHAREDLIB_CFLAGS) -o $@ $< -runtime4/domain_state64.inc: \ - runtime4/gen_domain_state64_inc.awk runtime4/caml/domain_state.tbl +$(RUNTIME_DIR)/domain_state64.inc: \ + $(RUNTIME_DIR)/gen_domain_state64_inc.awk $(RUNTIME_DIR)/caml/domain_state.tbl $(V_GEN)$(AWK) -f $^ > $@ -runtime4/domain_state32.inc: \ - runtime4/gen_domain_state32_inc.awk runtime4/caml/domain_state.tbl +$(RUNTIME_DIR)/domain_state32.inc: \ + $(RUNTIME_DIR)/gen_domain_state32_inc.awk $(RUNTIME_DIR)/caml/domain_state.tbl $(V_GEN)$(AWK) -f $^ > $@ -runtime4/amd64nt.obj: runtime4/amd64nt.asm runtime4/domain_state64.inc +$(RUNTIME_DIR)/amd64nt.obj: $(RUNTIME_DIR)/amd64nt.asm $(RUNTIME_DIR)/domain_state64.inc $(V_ASM)$(ASM)$@ $< -runtime4/amd64nt.d.obj: runtime4/amd64nt.asm runtime4/domain_state64.inc +$(RUNTIME_DIR)/amd64nt.d.obj: $(RUNTIME_DIR)/amd64nt.asm $(RUNTIME_DIR)/domain_state64.inc $(V_ASM)$(ASM)$@ $(ocamlrund_CPPFLAGS) $< -runtime4/amd64nt.i.obj: runtime4/amd64nt.asm runtime4/domain_state64.inc +$(RUNTIME_DIR)/amd64nt.i.obj: $(RUNTIME_DIR)/amd64nt.asm $(RUNTIME_DIR)/domain_state64.inc $(V_ASM)$(ASM)$@ $(ocamlruni_CPPFLAGS) $< -runtime4/%_libasmrunpic.obj: runtime4/%.asm +$(RUNTIME_DIR)/%_libasmrunpic.obj: $(RUNTIME_DIR)/%.asm $(V_ASM)$(ASM)$@ $< ## Runtime dependencies runtime_DEP_FILES := $(addsuffix .b, \ - $(basename $(runtime_BYTECODE_C_SOURCES) runtime4/instrtrace)) + $(basename $(runtime_BYTECODE_C_SOURCES) $(RUNTIME_DIR)/instrtrace)) ifeq "$(NATIVE_COMPILER)" "true" runtime_DEP_FILES += $(addsuffix .n, $(basename $(runtime_NATIVE_C_SOURCES))) endif @@ -1047,15 +1130,15 @@ endif .PHONY: makeruntime makeruntime: runtime-all stdlib/libcamlrun.$(A): runtime-all - cd stdlib; $(LN) ../runtime4/libcamlrun.$(A) . + cd stdlib; $(LN) ../$(RUNTIME_DIR)/libcamlrun.$(A) . clean:: - rm -f $(addprefix runtime4/, *.o *.obj *.a *.lib *.so *.dll ld.conf) - rm -f $(addprefix runtime4/, ocamlrun ocamlrund ocamlruni ocamlruns sak) - rm -f $(addprefix runtime4/, \ + rm -f $(addprefix $(RUNTIME_DIR)/, *.o *.obj *.a *.lib *.so *.dll ld.conf) + rm -f $(addprefix $(RUNTIME_DIR)/, ocamlrun ocamlrund ocamlruni ocamlruns sak) + rm -f $(addprefix $(RUNTIME_DIR)/, \ ocamlrun.exe ocamlrund.exe ocamlruni.exe ocamlruns.exe sak.exe) - rm -f runtime4/primitives runtime4/primitives.new runtime4/prims.c \ + rm -f $(RUNTIME_DIR)/primitives $(RUNTIME_DIR)/primitives.new $(RUNTIME_DIR)/prims.c \ $(runtime_BUILT_HEADERS) - rm -f runtime4/domain_state*.inc + rm -f $(RUNTIME_DIR)/domain_state*.inc rm -rf $(DEPDIR) rm -f stdlib/libcamlrun.a stdlib/libcamlrun.lib @@ -1065,7 +1148,7 @@ runtimeopt: stdlib/libasmrun.$(A) .PHONY: makeruntimeopt makeruntimeopt: runtime-allopt stdlib/libasmrun.$(A): runtime-allopt - cd stdlib; $(LN) ../runtime4/libasmrun.$(A) . + cd stdlib; $(LN) ../$(RUNTIME_DIR)/libasmrun.$(A) . clean:: rm -f stdlib/libasmrun.a stdlib/libasmrun.lib @@ -1091,7 +1174,11 @@ library: ocamlc .PHONY: library-cross library-cross: - $(MAKE) -C stdlib OCAMLRUN=../runtime4/ocamlrun$(EXE) all + $(MAKE) -C stdlib OCAMLRUN=../$(RUNTIME_DIR)/ocamlrun$(EXE) all + +.PHONY: library-cross5 +library-cross5: + $(MAKE) -C stdlib OCAMLRUN=../runtime/ocamlrun$(EXE) all .PHONY: libraryopt libraryopt: @@ -1414,7 +1501,7 @@ make_opcodes = tools/make_opcodes$(EXE) make_opcodes_LIBRARIES = make_opcodes_MODULES = tools/make_opcodes -tools/opnames.ml: runtime4/caml/instruct.h $(make_opcodes) +tools/opnames.ml: $(RUNTIME_DIR)/caml/instruct.h $(make_opcodes) $(V_GEN)$(NEW_OCAMLRUN) $(make_opcodes) -opnames < $< > $@ clean:: @@ -1530,7 +1617,7 @@ toplevel/native/topeval.cmx: otherlibs/dynlink/dynlink.cmxa # The numeric opcodes -bytecomp/opcodes.ml: runtime4/caml/instruct.h $(make_opcodes) +bytecomp/opcodes.ml: $(RUNTIME_DIR)/caml/instruct.h $(make_opcodes) $(V_GEN)$(NEW_OCAMLRUN) $(make_opcodes) -opcodes < $< > $@ bytecomp/opcodes.mli: bytecomp/opcodes.ml @@ -1617,7 +1704,7 @@ ifneq "$(runtime_BYTECODE_SHARED_LIBRARIES)" "" $(INSTALL_PROG) $(runtime_BYTECODE_SHARED_LIBRARIES) \ "$(INSTALL_LIBDIR)" endif - $(INSTALL_DATA) runtime4/caml/domain_state.tbl runtime4/caml/*.h \ + $(INSTALL_DATA) $(RUNTIME_DIR)/caml/domain_state.tbl $(RUNTIME_DIR)/caml/*.h \ "$(INSTALL_INCDIR)" $(INSTALL_PROG) ocaml$(EXE) "$(INSTALL_BINDIR)" ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true" diff --git a/ocaml/Makefile.build_config.in b/ocaml/Makefile.build_config.in index b7a423af700..930a74cd631 100644 --- a/ocaml/Makefile.build_config.in +++ b/ocaml/Makefile.build_config.in @@ -52,7 +52,7 @@ COMPUTE_DEPS=@compute_deps@ # Build-system flags to use to compile C files OC_CFLAGS=@oc_cflags@ -OC_CPPFLAGS=-I$(ROOTDIR)/runtime4 @oc_cppflags@ +OC_CPPFLAGS=-I$(ROOTDIR)/$(RUNTIME_DIR) @oc_cppflags@ # The following variable defines flags to be passed to the C preprocessor # when compiling C files to be linked with native code. This includes @@ -148,7 +148,7 @@ OC_NATIVE_LINKFLAGS = -g LN = @ln@ # Platform-dependent assembler files to use to build the runtime -runtime_ASM_OBJECTS = $(addprefix runtime4/,@runtime_asm_objects@) +runtime_ASM_OBJECTS = $(addprefix $(RUNTIME_DIR)/,@runtime_asm_objects@) # Platform-dependent module for ocamlyacc ocamlyacc_WSTR_MODULE = @ocamlyacc_wstr_module@ diff --git a/ocaml/Makefile.common b/ocaml/Makefile.common index 9e07c579d12..5bec430b796 100644 --- a/ocaml/Makefile.common +++ b/ocaml/Makefile.common @@ -90,14 +90,14 @@ FLEXDLL_SUBMODULE_PRESENT := $(wildcard $(ROOTDIR)/flexdll/Makefile) IN_COREBOOT_CYCLE ?= false # Variables used to represent the OCaml runtime system -# Most of the time, boot/ocamlrun and runtime4/ocamlrun are the same. +# Most of the time, boot/ocamlrun and $(RUNTIME_DIR)/ocamlrun are the same. # However, under some circumstances it is important to be able to # distinguish one from the other, hence these two variables. # Boot/ocamlrun is the most frequently used in the build system, so # we use OCAMLRUN to designate it and keep NEW_OCAMLRUN to refer -# to runtime4/ocamlrun, because it's less frequently used. +# to $(RUNTIME_DIR)/ocamlrun, because it's less frequently used. OCAMLRUN ?= $(ROOTDIR)/boot/ocamlrun$(EXE) -NEW_OCAMLRUN ?= $(ROOTDIR)/runtime4/ocamlrun$(EXE) +NEW_OCAMLRUN ?= $(ROOTDIR)/$(RUNTIME_DIR)/ocamlrun$(EXE) # Standard library flags STDLIBFLAGS ?= -nostdlib -I $(ROOTDIR)/stdlib @@ -159,8 +159,8 @@ ifeq "$(COMPUTE_DEPS)" "true" RUNTIME_HEADERS := REQUIRED_HEADERS := else -RUNTIME_HEADERS := $(wildcard $(ROOTDIR)/runtime4/caml/*.tbl) \ - $(wildcard $(ROOTDIR)/runtime4/caml/*.h) +RUNTIME_HEADERS := $(wildcard $(ROOTDIR)/$(RUNTIME_DIR)/caml/*.tbl) \ + $(wildcard $(ROOTDIR)/$(RUNTIME_DIR)/caml/*.h) REQUIRED_HEADERS := $(RUNTIME_HEADERS) $(wildcard *.h) endif @@ -217,7 +217,7 @@ OCAMLYACCFLAGS ?= --strict -v %.ml %.mli: %.mly $(V_OCAMLYACC)$(OCAMLYACC) $(OCAMLYACCFLAGS) $< -SAK = $(ROOTDIR)/runtime4/sak$(EXE) +SAK = $(ROOTDIR)/$(RUNTIME_DIR)/sak$(EXE) # stdlib/StdlibModules cannot be include'd unless $(SAK) has been built. These # two rules add that dependency. They have to be pattern rules since diff --git a/ocaml/Makefile.common-jst b/ocaml/Makefile.common-jst index 9c6688d122a..1c65adca01e 100644 --- a/ocaml/Makefile.common-jst +++ b/ocaml/Makefile.common-jst @@ -63,23 +63,23 @@ boot_targets = \ $(boot_ocamlobjinfo) boot-compiler: _build/_bootinstall - $(dune) build $(ws_boot) $(coverage_dune_flags) $(boot_targets) + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) $(coverage_dune_flags) $(boot_targets) boot-runtest: boot-compiler - $(dune) runtest $(ws_boot) $(coverage_dune_flags) --force + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) runtest $(ws_boot) $(coverage_dune_flags) --force runtime-stdlib: boot-compiler - $(dune) build $(ws_runstd) --only-package=ocaml_runtime_stdlib @install + 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 compiler: runtime-stdlib - $(dune) build $(ws_main) --only-package=ocaml @install \ + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_main) --only-package=ocaml @install \ $(ocamldir)/ocamltest/ocamltest.byte \ $(ocamldir)/tools/dumpobj.bc runtest: compiler - $(dune) runtest $(ws_main) + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) runtest $(ws_main) # This Makefile supports old versions that don't have $(file), so we're using @@ -109,7 +109,15 @@ dune_config_targets = \ $(ocamldir)/duneconf/dirs-to-ignore.inc \ $(ocamldir)/duneconf/jst-extra.inc \ dune-project \ - $(ocamldir)/stdlib/ocaml_compiler_internal_params + $(ocamldir)/stdlib/ocaml_compiler_internal_params \ + $(ocamldir)/dune.runtime_selection + +$(ocamldir)/dune.runtime_selection: + if [ "$(RUNTIME_DIR)" = "runtime4" ]; then \ + echo "(dirs (:standard \ runtime))" > $@; \ + else \ + echo "(dirs (:standard \ runtime4))" > $@; \ + fi _build/_bootinstall: Makefile.config $(dune_config_targets) echo -n '$(NATDYNLINKOPTS)' > $(ocamldir)/otherlibs/dynlink/natdynlinkops @@ -227,9 +235,9 @@ install_for_test: _install touch ocamlc.opt ocamlopt.opt; \ done; \ ln -s _install/lib/ocaml stdlib; \ - mkdir runtime4; \ - for f in ocamlrun* stdlib/caml stdlib/stublibs/* runtime4/caml/threads.h; do \ - ln -s ../$$f runtime4/`basename $$f`; \ + mkdir $(RUNTIME_DIR); \ + for f in ocamlrun* stdlib/caml stdlib/stublibs/* $(RUNTIME_DIR)/caml/threads.h; do \ + ln -s ../$$f $(RUNTIME_DIR)/`basename $$f`; \ done; \ ln -s . lex; ln -s . yacc; \ ln -s _install/lib/ocaml/compiler-libs compilerlibs; \ @@ -358,7 +366,7 @@ promote-one-no-rebuild: # This target is like a polling version of upstream "make ocamlopt" .PHONY: hacking hacking: _build/_bootinstall - $(dune) build $(ws_boot) -w $(boot_targets) + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) -w $(boot_targets) # The `hacking-emacs-poller` and `hacking-emacs-builder` targets make it # possible to run the polling build with Emacs's `M-x compile`. You should run @@ -368,7 +376,7 @@ hacking: _build/_bootinstall .PHONY: hacking-emacs-poller hacking-emacs-poller: _build/_bootinstall - $(dune) build $(ws_boot) --passive-watch-mode + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_boot) --passive-watch-mode .PHONY: hacking-emacs-builder hacking-emacs-builder: _build/_bootinstall @@ -377,7 +385,7 @@ hacking-emacs-builder: _build/_bootinstall .PHONY: debug-printers debug-printers: runtime-stdlib # required for $(ws_main) to work - $(dune) build $(ws_main) $(ocamldir)/tools/debug_printers + RUNTIME_DIR=$(RUNTIME_DIR) $(dune) build $(ws_main) $(ocamldir)/tools/debug_printers @echo @echo To load into ocamldebug, use: @echo source \"$$(realpath _build/main/$(ocamldir)/tools/debug_printers)\" diff --git a/ocaml/Makefile.config.in b/ocaml/Makefile.config.in index 2d0939937ac..1fd3dfd7fae 100644 --- a/ocaml/Makefile.config.in +++ b/ocaml/Makefile.config.in @@ -243,6 +243,14 @@ STACK_ALLOCATION=@stack_allocation@ POLL_INSERTION=@poll_insertion@ DUNE=@dune@ +# Selection of OCaml 4.x or 5.x runtime +ifeq "@enable_runtime5@" "yes" + RUNTIME_SUFFIX= +else + RUNTIME_SUFFIX=4 +endif +RUNTIME_DIR=runtime$(RUNTIME_SUFFIX) + # Deprecated variables ## Variables deprecated since OCaml 5.0 diff --git a/ocaml/VERSION b/ocaml/VERSION index 3736ffcb307..03748534100 100644 --- a/ocaml/VERSION +++ b/ocaml/VERSION @@ -1,4 +1,4 @@ -5.1.1+jst-runtime4 +5.1.1+jst # Starting with OCaml 4.14, although the version string that appears above is # still correct and this file can thus still be used to figure it out, diff --git a/ocaml/asmcomp/amd64/emit.mlp b/ocaml/asmcomp/amd64/emit.mlp index 21f75323a90..17f725916b9 100644 --- a/ocaml/asmcomp/amd64/emit.mlp +++ b/ocaml/asmcomp/amd64/emit.mlp @@ -1093,12 +1093,12 @@ let emit_instr env fallthrough i = load_label_addr lbl_handler r11; I.push r11; cfi_adjust_cfa_offset 8; - I.push (domain_field Domainstate.Domain_exception_pointer); + I.push (domain_field Domainstate.Domain_exn_handler); cfi_adjust_cfa_offset 8; - I.mov rsp (domain_field Domainstate.Domain_exception_pointer); + I.mov rsp (domain_field Domainstate.Domain_exn_handler); env.stack_offset <- env.stack_offset + 16; | Lpoptrap -> - I.pop (domain_field Domainstate.Domain_exception_pointer); + I.pop (domain_field Domainstate.Domain_exn_handler); cfi_adjust_cfa_offset (-8); I.add (int 8) rsp; cfi_adjust_cfa_offset (-8); @@ -1113,8 +1113,8 @@ let emit_instr env fallthrough i = emit_call "caml_raise_exn"; record_frame env Reg.Set.empty (Dbg_raise i.dbg) | Lambda.Raise_notrace -> - I.mov (domain_field Domainstate.Domain_exception_pointer) rsp; - I.pop (domain_field Domainstate.Domain_exception_pointer); + I.mov (domain_field Domainstate.Domain_exn_handler) rsp; + I.pop (domain_field Domainstate.Domain_exn_handler); I.pop r11; I.jmp r11 end diff --git a/ocaml/build-aux/ocaml_version.m4 b/ocaml/build-aux/ocaml_version.m4 index 5c26fabbef5..d7dfbbf3910 100644 --- a/ocaml/build-aux/ocaml_version.m4 +++ b/ocaml/build-aux/ocaml_version.m4 @@ -36,7 +36,7 @@ m4_define([OCAML__VERSION_MINOR], [1]) m4_define([OCAML__VERSION_PATCHLEVEL], [1]) # Note that the OCAML__VERSION_EXTRA string defined below is always empty # for officially-released versions of OCaml. -m4_define([OCAML__VERSION_EXTRA], [jst-runtime4]) +m4_define([OCAML__VERSION_EXTRA], [jst]) # The OCAML__VERSION_EXTRA_PREFIX macro defined below should be a # single character: diff --git a/ocaml/bytecomp/dune b/ocaml/bytecomp/dune index 6a689c33306..c49ce942cf7 100644 --- a/ocaml/bytecomp/dune +++ b/ocaml/bytecomp/dune @@ -15,7 +15,7 @@ (rule (targets opcodes.ml) (mode fallback) - (deps (:instr (file ../runtime4/caml/instruct.h))) + (deps (:instr (file ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml/instruct.h))) (action (bash "%{dep:../tools/make_opcodes.exe} -opcodes < %{instr} > %{targets}"))) diff --git a/ocaml/compilerlibs/Makefile.compilerlibs b/ocaml/compilerlibs/Makefile.compilerlibs index 42a978f0c5f..8d36efb7056 100644 --- a/ocaml/compilerlibs/Makefile.compilerlibs +++ b/ocaml/compilerlibs/Makefile.compilerlibs @@ -432,7 +432,7 @@ beforedepend:: utils/config_main.mli utils/config_boot.mli $(addprefix compilerlibs/,\ ocamlcommon.cma ocamlbytecomp.cma ocamloptcomp.cma ocamlmiddleend.cma \ ocamltoplevel.cma): \ - CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims runtime4/primitives + CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims $(RUNTIME_DIR)/primitives compilerlibs/ocamlcommon.cma: $(COMMON_CMI) $(ALL_CONFIG_CMO) $(COMMON) $(V_LINKC)$(CAMLC) -a -linkall -o $@ $(COMMON) diff --git a/ocaml/configure b/ocaml/configure index f1cd9c4a940..c732c15a344 100755 --- a/ocaml/configure +++ b/ocaml/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for OCaml 5.1.1+jst-runtime4. +# Generated by GNU Autoconf 2.71 for OCaml 5.1.1+jst. # # Report bugs to . # @@ -621,8 +621,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='OCaml' PACKAGE_TARNAME='ocaml' -PACKAGE_VERSION='5.1.1+jst-runtime4' -PACKAGE_STRING='OCaml 5.1.1+jst-runtime4' +PACKAGE_VERSION='5.1.1+jst' +PACKAGE_STRING='OCaml 5.1.1+jst' PACKAGE_BUGREPORT='caml-list@inria.fr' PACKAGE_URL='http://www.ocaml.org' @@ -857,6 +857,7 @@ VERSION default_build_target native_compiler CONFIGURE_ARGS +enable_runtime5 target_alias host_alias build_alias @@ -899,6 +900,7 @@ SHELL' ac_subst_files='' ac_user_opts=' enable_option_checking +enable_runtime5 with_dune enable_debug_runtime enable_debugger @@ -1514,7 +1516,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures OCaml 5.1.1+jst-runtime4 to adapt to many kinds of systems. +\`configure' configures OCaml 5.1.1+jst to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1581,7 +1583,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of OCaml 5.1.1+jst-runtime4:";; + short | recursive ) echo "Configuration of OCaml 5.1.1+jst:";; esac cat <<\_ACEOF @@ -1589,6 +1591,7 @@ Optional Features: --disable-option-checking ignore unrecognized --enable/--with options --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-runtime5 Use the OCaml 5 runtime --disable-debug-runtime do not build runtime with debugging support --enable-debugger build the debugger [default=auto] --disable-dependency-generation @@ -1751,7 +1754,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -OCaml configure 5.1.1+jst-runtime4 +OCaml configure 5.1.1+jst generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -2408,7 +2411,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by OCaml $as_me 5.1.1+jst-runtime4, which was +It was created by OCaml $as_me 5.1.1+jst, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -3164,8 +3167,8 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Configuring OCaml version 5.1.1+jst-runtime4" >&5 -printf "%s\n" "$as_me: Configuring OCaml version 5.1.1+jst-runtime4" >&6;} +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Configuring OCaml version 5.1.1+jst" >&5 +printf "%s\n" "$as_me: Configuring OCaml version 5.1.1+jst" >&6;} # Configuration variables @@ -3226,16 +3229,26 @@ ocamltest_unix_include="" ## Directory containing auxiliary scripts used during build +# Runtime selection + +# Check whether --enable-runtime5 was given. +if test ${enable_runtime5+y} +then : + enableval=$enable_runtime5; +fi + + ## Output variables -VERSION=5.1.1+jst-runtime4 + +VERSION=5.1.1+jst OCAML_DEVELOPMENT_VERSION=false -OCAML_RELEASE_EXTRA='Some (Plus, "jst-runtime4")' +OCAML_RELEASE_EXTRA='Some (Plus, "jst")' OCAML_VERSION_MAJOR=5 @@ -3243,7 +3256,7 @@ OCAML_VERSION_MINOR=1 OCAML_VERSION_PATCHLEVEL=1 -OCAML_VERSION_EXTRA=jst-runtime4 +OCAML_VERSION_EXTRA=jst OCAML_VERSION_SHORT=5.1 @@ -3393,18 +3406,25 @@ ac_config_files="$ac_config_files utils/config.generated.ml" ac_config_files="$ac_config_files tools/eventlog_metadata" -ac_config_headers="$ac_config_headers runtime/caml/m.h" +if test "x$enable_runtime5" = "xyes" +then : + ac_config_headers="$ac_config_headers runtime/caml/m.h" + + ac_config_headers="$ac_config_headers runtime/caml/s.h" + + ac_config_headers="$ac_config_headers runtime/caml/version.h" -ac_config_headers="$ac_config_headers runtime/caml/s.h" -ac_config_headers="$ac_config_headers runtime/caml/version.h" +else $as_nop + ac_config_headers="$ac_config_headers runtime4/caml/m.h" + + ac_config_headers="$ac_config_headers runtime4/caml/s.h" -ac_config_headers="$ac_config_headers runtime4/caml/m.h" + ac_config_headers="$ac_config_headers runtime4/caml/version.h" -ac_config_headers="$ac_config_headers runtime4/caml/s.h" -ac_config_headers="$ac_config_headers runtime4/caml/version.h" +fi ac_config_files="$ac_config_files compilerlibs/META" ac_config_files="$ac_config_files otherlibs/dynlink/META" @@ -3421,13 +3441,13 @@ printf "%s\n" "#define OCAML_VERSION_MINOR 1" >>confdefs.h printf "%s\n" "#define OCAML_VERSION_PATCHLEVEL 1" >>confdefs.h -printf "%s\n" "#define OCAML_VERSION_ADDITIONAL \"jst-runtime4\"" >>confdefs.h +printf "%s\n" "#define OCAML_VERSION_ADDITIONAL \"jst\"" >>confdefs.h - printf "%s\n" "#define OCAML_VERSION_EXTRA \"jst-runtime4\"" >>confdefs.h + printf "%s\n" "#define OCAML_VERSION_EXTRA \"jst\"" >>confdefs.h printf "%s\n" "#define OCAML_VERSION 50101" >>confdefs.h -printf "%s\n" "#define OCAML_VERSION_STRING \"5.1.1+jst-runtime4\"" >>confdefs.h +printf "%s\n" "#define OCAML_VERSION_STRING \"5.1.1+jst\"" >>confdefs.h # Works out how many "o"s are needed in quoted strings @@ -20737,7 +20757,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by OCaml $as_me 5.1.1+jst-runtime4, which was +This file was extended by OCaml $as_me 5.1.1+jst, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -20806,7 +20826,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -OCaml config.status 5.1.1+jst-runtime4 +OCaml config.status 5.1.1+jst configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff --git a/ocaml/configure.ac b/ocaml/configure.ac index a58d97cbcc8..d08b09731fc 100644 --- a/ocaml/configure.ac +++ b/ocaml/configure.ac @@ -84,8 +84,15 @@ AC_CONFIG_SRCDIR([runtime/interp.c]) ## Directory containing auxiliary scripts used during build AC_CONFIG_AUX_DIR([build-aux]) +# Runtime selection + +AC_ARG_ENABLE([runtime5], + [AS_HELP_STRING([--enable-runtime5], + [Use the OCaml 5 runtime])]) + ## Output variables +AC_SUBST([enable_runtime5]) AC_SUBST([CONFIGURE_ARGS]) AC_SUBST([native_compiler]) AC_SUBST([default_build_target]) @@ -235,12 +242,16 @@ AC_CONFIG_FILES([manual/src/html_processing/src/common.ml]) AC_CONFIG_FILES([ocamltest/ocamltest_config.ml]) AC_CONFIG_FILES([utils/config.generated.ml]) AC_CONFIG_FILES([tools/eventlog_metadata]) -AC_CONFIG_HEADERS([runtime/caml/m.h]) -AC_CONFIG_HEADERS([runtime/caml/s.h]) -AC_CONFIG_HEADERS([runtime/caml/version.h]) -AC_CONFIG_HEADERS([runtime4/caml/m.h]) -AC_CONFIG_HEADERS([runtime4/caml/s.h]) -AC_CONFIG_HEADERS([runtime4/caml/version.h]) +AS_IF([test "x$enable_runtime5" = "xyes"], + [ AC_CONFIG_HEADERS([runtime/caml/m.h]) + AC_CONFIG_HEADERS([runtime/caml/s.h]) + AC_CONFIG_HEADERS([runtime/caml/version.h]) + ], + [ AC_CONFIG_HEADERS([runtime4/caml/m.h]) + AC_CONFIG_HEADERS([runtime4/caml/s.h]) + AC_CONFIG_HEADERS([runtime4/caml/version.h]) + ] +) AC_CONFIG_FILES([compilerlibs/META]) AC_CONFIG_FILES([otherlibs/dynlink/META]) AC_CONFIG_FILES([otherlibs/runtime_events/META]) diff --git a/ocaml/dune b/ocaml/dune index 38dcff505cf..0772aa329f6 100644 --- a/ocaml/dune +++ b/ocaml/dune @@ -24,9 +24,7 @@ (flags (:standard -w +a-4-9-40-41-42-44-45-48-66-67-70 -warn-error +A)))) -; Disable the runtime/ directory for now -; (We're currently using runtime4/ instead) -(dirs (:standard \ runtime)) +(include dune.runtime_selection) (copy_files# utils/*.ml{,i}) (copy_files# parsing/*.ml{,i}) diff --git a/ocaml/lambda/dune b/ocaml/lambda/dune index d5e09a2eeae..b6ba2fee8f2 100644 --- a/ocaml/lambda/dune +++ b/ocaml/lambda/dune @@ -15,7 +15,7 @@ (rule (targets runtimedef.ml) (mode fallback) - (deps (:fail (file ../runtime4/caml/fail.h)) - (:prim (file ../runtime4/primitives))) + (deps (:fail (file ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml/fail.h)) + (:prim (file ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/primitives))) (action (with-stdout-to %{targets} (run ./generate_runtimedef.sh %{fail} %{prim})))) diff --git a/ocaml/otherlibs/systhreads/st_stubs.c b/ocaml/otherlibs/systhreads/st_stubs.c index a448ddddcaf..ace63ea0cd7 100644 --- a/ocaml/otherlibs/systhreads/st_stubs.c +++ b/ocaml/otherlibs/systhreads/st_stubs.c @@ -103,7 +103,7 @@ struct caml_thread_struct { char * bottom_of_stack; /* Saved value of Caml_state->_bottom_of_stack */ uintnat last_retaddr; /* Saved value of Caml_state->_last_return_address */ value * gc_regs; /* Saved value of Caml_state->_gc_regs */ - char * exception_pointer; /* Saved value of Caml_state->_exception_pointer */ + char * exn_handler; /* Saved value of Caml_state->_exn_handler */ char * async_exception_pointer; /* Saved value of Caml_state->_async_exception_pointer */ struct caml__roots_block * local_roots; /* Saved value of local_roots */ @@ -262,7 +262,7 @@ CAMLexport void caml_thread_save_runtime_state(void) curr_thread->bottom_of_stack = Caml_state->_bottom_of_stack; curr_thread->last_retaddr = Caml_state->_last_return_address; curr_thread->gc_regs = Caml_state->_gc_regs; - curr_thread->exception_pointer = Caml_state->_exception_pointer; + curr_thread->exn_handler = Caml_state->_exn_handler; curr_thread->async_exception_pointer = Caml_state->_async_exception_pointer; curr_thread->local_arenas = caml_get_local_arenas(); #else @@ -292,7 +292,7 @@ CAMLexport void caml_thread_restore_runtime_state(void) Caml_state->_bottom_of_stack= curr_thread->bottom_of_stack; Caml_state->_last_return_address = curr_thread->last_retaddr; Caml_state->_gc_regs = curr_thread->gc_regs; - Caml_state->_exception_pointer = curr_thread->exception_pointer; + Caml_state->_exn_handler = curr_thread->exn_handler; Caml_state->_async_exception_pointer = curr_thread->async_exception_pointer; caml_set_local_arenas(curr_thread->local_arenas); #else @@ -440,7 +440,7 @@ static caml_thread_t caml_thread_new_info(void) th->bottom_of_stack = NULL; th->top_of_stack = NULL; th->last_retaddr = 1; - th->exception_pointer = NULL; + th->exn_handler = NULL; th->async_exception_pointer = NULL; th->local_roots = NULL; th->local_arenas = NULL; diff --git a/ocaml/runtime/caml/domain_state.tbl b/ocaml/runtime/caml/domain_state.tbl index 3c1760fa3ac..8a16039bd22 100644 --- a/ocaml/runtime/caml/domain_state.tbl +++ b/ocaml/runtime/caml/domain_state.tbl @@ -37,6 +37,12 @@ DOMAIN_STATE(struct stack_info*, current_stack) DOMAIN_STATE(void*, exn_handler) /* Pointer into the current stack */ +/* Local allocations */ +DOMAIN_STATE(struct caml_local_arenas*, local_arenas) +DOMAIN_STATE(intnat, local_sp) +DOMAIN_STATE(void*, local_top) +DOMAIN_STATE(intnat, local_limit) + DOMAIN_STATE(int, action_pending) /* Whether we are due to start the processing of delayable pending actions. See runtime/signal.c. */ diff --git a/ocaml/runtime/caml/exec.h b/ocaml/runtime/caml/exec.h index 6d5ed7d7858..9831e815592 100644 --- a/ocaml/runtime/caml/exec.h +++ b/ocaml/runtime/caml/exec.h @@ -60,7 +60,7 @@ struct exec_trailer { /* Magic number for this release */ -#define EXEC_MAGIC "Caml1999X033" +#define EXEC_MAGIC "Caml1999X520" #endif /* CAML_INTERNALS */ diff --git a/ocaml/runtime/dune b/ocaml/runtime/dune index e83c6820d32..9c7f70e2d92 100644 --- a/ocaml/runtime/dune +++ b/ocaml/runtime/dune @@ -16,56 +16,78 @@ (targets primitives) (mode fallback) (deps - ; matches the line structure of files in gen_primitives.sh - 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 memprof.c obj.c parsing.c signals.c str.c sys.c - callback.c weak.c - finalise.c dynlink.c backtrace_byt.c backtrace.c - afl.c - bigarray.c runtime_events.c) - (action (with-stdout-to %{targets} (run %{dep:gen_primitives.sh})))) + ; matches the line structure of files in gen_primitives.sh + 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 memprof.c obj.c parsing.c signals.c str.c sys.c callback.c weak.c + finalise.c domain.c platform.c fiber.c memory.c startup_aux.c runtime_events.c sync.c + dynlink.c backtrace_byt.c backtrace.c afl.c + bigarray.c prng.c win32.c + ) + (action (with-stdout-to %{targets} + (chdir .. (run %{dep:gen_primitives.sh}))))) (rule - (targets libcamlrun.a) + (targets libasmrun.a libasmrund.a libasmruni.a libasmrun_pic.a + libasmrun_shared.so libcamlrun.a libcamlrund.a libcamlruni.a libcamlrun_pic.a + libcamlrun_shared.so ocamlrun ocamlrund ocamlruni ld.conf + sak) (mode fallback) (deps ../Makefile.config ../Makefile.build_config ../Makefile.config_if_required - ../Makefile.common Makefile + ../Makefile.common ../Makefile + ../compilerlibs/Makefile.compilerlibs + ../Makefile.menhir + ../.depend + ../.depend.menhir + ../config.status (glob_files caml/*.h) - ; matches the line structure of files in Makefile/BYTECODE_C_SOURCES - interp.c misc.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 - afl.c unix.c win32.c bigarray.c main.c memprof.c domain.c - skiplist.c codefrag.c + (glob_files *.h) + caml/domain_state.tbl + primitives + (glob_files *.S) + (glob_files *.c) ) (action + (no-infer (progn (bash "touch .depend") ; hack. - (run make %{targets} COMPUTE_DEPS=false) - (bash "rm .depend")))) + (bash "cd .. && make V=1 'SAK_LINK=cc -o $(1) $(2)' COMPUTE_DEPS=false runtime/sak") + (bash "cd .. && make V=1 -sj8 runtime/libasmrun.a runtime/libasmrund.a runtime/libasmruni.a runtime/libasmrun_pic.a \ + runtime/libasmrun_shared.so runtime/libcamlrun.a runtime/libcamlrund.a runtime/libcamlruni.a runtime/libcamlrun_pic.a \ + runtime/libcamlrun_shared.so runtime/ocamlrun runtime/ocamlrund runtime/ocamlruni runtime/ld.conf COMPUTE_DEPS=false") + (bash "rm .depend"))))) -;; HACK -(library - (name runtime) - (modes byte) - (wrapped false) - (modules runtime) - (flags (-nostdlib -nopervasives)) - (library_flags -cclib "-I runtime") - (self_build_stubs_archive (runtime))) +(install + (files + ocamlrun + ocamlrund + ocamlruni + ) + (section bin) + (package ocaml_runtime_stdlib)) -(rule - (targets libruntime_stubs.a) - (action (copy libcamlrun.a %{targets}))) +(install + (files + ld.conf -(rule - (targets runtime.ml) - (action (write-file %{targets} "let linkme = ()"))) + libcamlrun.a + libcamlrund.a + libcamlruni.a + libcamlrun_pic.a + libcamlrun_shared.so + ) + (section lib) + (package ocaml_runtime_stdlib)) + +(install + (files + libasmrun.a + libasmrund.a + libasmruni.a + libasmrun_pic.a + libasmrun_shared.so + ) + (section lib) + (package ocaml_runtime_stdlib)) diff --git a/ocaml/runtime/startup_aux.c b/ocaml/runtime/startup_aux.c index dc659f407f4..3829bbb9747 100644 --- a/ocaml/runtime/startup_aux.c +++ b/ocaml/runtime/startup_aux.c @@ -1,3 +1,5 @@ +/* CR mshinwell: Reverted to 5.x version, need to check conflicts */ + /**************************************************************************/ /* */ /* OCaml */ @@ -95,47 +97,6 @@ void caml_parse_ocamlrunparam(void) if (opt != NULL){ while (*opt != '\0'){ switch (*opt++){ -<<<<<<< HEAD - case 'a': scanmult (opt, &caml_init_policy); break; - case 'b': scanmult (opt, &p); caml_record_backtraces(p); break; - case 'c': scanmult (opt, &p); caml_cleanup_on_exit = (p != 0); break; - case 'h': scanmult (opt, &caml_init_heap_wsz); break; - case 'H': scanmult (opt, &caml_use_huge_pages); break; - case 'i': scanmult (opt, &caml_init_heap_chunk_sz); break; - case 'l': scanmult (opt, &caml_init_max_stack_wsz); break; - case 'M': scanmult (opt, &caml_init_custom_major_ratio); break; - case 'm': scanmult (opt, &caml_init_custom_minor_ratio); break; - case 'n': scanmult (opt, &caml_init_custom_minor_max_bsz); break; - case 'o': scanmult (opt, &caml_init_percent_free); break; - case 'O': scanmult (opt, &caml_init_max_percent_free); break; - case 'p': scanmult (opt, &p); caml_parser_trace = (p != 0); break; -||||||| merged common ancestors -<<<<<<<<< Temporary merge branch 1 - case 'a': scanmult (opt, &p); caml_set_allocation_policy ((intnat) p); - break; - case 'b': scanmult (opt, &p); caml_record_backtrace(Val_int (p)); - break; -||||||||| 24dbb0976a - case 'a': scanmult (opt, &p); caml_set_allocation_policy ((intnat) p); - break; - case 'b': scanmult (opt, &p); caml_record_backtrace(Val_bool (p)); - break; -========= - case 'a': scanmult (opt, &caml_init_policy); break; - case 'b': scanmult (opt, &p); caml_record_backtraces(p); break; ->>>>>>>>> Temporary merge branch 2 - case 'c': scanmult (opt, &p); caml_cleanup_on_exit = (p != 0); break; - case 'h': scanmult (opt, &caml_init_heap_wsz); break; - case 'H': scanmult (opt, &caml_use_huge_pages); break; - case 'i': scanmult (opt, &caml_init_heap_chunk_sz); break; - case 'l': scanmult (opt, &caml_init_max_stack_wsz); break; - case 'M': scanmult (opt, &caml_init_custom_major_ratio); break; - case 'm': scanmult (opt, &caml_init_custom_minor_ratio); break; - case 'n': scanmult (opt, &caml_init_custom_minor_max_bsz); break; - case 'o': scanmult (opt, &caml_init_percent_free); break; - case 'O': scanmult (opt, &caml_init_max_percent_free); break; - case 'p': scanmult (opt, &p); caml_parser_trace = (p != 0); break; -======= case 'b': scanmult (opt, ¶ms.backtrace_enabled); break; case 'c': scanmult (opt, ¶ms.cleanup_on_exit); break; case 'e': scanmult (opt, ¶ms.runtime_events_log_wsize); break; @@ -145,7 +106,6 @@ void caml_parse_ocamlrunparam(void) case 'n': scanmult (opt, ¶ms.init_custom_minor_max_bsz); break; case 'o': scanmult (opt, ¶ms.init_percent_free); break; case 'p': scanmult (opt, ¶ms.parser_trace); break; ->>>>>>> ocaml/5.1 case 'R': break; /* see stdlib/hashtbl.mli */ case 's': scanmult (opt, ¶ms.init_minor_heap_wsz); break; case 't': scanmult (opt, ¶ms.trace_level); break; diff --git a/ocaml/runtime/sync_posix.h b/ocaml/runtime/sync_posix.h index 52969d88bb4..7ef3bd241bc 100644 --- a/ocaml/runtime/sync_posix.h +++ b/ocaml/runtime/sync_posix.h @@ -84,16 +84,16 @@ Caml_inline int sync_mutex_unlock(sync_mutex m) /* Condition variables */ -typedef custom_condvar * sync_condvar; +typedef pthread_cond_t * sync_condvar; #define Condition_val(v) (* (sync_condvar *) Data_custom_val(v)) Caml_inline int sync_condvar_create(sync_condvar * res) { int rc; - sync_condvar c = caml_stat_alloc_noexc(sizeof(custom_condvar)); + sync_condvar c = caml_stat_alloc_noexc(sizeof(pthread_cond_t)); if (c == NULL) return ENOMEM; - rc = custom_condvar_init(c); + rc = pthread_cond_init(c, NULL); if (rc != 0) { caml_stat_free(c); return rc; } *res = c; return 0; @@ -102,24 +102,24 @@ Caml_inline int sync_condvar_create(sync_condvar * res) Caml_inline int sync_condvar_destroy(sync_condvar c) { int rc; - rc = custom_cond_destroy(c); + rc = pthread_cond_destroy(c); caml_stat_free(c); return rc; } Caml_inline int sync_condvar_signal(sync_condvar c) { - return custom_cond_signal(c); + return pthread_cond_signal(c); } Caml_inline int sync_condvar_broadcast(sync_condvar c) { - return custom_cond_broadcast(c); + return pthread_cond_broadcast(c); } Caml_inline int sync_condvar_wait(sync_condvar c, sync_mutex m) { - return custom_cond_wait(c, m); + return pthread_cond_wait(c, m); } /* Reporting errors */ diff --git a/ocaml/runtime/weak.c b/ocaml/runtime/weak.c index be5663bc4e8..b6fe9cb5eef 100644 --- a/ocaml/runtime/weak.c +++ b/ocaml/runtime/weak.c @@ -1,3 +1,5 @@ +/* CR mshinwell: Reverted to 5.x version, need to check conflicts */ + /**************************************************************************/ /* */ /* OCaml */ @@ -43,118 +45,8 @@ struct caml_ephe_info* caml_alloc_ephe_info (void) return e; } -<<<<<<< HEAD -/* The minor heap is considered alive. Outside minor and major heap it is - considered alive (out of reach of the GC). */ -Caml_inline int Test_if_its_white(value x){ - CAMLassert (x != caml_ephe_none); -#ifdef NO_NAKED_POINTERS - if (!Is_block(x) || Is_young (x)) return 0; -#else - if (!Is_block(x) || !Is_in_heap(x)) return 0; -#endif - if (Tag_val(x) == Infix_tag) x -= Infix_offset_val(x); - return Is_white_val(x); -} - -/* If it is not white during clean phase it is dead, i.e it will be swept */ -Caml_inline int Is_Dead_during_clean(value x) -{ - CAMLassert (caml_gc_phase == Phase_clean); - return Test_if_its_white(x); -} - -/** caml_ephe_none is considered as not white */ -Caml_inline int Is_White_During_Mark(value x) -{ - CAMLassert (caml_gc_phase == Phase_mark); - if (x == caml_ephe_none ) return 0; - return Test_if_its_white(x); -} - -/** The minor heap doesn't have to be marked, outside they should - already be black. Remains the value in the heap to mark. -*/ -Caml_inline int Must_be_Marked_during_mark(value x) -{ - CAMLassert (x != caml_ephe_none); - CAMLassert (caml_gc_phase == Phase_mark); -#ifdef NO_NAKED_POINTERS - return Is_block (x) && !Is_young (x); -#else - return Is_block (x) && Is_in_heap (x); -#endif -} - -/* [len] is a number of words (fields) */ -CAMLexport value caml_ephemeron_create (mlsize_t len) -||||||| merged common ancestors -/* The minor heap is considered alive. Outside minor and major heap it is - considered alive (out of reach of the GC). */ -Caml_inline int Test_if_its_white(value x){ - CAMLassert (x != caml_ephe_none); -#ifdef NO_NAKED_POINTERS - if (!Is_block(x) || Is_young (x)) return 0; -#else - if (!Is_block(x) || !Is_in_heap(x)) return 0; -#endif - if (Tag_val(x) == Infix_tag) x -= Infix_offset_val(x); - return Is_white_val(x); -} - -/* If it is not white during clean phase it is dead, i.e it will be swept */ -Caml_inline int Is_Dead_during_clean(value x) -{ - CAMLassert (caml_gc_phase == Phase_clean); -<<<<<<<<< Temporary merge branch 1 -#ifdef NO_NAKED_POINTERS - if (!Is_block(x) || Is_young (x)) return 0; -#else - if (!Is_block(x) || !Is_in_heap(x)) return 0; -#endif - if (Tag_val(x) == Infix_tag) x -= Infix_offset_val(x); - return Is_white_val(x); -||||||||| 24dbb0976a - if (!Is_block(x)) return 0; - if (Tag_val(x) == Infix_tag) x -= Infix_offset_val(x); -#ifdef NO_NAKED_POINTERS - return Is_white_val(x) && !Is_young (x); -#else - return Is_white_val(x) && Is_in_heap (x); -#endif -========= - return Test_if_its_white(x); ->>>>>>>>> Temporary merge branch 2 -} - -/** caml_ephe_none is considered as not white */ -Caml_inline int Is_White_During_Mark(value x) -{ - CAMLassert (caml_gc_phase == Phase_mark); - if (x == caml_ephe_none ) return 0; - return Test_if_its_white(x); -} - -/** The minor heap doesn't have to be marked, outside they should - already be black. Remains the value in the heap to mark. -*/ -Caml_inline int Must_be_Marked_during_mark(value x) -{ - CAMLassert (x != caml_ephe_none); - CAMLassert (caml_gc_phase == Phase_mark); -#ifdef NO_NAKED_POINTERS - return Is_block (x) && !Is_young (x); -#else - return Is_block (x) && Is_in_heap (x); -#endif -} - -/* [len] is a number of words (fields) */ -CAMLexport value caml_ephemeron_create (mlsize_t len) -======= /* [len] is a value that represents a number of words (fields) */ CAMLprim value caml_ephe_create (value len) ->>>>>>> ocaml/5.1 { mlsize_t size, i; value res; diff --git a/ocaml/runtime4/amd64.S b/ocaml/runtime4/amd64.S index d24629949fb..590554d17f6 100644 --- a/ocaml/runtime4/amd64.S +++ b/ocaml/runtime4/amd64.S @@ -586,14 +586,14 @@ LBL(caml_start_program): /* Build an exception handler */ lea LBL(108)(%rip), %r13 pushq %r13; CFI_ADJUST(8) - pushq Caml_state(exception_pointer); CFI_ADJUST(8) - movq %rsp, Caml_state(exception_pointer) + pushq Caml_state(exn_handler); CFI_ADJUST(8) + movq %rsp, Caml_state(exn_handler) movq %rsp, Caml_state(async_exception_pointer) /* Call the OCaml code */ call *%r12 LBL(107): /* Pop the exception handler */ - popq Caml_state(exception_pointer); CFI_ADJUST(-8) + popq Caml_state(exn_handler); CFI_ADJUST(-8) popq %r12; CFI_ADJUST(-8) /* dummy register */ LBL(109): /* Update alloc ptr */ @@ -621,8 +621,8 @@ FUNCTION(G(caml_raise_exn)) CFI_STARTPROC testq $1, Caml_state(backtrace_active) jne LBL(110) - movq Caml_state(exception_pointer), %rsp - popq Caml_state(exception_pointer); CFI_ADJUST(-8) + movq Caml_state(exn_handler), %rsp + popq Caml_state(exn_handler); CFI_ADJUST(-8) ret LBL(110): movq %rax, %r12 /* Save exception bucket */ @@ -636,14 +636,14 @@ LBL(110): movq %rsp, C_ARG_3 /* arg 3: sp at raise */ #endif /* arg 4: sp of handler */ - movq Caml_state(exception_pointer), C_ARG_4 + movq Caml_state(exn_handler), C_ARG_4 /* PR#5700: thanks to popq above, stack is now 16-aligned */ /* Thanks to ENTER_FUNCTION, stack is now 16-aligned */ PREPARE_FOR_C_CALL /* no need to cleanup after */ call GCALL(caml_stash_backtrace) movq %r12, %rax /* Recover exception bucket */ - movq Caml_state(exception_pointer), %rsp - popq Caml_state(exception_pointer); CFI_ADJUST(-8) + movq Caml_state(exn_handler), %rsp + popq Caml_state(exn_handler); CFI_ADJUST(-8) ret CFI_ENDPROC ENDFUNCTION(G(caml_raise_exn)) @@ -656,9 +656,9 @@ CFI_STARTPROC testq $1, Caml_state(backtrace_active) jne LBL(112) movq C_ARG_2, %rax - movq Caml_state(exception_pointer), %rsp /* Cut stack */ + movq Caml_state(exn_handler), %rsp /* Cut stack */ /* Recover previous exception handler */ - popq Caml_state(exception_pointer); CFI_ADJUST(-8) + popq Caml_state(exn_handler); CFI_ADJUST(-8) movq Caml_state(young_ptr), %r15 /* Reload alloc ptr */ ret LBL(112): @@ -674,16 +674,16 @@ LBL(112): /* arg 3: sp of raise */ movq Caml_state(bottom_of_stack), C_ARG_3 /* arg 4: sp of handler */ - movq Caml_state(exception_pointer), C_ARG_4 + movq Caml_state(exn_handler), C_ARG_4 #ifndef WITH_FRAME_POINTERS subq $8, %rsp /* PR#5700: maintain stack alignment */ #endif PREPARE_FOR_C_CALL /* no need to cleanup after */ call GCALL(caml_stash_backtrace) movq %r12, %rax /* Recover exception bucket */ - movq Caml_state(exception_pointer), %rsp + movq Caml_state(exn_handler), %rsp /* Recover previous exception handler */ - popq Caml_state(exception_pointer); CFI_ADJUST(-8) + popq Caml_state(exn_handler); CFI_ADJUST(-8) movq Caml_state(young_ptr), %r15 /* Reload alloc ptr */ ret CFI_ENDPROC @@ -700,7 +700,7 @@ FUNCTION(G(caml_stack_overflow)) LEA_VAR(caml_exn_Stack_overflow, %rax) movq Caml_state(async_exception_pointer), %rsp /* cut the stack */ /* Recover previous exn handler */ - popq Caml_state(exception_pointer) + popq Caml_state(exn_handler) ret /* jump to handler's code */ ENDFUNCTION(G(caml_stack_overflow)) diff --git a/ocaml/runtime4/arm.S b/ocaml/runtime4/arm.S index 4e7adb9985e..a5752e397c7 100644 --- a/ocaml/runtime4/arm.S +++ b/ocaml/runtime4/arm.S @@ -159,7 +159,7 @@ FUNCTION(caml_call_gc) /* Save current allocation pointer for debugging purposes */ str alloc_ptr, Caml_state(young_ptr) /* Save trap pointer in case an exception is raised during GC */ - str trap_ptr, Caml_state(exception_pointer) + str trap_ptr, Caml_state(exn_handler) /* Call the garbage collector */ bl caml_garbage_collection /* Restore integer registers and return address from the stack */ @@ -228,7 +228,7 @@ FUNCTION(caml_c_call) CFI_REGISTER(lr, r4) /* Make the exception handler alloc ptr available to the C code */ str alloc_ptr, Caml_state(young_ptr) - str trap_ptr, Caml_state(exception_pointer) + str trap_ptr, Caml_state(exn_handler) /* Call the function */ blx r7 /* Reload alloc ptr */ @@ -273,7 +273,7 @@ FUNCTION(caml_start_program) /* Setup a trap frame to catch exceptions escaping the OCaml code */ sub sp, sp, 8; CFI_ADJUST(8) ldr r5, =.Ltrap_handler - ldr r4, Caml_state(exception_pointer) + ldr r4, Caml_state(exn_handler) str r4, [sp, 0] str r5, [sp, 4] mov trap_ptr, sp @@ -282,9 +282,9 @@ FUNCTION(caml_start_program) /* Call the OCaml code */ blx r12 .Lcaml_retaddr: - /* Pop the trap frame, restoring caml_exception_pointer */ + /* Pop the trap frame, restoring caml_exn_handler */ ldr r5, [sp, 0] - str r5, Caml_state(exception_pointer) + str r5, Caml_state(exn_handler) add sp, sp, 8; CFI_ADJUST(-8) /* Pop the callback link, restoring the global variables */ .Lreturn_result: @@ -315,7 +315,7 @@ FUNCTION(caml_start_program) .Ltrap_handler: CFI_STARTPROC /* Save exception pointer */ - str trap_ptr, Caml_state(exception_pointer) + str trap_ptr, Caml_state(exn_handler) /* Encode exception bucket as an exception result */ orr r0, r0, 2 /* Return it */ @@ -356,7 +356,7 @@ FUNCTION(caml_raise_exception) /* Load exception bucket */ mov r0, r1 /* Reload trap ptr and alloc ptr */ - ldr trap_ptr, Caml_state(exception_pointer) + ldr trap_ptr, Caml_state(exn_handler) ldr alloc_ptr, Caml_state(young_ptr) /* Test if backtrace is active */ ldr r1, Caml_state(backtrace_active) diff --git a/ocaml/runtime4/arm64.S b/ocaml/runtime4/arm64.S index e92d13e1be8..36a248644a6 100644 --- a/ocaml/runtime4/arm64.S +++ b/ocaml/runtime4/arm64.S @@ -204,7 +204,7 @@ L(caml_call_gc): /* Save current allocation pointer for debugging purposes */ str ALLOC_PTR, Caml_state(young_ptr) /* Save trap pointer in case an exception is raised during GC */ - str TRAP_PTR, Caml_state(exception_pointer) + str TRAP_PTR, Caml_state(exn_handler) /* Call the garbage collector */ bl G(caml_garbage_collection) /* Restore registers */ @@ -294,7 +294,7 @@ FUNCTION(caml_c_call) str TMP, Caml_state(bottom_of_stack) /* Make the exception handler alloc ptr available to the C code */ str ALLOC_PTR, Caml_state(young_ptr) - str TRAP_PTR, Caml_state(exception_pointer) + str TRAP_PTR, Caml_state(exn_handler) /* Call the function */ blr ADDITIONAL_ARG /* Reload alloc ptr */ @@ -342,7 +342,7 @@ L(jump_to_caml): CFI_ADJUST(32) str x10, [sp, 16] /* Setup a trap frame to catch exceptions escaping the OCaml code */ - ldr x8, Caml_state(exception_pointer) + ldr x8, Caml_state(exn_handler) adr x9, L(trap_handler) stp x8, x9, [sp, -16]! CFI_ADJUST(16) @@ -352,10 +352,10 @@ L(jump_to_caml): /* Call the OCaml code */ blr TMP2 L(caml_retaddr): - /* Pop the trap frame, restoring caml_exception_pointer */ + /* Pop the trap frame, restoring caml_exn_handler */ ldr x8, [sp], 16 CFI_ADJUST(-16) - str x8, Caml_state(exception_pointer) + str x8, Caml_state(exn_handler) /* Pop the callback link, restoring the global variables */ L(return_result): ldr x10, [sp, 16] @@ -389,7 +389,7 @@ L(return_result): L(trap_handler): CFI_STARTPROC /* Save exception pointer */ - str TRAP_PTR, Caml_state(exception_pointer) + str TRAP_PTR, Caml_state(exn_handler) /* Encode exception bucket as an exception result */ orr x0, x0, #2 /* Return it */ @@ -432,7 +432,7 @@ FUNCTION(caml_raise_exception) /* Load the exception bucket */ mov x0, C_ARG_2 /* Reload trap ptr and alloc ptr */ - ldr TRAP_PTR, Caml_state(exception_pointer) + ldr TRAP_PTR, Caml_state(exn_handler) ldr ALLOC_PTR, Caml_state(young_ptr) /* Test if backtrace is active */ ldr TMP, Caml_state(backtrace_active) diff --git a/ocaml/runtime4/caml/domain_state.tbl b/ocaml/runtime4/caml/domain_state.tbl index 0666a09f999..107d48bb71f 100644 --- a/ocaml/runtime4/caml/domain_state.tbl +++ b/ocaml/runtime4/caml/domain_state.tbl @@ -18,8 +18,10 @@ DOMAIN_STATE(value*, young_limit) DOMAIN_STATE(value*, young_ptr) /* Minor heap limit. See minor_gc.c. */ -DOMAIN_STATE(char*, exception_pointer) +DOMAIN_STATE(char*, exn_handler) /* Exception pointer that points into the current stack */ +/* This was called [exception_pointer] before but has been renamed to + match the 5.x runtime */ DOMAIN_STATE(char*, async_exception_pointer) /* Async exception pointer that points into the current stack */ diff --git a/ocaml/runtime4/domain.c b/ocaml/runtime4/domain.c index f6b9ce8cdb8..839c54de25b 100644 --- a/ocaml/runtime4/domain.c +++ b/ocaml/runtime4/domain.c @@ -32,7 +32,7 @@ void caml_init_domain () caml_fatal_error ("cannot initialize domain state"); Caml_state->young_limit = NULL; - Caml_state->exception_pointer = NULL; + Caml_state->exn_handler = NULL; Caml_state->young_ptr = NULL; Caml_state->young_base = NULL; diff --git a/ocaml/runtime4/fail_nat.c b/ocaml/runtime4/fail_nat.c index 7f2759bce10..911c17406bf 100644 --- a/ocaml/runtime4/fail_nat.c +++ b/ocaml/runtime4/fail_nat.c @@ -58,10 +58,10 @@ CAMLnoreturn_start extern void caml_raise_exception (caml_domain_state* state, value bucket) CAMLnoreturn_end; -static void unwind_local_roots(char *exception_pointer) +static void unwind_local_roots(char *exn_handler) { while (Caml_state->local_roots != NULL && - (char *)Caml_state->local_roots < exception_pointer) + (char *)Caml_state->local_roots < exn_handler) { Caml_state->local_roots = Caml_state->local_roots->next; } @@ -77,12 +77,12 @@ void caml_raise(value v) a blocking call has a chance to interrupt the raising of EINTR */ v = caml_process_pending_actions_with_root(v); - if (Caml_state->exception_pointer == NULL) { + if (Caml_state->exn_handler == NULL) { caml_terminate_signals(); caml_fatal_uncaught_exception(v); } - unwind_local_roots(Caml_state->exception_pointer); + unwind_local_roots(Caml_state->exn_handler); caml_raise_exception(Caml_state, v); } @@ -102,7 +102,7 @@ CAMLno_asan void caml_raise_async(value v) caml_fatal_uncaught_exception(v); unwind_local_roots(Caml_state->async_exception_pointer); - Caml_state->exception_pointer = Caml_state->async_exception_pointer; + Caml_state->exn_handler = Caml_state->async_exception_pointer; Caml_state->raising_async_exn = 1; caml_raise_exception(Caml_state, v); } diff --git a/ocaml/runtime4/i386.S b/ocaml/runtime4/i386.S index cd1fb6976a1..a5bfa494e9e 100644 --- a/ocaml/runtime4/i386.S +++ b/ocaml/runtime4/i386.S @@ -285,15 +285,15 @@ LBL(106): /* Build an exception handler */ pushl $ LBL(108); CFI_ADJUST(4) ALIGN_STACK(8) - pushl CAML_STATE(exception_pointer, %edi); CFI_ADJUST(4) - movl %esp, CAML_STATE(exception_pointer, %edi) + pushl CAML_STATE(exn_handler, %edi); CFI_ADJUST(4) + movl %esp, CAML_STATE(exn_handler, %edi) movl %esp, CAML_STATE(async_exception_pointer, %edi) /* Call the OCaml code */ call *%esi LBL(107): movl G(Caml_state), %edi /* Pop the exception handler */ - popl CAML_STATE(exception_pointer, %edi); CFI_ADJUST(-4) + popl CAML_STATE(exn_handler, %edi); CFI_ADJUST(-4) addl $12, %esp ; CFI_ADJUST(-12) LBL(109): movl G(Caml_state), %edi /* Reload for LBL(109) entry */ @@ -325,13 +325,13 @@ FUNCTION(caml_raise_exn) movl G(Caml_state), %ebx testl $1, CAML_STATE(backtrace_active, %ebx) jne LBL(110) - movl CAML_STATE(exception_pointer, %ebx), %esp - popl CAML_STATE(exception_pointer, %ebx); CFI_ADJUST(-4) + movl CAML_STATE(exn_handler, %ebx), %esp + popl CAML_STATE(exn_handler, %ebx); CFI_ADJUST(-4) UNDO_ALIGN_STACK(8) ret LBL(110): movl %eax, %esi /* Save exception bucket in esi */ - movl CAML_STATE(exception_pointer, %ebx), %edi /* SP of handler */ + movl CAML_STATE(exn_handler, %ebx), %edi /* SP of handler */ movl 0(%esp), %eax /* PC of raise */ leal 4(%esp), %edx /* SP of raise */ ALIGN_STACK(12) @@ -342,7 +342,7 @@ LBL(110): call G(caml_stash_backtrace) movl %esi, %eax /* Recover exception bucket */ movl %edi, %esp - popl CAML_STATE(exception_pointer, %ebx); CFI_ADJUST(-4) + popl CAML_STATE(exn_handler, %ebx); CFI_ADJUST(-4) UNDO_ALIGN_STACK(8) ret CFI_ENDPROC @@ -356,15 +356,15 @@ FUNCTION(caml_raise_exception) testl $1, CAML_STATE(backtrace_active, %ebx) jne LBL(112) movl 8(%esp), %eax - movl CAML_STATE(exception_pointer, %ebx), %esp - popl CAML_STATE(exception_pointer, %ebx); CFI_ADJUST(-4) + movl CAML_STATE(exn_handler, %ebx), %esp + popl CAML_STATE(exn_handler, %ebx); CFI_ADJUST(-4) UNDO_ALIGN_STACK(8) ret LBL(112): movl 8(%esp), %esi /* Save exception bucket in esi */ ALIGN_STACK(12) /* 4: sp of handler */ - pushl CAML_STATE(exception_pointer, %ebx); CFI_ADJUST(4) + pushl CAML_STATE(exn_handler, %ebx); CFI_ADJUST(4) /* 3: sp of raise */ pushl CAML_STATE(bottom_of_stack, %ebx); CFI_ADJUST(4) /* 2: pc of raise */ @@ -373,8 +373,8 @@ LBL(112): pushl %esi; CFI_ADJUST(4) call G(caml_stash_backtrace) movl %esi, %eax /* Recover exception bucket */ - movl CAML_STATE(exception_pointer, %ebx), %esp - popl CAML_STATE(exception_pointer, %ebx); CFI_ADJUST(-4) + movl CAML_STATE(exn_handler, %ebx), %esp + popl CAML_STATE(exn_handler, %ebx); CFI_ADJUST(-4) UNDO_ALIGN_STACK(8) ret CFI_ENDPROC diff --git a/ocaml/runtime4/power.S b/ocaml/runtime4/power.S index 66c310791f5..e9e2faf8d8c 100644 --- a/ocaml/runtime4/power.S +++ b/ocaml/runtime4/power.S @@ -177,7 +177,7 @@ FUNCTION(caml_call_gc) /* Save current allocation pointer for debugging purposes */ stg ALLOC_PTR, Caml_state(young_ptr) /* Save exception pointer (if e.g. a sighandler raises) */ - stg TRAP_PTR, Caml_state(exception_pointer) + stg TRAP_PTR, Caml_state(exn_handler) /* Save all registers used by the code generator */ addi 11, 1, 8*32 + PARAM_SAVE_AREA + RESERVED_STACK - WORD stgu 3, WORD(11) @@ -324,7 +324,7 @@ FUNCTION(caml_c_call) stg C_CALL_RET_ADDR, Caml_state(last_return_address) /* Make the exception handler and alloc ptr available to the C code */ stg ALLOC_PTR, Caml_state(young_ptr) - stg TRAP_PTR, Caml_state(exception_pointer) + stg TRAP_PTR, Caml_state(exn_handler) /* Call C function (address in C_CALL_FUN) */ #if defined(MODEL_ppc) mtctr C_CALL_FUN @@ -396,7 +396,7 @@ FUNCTION(caml_raise_exception) bne .L121 .L120: /* Reload OCaml global registers */ - lg 1, Caml_state(exception_pointer) + lg 1, Caml_state(exn_handler) lg ALLOC_PTR, Caml_state(young_ptr) /* Pop trap frame */ lg 0, TRAP_HANDLER_OFFSET(1) @@ -410,7 +410,7 @@ FUNCTION(caml_raise_exception) /* arg1: exception bucket, already in r3 */ lg 4, Caml_state(last_return_address) /* arg2: PC of raise */ lg 5, Caml_state(bottom_of_stack) /* arg3: SP of raise */ - lg 6, Caml_state(exception_pointer) /* arg4: SP of handler */ + lg 6, Caml_state(exn_handler) /* arg4: SP of handler */ addi 1, 1, -(PARAM_SAVE_AREA + RESERVED_STACK) /* reserve stack space for C call */ bl caml_stash_backtrace @@ -498,7 +498,7 @@ FUNCTION(caml_start_program) .cfi_adjust_cfa_offset TRAP_SIZE mflr 0 stg 0, TRAP_HANDLER_OFFSET(1) - lg 11, Caml_state(exception_pointer) + lg 11, Caml_state(exn_handler) stg 11, TRAP_PREVIOUS_OFFSET(1) mr TRAP_PTR, 1 /* Reload allocation pointer */ @@ -522,9 +522,9 @@ FUNCTION(caml_start_program) #else #error "wrong MODEL" #endif - /* Pop the trap frame, restoring caml_exception_pointer */ + /* Pop the trap frame, restoring caml_exn_handler */ lg 0, TRAP_PREVIOUS_OFFSET(1) - stg 0, Caml_state(exception_pointer) + stg 0, Caml_state(exn_handler) addi 1, 1, TRAP_SIZE .cfi_adjust_cfa_offset -TRAP_SIZE /* Pop the callback link, restoring the global variables */ @@ -588,8 +588,8 @@ FUNCTION(caml_start_program) #ifdef TOC_SAVE_PARENT ld 2, (STACKSIZE + TOC_SAVE_PARENT)(1) #endif - /* Update caml_exception_pointer */ - stg TRAP_PTR, Caml_state(exception_pointer) + /* Update caml_exn_handler */ + stg TRAP_PTR, Caml_state(exn_handler) /* Encode exception bucket as an exception result and return it */ ori 3, 3, 2 b .L106 diff --git a/ocaml/runtime4/riscv.S b/ocaml/runtime4/riscv.S index 205b1498c6c..4c31e4fccab 100644 --- a/ocaml/runtime4/riscv.S +++ b/ocaml/runtime4/riscv.S @@ -143,7 +143,7 @@ FUNCTION(caml_call_gc) /* Save current allocation pointer for debugging purposes */ STORE ALLOC_PTR, Caml_state(young_ptr) /* Save trap pointer in case an exception is raised during GC */ - STORE TRAP_PTR, Caml_state(exception_pointer) + STORE TRAP_PTR, Caml_state(exn_handler) /* Call the garbage collector */ call PLT(caml_garbage_collection) /* Restore registers */ @@ -211,7 +211,7 @@ FUNCTION(caml_c_call) STORE sp, Caml_state(bottom_of_stack) /* Make the exception handler alloc ptr available to the C code */ STORE ALLOC_PTR, Caml_state(young_ptr) - STORE TRAP_PTR, Caml_state(exception_pointer) + STORE TRAP_PTR, Caml_state(exn_handler) /* Call the function */ jalr ARG /* Reload alloc ptr */ @@ -253,7 +253,7 @@ END_FUNCTION(caml_raise_exn) FUNCTION(caml_raise_exception) mv DOMAIN_STATE_PTR, a0 mv a0, a1 - LOAD TRAP_PTR, Caml_state(exception_pointer) + LOAD TRAP_PTR, Caml_state(exn_handler) LOAD ALLOC_PTR, Caml_state(young_ptr) LOAD TMP, Caml_state(backtrace_active) bnez TMP, 2f @@ -326,7 +326,7 @@ FUNCTION(caml_start_program) /* set up a trap frame */ addi sp, sp, -16 CFI_ADJUST(16) - LOAD TMP, Caml_state(exception_pointer) + LOAD TMP, Caml_state(exn_handler) STORE TMP, 0(sp) lla TMP, .Ltrap_handler STORE TMP, 8(sp) @@ -334,9 +334,9 @@ FUNCTION(caml_start_program) LOAD ALLOC_PTR, Caml_state(young_ptr) STORE x0, Caml_state(last_return_address) jalr ARG -.Lcaml_retaddr: /* pop trap frame, restoring caml_exception_pointer */ +.Lcaml_retaddr: /* pop trap frame, restoring caml_exn_handler */ LOAD TMP, 0(sp) - STORE TMP, Caml_state(exception_pointer) + STORE TMP, Caml_state(exn_handler) addi sp, sp, 16 CFI_ADJUST(-16) .Lreturn_result: /* pop callback link, restoring global variables */ @@ -386,7 +386,7 @@ END_FUNCTION(caml_start_program) .align 2 .Ltrap_handler: CFI_STARTPROC - STORE TRAP_PTR, Caml_state(exception_pointer) + STORE TRAP_PTR, Caml_state(exn_handler) ori a0, a0, 2 j .Lreturn_result .type .Ltrap_handler, @function diff --git a/ocaml/runtime4/s390x.S b/ocaml/runtime4/s390x.S index 9d8cb763e8a..7a90f4447ca 100644 --- a/ocaml/runtime4/s390x.S +++ b/ocaml/runtime4/s390x.S @@ -58,7 +58,7 @@ caml_call_gc: /* Save current allocation pointer for debugging purposes */ stg %r11, Caml_state(young_ptr) /* Save exception pointer (if e.g. a sighandler raises) */ - stg %r13, Caml_state(exception_pointer) + stg %r13, Caml_state(exn_handler) /* Save all registers used by the code generator */ stmg %r2,%r9, (8*16)(%r15) stg %r12, (8*16 + 8*8)(%r15) @@ -125,7 +125,7 @@ caml_c_call: stg %r14, Caml_state(last_return_address) /* Make the exception handler and alloc ptr available to the C code */ stg %r11, Caml_state(young_ptr) - stg %r13, Caml_state(exception_pointer) + stg %r13, Caml_state(exn_handler) /* Call the function */ basr %r14, %r7 /* restore return address */ @@ -174,7 +174,7 @@ caml_raise_exception: jne .L112 .L113: /* Reload OCaml global registers */ - lg %r15, Caml_state(exception_pointer) + lg %r15, Caml_state(exn_handler) lg %r11, Caml_state(young_ptr) /* Pop trap frame */ lg %r1, 0(%r15) @@ -187,7 +187,7 @@ caml_raise_exception: /* arg1: exception bucket, already in r2 */ lg %r3, Caml_state(last_return_address) /* arg2: PC of raise */ lg %r4, Caml_state(bottom_of_stack) /* arg3: SP of raise */ - lg %r5, Caml_state(exception_pointer) /* arg4: SP of handler */ + lg %r5, Caml_state(exn_handler) /* arg4: SP of handler */ /* reserve stack space for C call */ lay %r15, -160(%r15) brasl %r14, caml_stash_backtrace@PLT @@ -237,7 +237,7 @@ caml_start_program: .L103: lay %r15, -16(%r15) stg %r14, 0(%r15) - lg %r1, Caml_state(exception_pointer) + lg %r1, Caml_state(exn_handler) stg %r1, 8(%r15) lgr %r13, %r15 /* Reload allocation pointer */ @@ -246,9 +246,9 @@ caml_start_program: lgr %r1,%r0 basr %r14, %r1 .L105: - /* Pop the trap frame, restoring caml_exception_pointer */ + /* Pop the trap frame, restoring caml_exn_handler */ lg %r0, 8(%r15) - stg %r0, Caml_state(exception_pointer) + stg %r0, Caml_state(exn_handler) la %r15, 16(%r15) /* Pop the callback link, restoring the global variables */ .L106: @@ -280,8 +280,8 @@ caml_start_program: /* The trap handler: */ .L104: - /* Update caml_exception_pointer */ - stg %r13, Caml_state(exception_pointer) + /* Update caml_exn_handler */ + stg %r13, Caml_state(exn_handler) /* Encode exception bucket as an exception result and return it */ oill %r2, 2 j .L106 diff --git a/ocaml/runtime4/signals_nat.c b/ocaml/runtime4/signals_nat.c index 3dd37fb0174..16c90b6f3c2 100644 --- a/ocaml/runtime4/signals_nat.c +++ b/ocaml/runtime4/signals_nat.c @@ -169,7 +169,7 @@ DECLARE_SIGNAL_HANDLER(trap_handler) caml_sigmask_hook(SIG_UNBLOCK, &mask, NULL); } #endif - Caml_state->exception_pointer = (char *) CONTEXT_EXCEPTION_POINTER; + Caml_state->exn_handler = (char *) CONTEXT_EXCEPTION_POINTER; Caml_state->young_ptr = (value *) CONTEXT_YOUNG_PTR; Caml_state->bottom_of_stack = (char *) CONTEXT_SP; Caml_state->last_return_address = (uintnat) CONTEXT_PC; @@ -229,7 +229,7 @@ DECLARE_SIGNAL_HANDLER(segv_handler) Caml_state->young_ptr = (value *) CONTEXT_YOUNG_PTR; #endif #if defined(CONTEXT_EXCEPTION_POINTER) - Caml_state->exception_pointer = (char *) CONTEXT_EXCEPTION_POINTER; + Caml_state->exn_handler = (char *) CONTEXT_EXCEPTION_POINTER; #endif caml_raise_stack_overflow(); #endif diff --git a/ocaml/stdlib/Makefile b/ocaml/stdlib/Makefile index 129b824f4bd..5130c3f232a 100644 --- a/ocaml/stdlib/Makefile +++ b/ocaml/stdlib/Makefile @@ -36,7 +36,7 @@ CAMLOPT=$(OCAMLRUN) $(OPTCOMPILER) CAMLDEP=$(BOOT_OCAMLC) -depend DEPFLAGS=-slash -OC_CPPFLAGS += -I$(ROOTDIR)/runtime4 +OC_CPPFLAGS += -I$(ROOTDIR)/$(RUNTIME_DIR) include StdlibModules diff --git a/ocaml/stdlib/dune b/ocaml/stdlib/dune index 25c83ad42c2..0f54479caaf 100644 --- a/ocaml/stdlib/dune +++ b/ocaml/stdlib/dune @@ -48,7 +48,7 @@ ../Makefile.config_if_required ../Makefile.build_config ../Makefile.config - ../runtime4/sak) + ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/sak) (action (run make -s COMPUTE_DEPS=false %{targets}))) diff --git a/ocaml/tools/Makefile b/ocaml/tools/Makefile index ef776468f99..cc3520ed76d 100644 --- a/ocaml/tools/Makefile +++ b/ocaml/tools/Makefile @@ -32,7 +32,7 @@ $(patsubst %.cmo,%.cmx,$(patsubst %.cma,%.cmxa,$1)) endef CAMLC = $(BOOT_OCAMLC) -g -nostdlib -I $(ROOTDIR)/boot \ - -use-prims $(ROOTDIR)/runtime/primitives -I $(ROOTDIR) + -use-prims $(ROOTDIR)/$(RUNTIME_DIR)/primitives -I $(ROOTDIR) CAMLOPT = $(OCAMLRUN) $(ROOTDIR)/ocamlopt$(EXE) \ -g -nostdlib -I $(ROOTDIR)/stdlib INCLUDES = $(addprefix -I $(ROOTDIR)/,utils parsing typing bytecomp \ diff --git a/ocaml/tools/dune b/ocaml/tools/dune index 60ecf0ee13b..4d4ca623886 100644 --- a/ocaml/tools/dune +++ b/ocaml/tools/dune @@ -47,7 +47,7 @@ (rule (target opnames.ml) (deps make_opcodes.exe (universe)) - (action (system "./make_opcodes.exe -opnames < ../runtime4/caml/instruct.h > opnames.ml"))) + (action (system "./make_opcodes.exe -opnames < ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml/instruct.h > opnames.ml"))) (library (name opnames) diff --git a/ocaml/utils/config.fixed.ml b/ocaml/utils/config.fixed.ml index 28f346eba8b..e9a46706de5 100644 --- a/ocaml/utils/config.fixed.ml +++ b/ocaml/utils/config.fixed.ml @@ -74,3 +74,6 @@ let target = host let systhread_supported = false let flexdll_dirs = [] let ar_supports_response_files = true + +(* mshinwell: at present always use runtime4 for bootstrap *) +let runtime5 = false diff --git a/ocaml/utils/config.generated.ml.in b/ocaml/utils/config.generated.ml.in index d89d185f47d..85c67223be4 100644 --- a/ocaml/utils/config.generated.ml.in +++ b/ocaml/utils/config.generated.ml.in @@ -115,3 +115,5 @@ let systhread_supported = @systhread_support@ let flexdll_dirs = [@flexdll_dir@] let ar_supports_response_files = @ar_supports_response_files@ + +let runtime5 = "@enable_runtime5@" = "yes" \ No newline at end of file diff --git a/ocaml/utils/config.mli b/ocaml/utils/config.mli index 376f10514f4..29157810369 100644 --- a/ocaml/utils/config.mli +++ b/ocaml/utils/config.mli @@ -276,6 +276,10 @@ val poll_insertion : bool val ar_supports_response_files: bool (** Whether ar supports @FILE arguments. *) +val runtime5 : bool +(** [true] if using the OCaml 5.x runtime, [false] if using the + OCaml 4.14 runtime. *) + (** Access to configuration values *) val print_config : out_channel -> unit diff --git a/ocaml/utils/dune b/ocaml/utils/dune index f11e23c012b..949ea371cc2 100644 --- a/ocaml/utils/dune +++ b/ocaml/utils/dune @@ -25,12 +25,12 @@ (mode fallback) (deps (:conf ../Makefile.config) (:c domainstate.ml.c) - (:tbl ../runtime4/caml/domain_state.tbl) - (glob_files ../runtime4/caml/{config,m,s}.h)) + (:tbl ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml/domain_state.tbl) + (glob_files ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml/{config,m,s}.h)) (action (with-stdout-to %{targets} (bash - "`grep '^CPP=' %{conf} | cut -d'=' -f2` -I ../runtime4/caml %{c}" + "`grep '^CPP=' %{conf} | cut -d'=' -f2` -I ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml %{c}" )))) (rule @@ -38,10 +38,10 @@ (mode fallback) (deps (:conf ../Makefile.config) (:c domainstate.mli.c) - (:tbl ../runtime4/caml/domain_state.tbl) - (glob_files ../runtime4/caml/{config,m,s}.h)) + (:tbl ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml/domain_state.tbl) + (glob_files ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml/{config,m,s}.h)) (action (with-stdout-to %{targets} (bash - "`grep '^CPP=' %{conf} | cut -d'=' -f2` -I ../runtime4/caml %{c}" + "`grep '^CPP=' %{conf} | cut -d'=' -f2` -I ../%{env:RUNTIME_DIR=runtime-dir-env-var-not-set}/caml %{c}" ))))