diff options
author | Tom Kelly <ctk21@cl.cam.ac.uk> | 2021-03-03 17:00:53 +0000 |
---|---|---|
committer | Tom Kelly <ctk21@cl.cam.ac.uk> | 2021-03-03 17:00:53 +0000 |
commit | 205b05cc9b4c34b97357f493e5c691440bc12a42 (patch) | |
tree | 8aebb4f93d14483193b0ed5cbe49fbdf30b08acb /tools | |
parent | 05aaf7b6eadc5045f9a9d92540519cada709f457 (diff) | |
parent | 5f4542862f384a63a988db1dbd49c1e6b1ebf217 (diff) | |
download | ocaml-205b05cc9b4c34b97357f493e5c691440bc12a42.tar.gz |
Merge commit '5f4542862f384a63a988db1dbd49c1e6b1ebf217' into parallel_minor_gc_4_12
Diffstat (limited to 'tools')
-rw-r--r-- | tools/.depend | 50 | ||||
-rw-r--r-- | tools/Makefile | 119 | ||||
-rw-r--r-- | tools/objinfo.ml | 3 | ||||
-rw-r--r-- | tools/objinfo_helper.c | 2 | ||||
-rw-r--r-- | tools/ocamlcmt.ml (renamed from tools/read_cmt.ml) | 2 | ||||
-rw-r--r-- | tools/ocamlmktop.ml | 5 |
6 files changed, 93 insertions, 88 deletions
diff --git a/tools/.depend b/tools/.depend index 109cb1f3f1..2c96493b76 100644 --- a/tools/.depend +++ b/tools/.depend @@ -116,6 +116,30 @@ objinfo.cmx : \ ../file_formats/cmo_format.cmi \ ../file_formats/cmi_format.cmx \ ../bytecomp/bytesections.cmx +ocamlcmt.cmo : \ + ../typing/untypeast.cmi \ + ../typing/stypes.cmi \ + ../parsing/pprintast.cmi \ + ../parsing/location.cmi \ + ../utils/load_path.cmi \ + ../typing/envaux.cmi \ + ../driver/compmisc.cmi \ + ../file_formats/cmt_format.cmi \ + ../typing/cmt2annot.cmo \ + ../utils/clflags.cmi \ + ../typing/annot.cmi +ocamlcmt.cmx : \ + ../typing/untypeast.cmx \ + ../typing/stypes.cmx \ + ../parsing/pprintast.cmx \ + ../parsing/location.cmx \ + ../utils/load_path.cmx \ + ../typing/envaux.cmx \ + ../driver/compmisc.cmx \ + ../file_formats/cmt_format.cmx \ + ../typing/cmt2annot.cmx \ + ../utils/clflags.cmx \ + ../typing/annot.cmi ocamlcp.cmo : \ ../driver/main_args.cmi ocamlcp.cmx : \ @@ -135,8 +159,10 @@ ocamlmklib.cmx : \ ocamlmklibconfig.cmo : ocamlmklibconfig.cmx : ocamlmktop.cmo : \ + ../utils/config.cmi \ ../utils/ccomp.cmi ocamlmktop.cmx : \ + ../utils/config.cmx \ ../utils/ccomp.cmx ocamloptp.cmo : \ ../driver/main_args.cmi @@ -167,30 +193,6 @@ profiling.cmo : \ profiling.cmx : \ profiling.cmi profiling.cmi : -read_cmt.cmo : \ - ../typing/untypeast.cmi \ - ../typing/stypes.cmi \ - ../parsing/pprintast.cmi \ - ../parsing/location.cmi \ - ../utils/load_path.cmi \ - ../typing/envaux.cmi \ - ../driver/compmisc.cmi \ - ../file_formats/cmt_format.cmi \ - ../typing/cmt2annot.cmo \ - ../utils/clflags.cmi \ - ../typing/annot.cmi -read_cmt.cmx : \ - ../typing/untypeast.cmx \ - ../typing/stypes.cmx \ - ../parsing/pprintast.cmx \ - ../parsing/location.cmx \ - ../utils/load_path.cmx \ - ../typing/envaux.cmx \ - ../driver/compmisc.cmx \ - ../file_formats/cmt_format.cmx \ - ../typing/cmt2annot.cmx \ - ../utils/clflags.cmx \ - ../typing/annot.cmi stripdebug.cmo : \ ../utils/misc.cmi \ ../bytecomp/bytesections.cmi diff --git a/tools/Makefile b/tools/Makefile index 49e6b5d6d1..69b67c586e 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -46,10 +46,14 @@ define byte_and_opt_ # This check is defensive programming $(and $(filter-out 1,$(words $1)),$(error \ cannot build file with whitespace in name)) -$1: $3 $2 +$(call PROGRAM_SYNONYM, $1) + +$1$(EXE): $3 $2 $$(CAMLC) $$(LINKFLAGS) -I $$(ROOTDIR) -o $$@ $2 -$1.opt: $3 $$(call byte2native,$2) +$(call PROGRAM_SYNONYM, $1.opt) + +$1.opt$(EXE): $3 $$(call byte2native,$2) $$(CAMLOPT_CMD) $$(LINKFLAGS) -I $$(ROOTDIR) -o $$@ \ $$(call byte2native,$2) @@ -61,7 +65,7 @@ ifeq '$(filter $(installed_tools),$1)' '$1' install_files += $1 endif clean:: - rm -f -- $1 $1.opt + rm -f -- $1 $1.opt $1.exe $1.opt.exe endef @@ -73,7 +77,7 @@ endef CAMLC = $(BOOT_OCAMLC) -g -nostdlib -I $(ROOTDIR)/boot \ -use-prims $(ROOTDIR)/runtime/primitives -I $(ROOTDIR) -CAMLOPT = $(CAMLRUN) $(ROOTDIR)/ocamlopt -g -nostdlib -I $(ROOTDIR)/stdlib +CAMLOPT = $(CAMLRUN) $(ROOTDIR)/ocamlopt$(EXE) -g -nostdlib -I $(ROOTDIR)/stdlib CAMLLEX = $(CAMLRUN) $(ROOTDIR)/boot/ocamllex INCLUDES = $(addprefix -I $(ROOTDIR)/,utils parsing typing bytecomp \ middle_end middle_end/closure middle_end/flambda \ @@ -93,17 +97,13 @@ CAMLDEP_OBJ=ocamldep.cmo CAMLDEP_IMPORTS= \ $(ROOTDIR)/compilerlibs/ocamlcommon.cma \ $(ROOTDIR)/compilerlibs/ocamlbytecomp.cma -ocamldep: LINKFLAGS += -compat-32 +ocamldep$(EXE): LINKFLAGS += -compat-32 $(call byte_and_opt,ocamldep,$(CAMLDEP_IMPORTS) $(CAMLDEP_OBJ),) -ocamldep: depend.cmi -ocamldep.opt: depend.cmi +ocamldep$(EXE): depend.cmi +ocamldep.opt$(EXE): depend.cmi -# ocamldep is precious: sometimes we are stuck in the middle of a -# bootstrap and we need to remake the dependencies clean:: - if test -f ocamldep; then mv -f ocamldep ocamldep.bak; else :; fi - rm -f ocamldep.opt - + rm -f ocamldep ocamldep.exe ocamldep.opt ocamldep.opt.exe # The profiler @@ -186,61 +186,57 @@ install:: ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true" for i in $(install_files); \ do \ - $(INSTALL_PROG) "$$i" "$(INSTALL_BINDIR)/$$i.byte$(EXE)"; \ - if test -f "$$i".opt; then \ - $(INSTALL_PROG) "$$i.opt" "$(INSTALL_BINDIR)/$$i.opt$(EXE)" && \ - (cd "$(INSTALL_BINDIR)/" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \ + $(INSTALL_PROG) "$$i$(EXE)" "$(INSTALL_BINDIR)/$$i.byte$(EXE)"; \ + if test -f "$$i".opt$(EXE); then \ + $(INSTALL_PROG) "$$i.opt$(EXE)" "$(INSTALL_BINDIR)" && \ + (cd "$(INSTALL_BINDIR)" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \ else \ - (cd "$(INSTALL_BINDIR)/" && $(LN) "$$i.byte$(EXE)" "$$i$(EXE)"); \ + (cd "$(INSTALL_BINDIR)" && $(LN) "$$i.byte$(EXE)" "$$i$(EXE)"); \ fi; \ done else for i in $(install_files); \ do \ - if test -f "$$i".opt; then \ - $(INSTALL_PROG) "$$i.opt" "$(INSTALL_BINDIR)/$$i.opt$(EXE)"; \ - (cd "$(INSTALL_BINDIR)/" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \ + if test -f "$$i".opt$(EXE); then \ + $(INSTALL_PROG) "$$i.opt$(EXE)" "$(INSTALL_BINDIR)"; \ + (cd "$(INSTALL_BINDIR)" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \ fi; \ done endif # The preprocessor for asm generators -CVT_EMIT=cvt_emit.cmo +cvt_emit := cvt_emit$(EXE) -cvt_emit: $(CVT_EMIT) - $(CAMLC) $(LINKFLAGS) -o cvt_emit $(CVT_EMIT) +$(eval $(call PROGRAM_SYNONYM,cvt_emit)) -# cvt_emit is precious: sometimes we are stuck in the middle of a -# bootstrap and we need to remake the dependencies -.PRECIOUS: cvt_emit -clean:: - if test -f cvt_emit; then mv -f cvt_emit cvt_emit.bak; else :; fi +$(cvt_emit): cvt_emit.cmo + $(CAMLC) $(LINKFLAGS) -o $@ $^ clean:: - rm -f cvt_emit.ml + rm -f cvt_emit.ml cvt_emit cvt_emit.exe beforedepend:: cvt_emit.ml # Reading cmt files -READ_CMT= \ +ocamlcmt_objects= \ $(ROOTDIR)/compilerlibs/ocamlcommon.cma \ $(ROOTDIR)/compilerlibs/ocamlbytecomp.cma \ \ - read_cmt.cmo + ocamlcmt.cmo # Reading cmt files -$(call byte_and_opt,read_cmt,$(READ_CMT),) +$(call byte_and_opt,ocamlcmt,$(ocamlcmt_objects),) install:: - if test -f read_cmt.opt; then \ - $(INSTALL_PROG) read_cmt.opt "$(INSTALL_BINDIR)/ocamlcmt$(EXE)"; \ + if test -f ocamlcmt.opt$(EXE); then \ + $(INSTALL_PROG)\ + ocamlcmt.opt$(EXE) "$(INSTALL_BINDIR)/ocamlcmt$(EXE)"; \ else \ - $(INSTALL_PROG) read_cmt "$(INSTALL_BINDIR)/ocamlcmt$(EXE)"; \ + $(INSTALL_PROG) ocamlcmt$(EXE) "$(INSTALL_BINDIR)"; \ fi - # The bytecode disassembler DUMPOBJ= \ @@ -251,14 +247,18 @@ DUMPOBJ= \ $(call byte_and_opt,dumpobj,$(DUMPOBJ),) -make_opcodes: make_opcodes.ml - $(CAMLC) make_opcodes.ml -o $@ +make_opcodes := make_opcodes$(EXE) -opnames.ml: $(ROOTDIR)/runtime/caml/instruct.h make_opcodes - $(ROOTDIR)/runtime/ocamlrun make_opcodes -opnames < $< > $@ +$(eval $(call PROGRAM_SYNONYM,make_opcodes)) + +$(make_opcodes): make_opcodes.ml + $(CAMLC) $< -o $@ + +opnames.ml: $(ROOTDIR)/runtime/caml/instruct.h $(make_opcodes) + $(ROOTDIR)/runtime/ocamlrun$(EXE) $(make_opcodes) -opnames < $< > $@ clean:: - rm -f opnames.ml make_opcodes make_opcodes.ml + rm -f opnames.ml make_opcodes make_opcodes.exe make_opcodes.ml beforedepend:: opnames.ml @@ -290,8 +290,7 @@ OBJINFO=$(ROOTDIR)/compilerlibs/ocamlcommon.cma \ $(call byte_and_opt,ocamlobjinfo,$(OBJINFO),objinfo_helper$(EXE)) install:: - $(INSTALL_PROG) \ - objinfo_helper$(EXE) "$(INSTALL_LIBDIR)/objinfo_helper$(EXE)" + $(INSTALL_PROG) objinfo_helper$(EXE) "$(INSTALL_LIBDIR)" primreq=$(ROOTDIR)/compilerlibs/ocamlcommon.cma \ $(ROOTDIR)/compilerlibs/ocamlbytecomp.cma \ @@ -306,11 +305,12 @@ LINTAPIDIFF=$(ROOTDIR)/compilerlibs/ocamlcommon.cmxa \ $(ROOTDIR)/otherlibs/str/str.cmxa \ lintapidiff.cmx -lintapidiff.opt: INCLUDES+= -I $(ROOTDIR)/otherlibs/str -lintapidiff.opt: $(LINTAPIDIFF) +lintapidiff.opt$(EXE): INCLUDES+= -I $(ROOTDIR)/otherlibs/str +lintapidiff.opt$(EXE): $(LINTAPIDIFF) $(CAMLOPT_CMD) $(LINKFLAGS) -I $(ROOTDIR) -o $@ $(LINTAPIDIFF) clean:: - rm -f -- lintapidiff.opt lintapidiff.cm? lintapidiff.o lintapidiff.obj + rm -f -- lintapidiff.opt lintapidiff.opt.exe + rm -f lintapidiff.cm? lintapidiff.o lintapidiff.obj clean:: @@ -340,28 +340,31 @@ CMPBYT=$(ROOTDIR)/compilerlibs/ocamlcommon.cma \ $(call byte_and_opt,cmpbyt,$(CMPBYT),) -CAMLTEX= $(ROOTDIR)/compilerlibs/ocamlcommon.cma \ - $(ROOTDIR)/compilerlibs/ocamlbytecomp.cma \ - $(ROOTDIR)/compilerlibs/ocamltoplevel.cma \ - $(ROOTDIR)/otherlibs/str/str.cma \ - $(ROOTDIR)/otherlibs/$(UNIXLIB)/unix.cma \ - caml_tex.ml +caml_tex_files := \ + $(ROOTDIR)/compilerlibs/ocamlcommon.cma \ + $(ROOTDIR)/compilerlibs/ocamlbytecomp.cma \ + $(ROOTDIR)/compilerlibs/ocamltoplevel.cma \ + $(ROOTDIR)/otherlibs/str/str.cma \ + $(ROOTDIR)/otherlibs/$(UNIXLIB)/unix.cma \ + caml_tex.ml #Scan latex files, and run ocaml code examples -caml-tex: INCLUDES += $(addprefix -I $(ROOTDIR)/otherlibs/,str $(UNIXLIB)) -caml-tex: $(CAMLTEX) - $(ROOTDIR)/runtime/ocamlrun $(ROOTDIR)/ocamlc -nostdlib \ +caml_tex := caml-tex$(EXE) + +$(caml_tex): INCLUDES += $(addprefix -I $(ROOTDIR)/otherlibs/,str $(UNIXLIB)) +$(caml_tex): $(caml_tex_files) + $(ROOTDIR)/runtime/ocamlrun$(EXE) $(ROOTDIR)/ocamlc$(EXE) -nostdlib \ -I $(ROOTDIR)/stdlib $(LINKFLAGS) -linkall \ - -o $@ -no-alias-deps $(CAMLTEX) + -o $@ -no-alias-deps $^ # we need str and unix which depend on the bytecode version of other tools # thus we delay building caml-tex to the opt.opt stage ifneq "$(WITH_CAMLTEX)" "" -opt.opt:caml-tex +opt.opt: $(caml_tex) endif clean:: - rm -f -- caml-tex caml_tex.cm? + rm -f -- caml-tex caml-tex.exe caml_tex.cm? # Common stuff diff --git a/tools/objinfo.ml b/tools/objinfo.ml index d2a01995cf..4854ca1c74 100644 --- a/tools/objinfo.ml +++ b/tools/objinfo.ml @@ -244,7 +244,8 @@ let dump_byte ic = toc let find_dyn_offset filename = - let helper = Filename.concat Config.standard_library "objinfo_helper" in + let helper_name = "objinfo_helper" ^ Config.ext_exe in + let helper = Filename.concat Config.standard_library helper_name in let tempfile = Filename.temp_file "objinfo" ".out" in match Fun.protect diff --git a/tools/objinfo_helper.c b/tools/objinfo_helper.c index fe3ebd42c9..9eb8087beb 100644 --- a/tools/objinfo_helper.c +++ b/tools/objinfo_helper.c @@ -111,7 +111,7 @@ int main(int argc, char ** argv) long value; if (argc != 2) - error(NULL, "Usage: objinfo_helper <dynamic library>"); + error(NULL, "Usage: %s <dynamic library>", argv[0]); fd = bfd_openr(argv[1], "default"); if (!fd) diff --git a/tools/read_cmt.ml b/tools/ocamlcmt.ml index 952fab5120..359b28aa4b 100644 --- a/tools/read_cmt.ml +++ b/tools/ocamlcmt.ml @@ -41,7 +41,7 @@ let arg_list = Arg.align [ ] let arg_usage = - "read_cmt [OPTIONS] FILE.cmt : read FILE.cmt and print related information" + "ocamlcmt [OPTIONS] FILE.cmt : read FILE.cmt and print related information" let dummy_crc = String.make 32 '-' diff --git a/tools/ocamlmktop.ml b/tools/ocamlmktop.ml index ab333966a4..2b47ebb074 100644 --- a/tools/ocamlmktop.ml +++ b/tools/ocamlmktop.ml @@ -20,9 +20,8 @@ let _ = cmd.exe has special quoting rules (see 'cmd.exe /?' for details). Short version: if the string passed to cmd.exe starts with '"', the first and last '"' are removed *) - let ocamlc,extra_quote = - if Sys.win32 then "ocamlc.exe","\"" else "ocamlc","" - in + let ocamlc = "ocamlc" ^ Config.ext_exe in + let extra_quote = if Sys.win32 then "\"" else "" in let ocamlc = Filename.(quote (concat (dirname ocamlmktop) ocamlc)) in let cmdline = extra_quote ^ ocamlc ^ " -I +compiler-libs -linkall ocamlcommon.cma " ^ |