Skip to content

Commit

Permalink
Merge pull request #11993 from xavierleroy/install-fewer-opt-progs
Browse files Browse the repository at this point in the history
Compile non-speed-critical tools to bytecode only
  • Loading branch information
gasche committed Feb 22, 2023
2 parents 84fe059 + 64c6ccf commit 39a6e64
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
7 changes: 7 additions & 0 deletions Changes
Expand Up @@ -307,6 +307,13 @@ Working version
parameters.
(Florian Angeletti, report by Wiktor Kuchta, review by Jules Aguillon)

* #11993: install only bytecode executables for the `ocamlmklib`, `ocamlcmt`,
`ocamlprof`, `ocamlcp`, `ocamloptp`, and `ocamlmktop` tools, but no
native-code executables. A tool like `ocamlmklib` for example is now
installed directly to `$BINDIR/ocamlmklib`; `ocamlmklib.byte` and
`ocamlmklib.opt` are no longer installed to `$BINDIR`.
(Xavier Leroy, review by Gabriel Scherer)

### Manual and documentation:

- #9430, #11291: Document the general desugaring rules for binding operators.
Expand Down
41 changes: 23 additions & 18 deletions Makefile
Expand Up @@ -109,11 +109,15 @@ ocamllex_PROGRAMS = $(addprefix lex/,ocamllex ocamllex.opt)

ocamlyacc_PROGRAM = yacc/ocamlyacc

TOOLS_TO_INSTALL = \
ocamldep ocamlprof ocamlcp ocamlmklib ocamlmktop ocamlobjinfo
# Tools to be compiled to native and bytecode, then installed
TOOLS_TO_INSTALL_NAT = ocamldep ocamlobjinfo

# Tools to be compiled to bytecode only, then installed
TOOLS_TO_INSTALL_BYT = \
ocamlcmt ocamlprof ocamlcp ocamlmklib ocamlmktop

ifeq "$(NATIVE_COMPILER)" "true"
TOOLS_TO_INSTALL += ocamloptp
TOOLS_TO_INSTALL_BYT += ocamloptp
endif

# Clean should remove tools/ocamloptp etc. unconditionally because
Expand All @@ -122,9 +126,11 @@ endif
clean::
rm -f $(addprefix tools/ocamlopt,p p.opt p.exe p.opt.exe)

TOOLS = $(TOOLS_TO_INSTALL) ocamlcmt dumpobj primreq stripdebug cmpbyt
TOOLS_NAT = $(TOOLS_TO_INSTALL_NAT)
TOOLS_BYT = $(TOOLS_TO_INSTALL_BYT) dumpobj primreq stripdebug cmpbyt

TOOLS_PROGRAMS = $(addprefix tools/,$(TOOLS))
TOOLS_NAT_PROGRAMS = $(addprefix tools/,$(TOOLS_NAT))
TOOLS_BYT_PROGRAMS = $(addprefix tools/,$(TOOLS_BYT))

TOOLS_MODULES = tools/profiling

Expand All @@ -137,7 +143,7 @@ $(foreach PROGRAM, $(C_PROGRAMS),\

# OCaml programs that are compiled in both bytecode and native code

OCAML_PROGRAMS = ocamlc ocamlopt lex/ocamllex $(TOOLS_PROGRAMS)
OCAML_PROGRAMS = ocamlc ocamlopt lex/ocamllex $(TOOLS_NAT_PROGRAMS)

$(foreach PROGRAM, $(OCAML_PROGRAMS),\
$(eval $(call OCAML_PROGRAM,$(PROGRAM))))
Expand All @@ -149,7 +155,8 @@ $(foreach PROGRAM, $(OCAML_PROGRAMS),\
# We have to use dedicated rules to build it

OCAML_BYTECODE_PROGRAMS = expunge \
$(addprefix tools/,cvt_emit make_opcodes ocamltex)
$(TOOLS_BYT_PROGRAMS) \
$(addprefix tools/, cvt_emit make_opcodes ocamltex)

$(foreach PROGRAM, $(OCAML_BYTECODE_PROGRAMS),\
$(eval $(call OCAML_BYTECODE_PROGRAM,$(PROGRAM))))
Expand Down Expand Up @@ -1308,11 +1315,11 @@ lintapidiff: tools/lintapidiff.opt$(EXE)
# Tools

TOOLS_BYTECODE_TARGETS = \
$(filter-out tools/ocamloptp,$(TOOLS_PROGRAMS)) $(TOOLS_MODULES:=.cmo)
$(TOOLS_NAT_PROGRAMS) $(TOOLS_BYT_PROGRAMS) $(TOOLS_MODULES:=.cmo)

TOOLS_NATIVE_TARGETS = $(TOOLS_MODULES:=.cmx) tools/ocamloptp
TOOLS_NATIVE_TARGETS = $(TOOLS_MODULES:=.cmx)

TOOLS_OPT_TARGETS = $(TOOLS_PROGRAMS:=.opt)
TOOLS_OPT_TARGETS = $(TOOLS_NAT_PROGRAMS:=.opt)

.PHONY: ocamltools
ocamltools: ocamlc ocamllex
Expand Down Expand Up @@ -1617,7 +1624,7 @@ endif
ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
$(INSTALL_PROG) lex/ocamllex$(EXE) \
"$(INSTALL_BINDIR)/ocamllex.byte$(EXE)"
for i in $(TOOLS_TO_INSTALL); \
for i in $(TOOLS_TO_INSTALL_NAT); \
do \
$(INSTALL_PROG) "tools/$$i$(EXE)" "$(INSTALL_BINDIR)/$$i.byte$(EXE)";\
if test -f "tools/$$i".opt$(EXE); then \
Expand All @@ -1628,21 +1635,19 @@ ifeq "$(INSTALL_BYTECODE_PROGRAMS)" "true"
fi; \
done
else
for i in $(TOOLS_TO_INSTALL); \
for i in $(TOOLS_TO_INSTALL_NAT); \
do \
if test -f "tools/$$i".opt$(EXE); then \
$(INSTALL_PROG) "tools/$$i.opt$(EXE)" "$(INSTALL_BINDIR)"; \
(cd "$(INSTALL_BINDIR)" && $(LN) "$$i.opt$(EXE)" "$$i$(EXE)"); \
fi; \
done
endif
for i in $(TOOLS_TO_INSTALL_BYT); \
do \
$(INSTALL_PROG) "tools/$$i$(EXE)" "$(INSTALL_BINDIR)";\
done
$(INSTALL_PROG) $(ocamlyacc_PROGRAM)$(EXE) "$(INSTALL_BINDIR)"
if test -f tools/ocamlcmt.opt$(EXE); then \
$(INSTALL_PROG)\
tools/ocamlcmt.opt$(EXE) "$(INSTALL_BINDIR)/ocamlcmt$(EXE)"; \
else \
$(INSTALL_PROG) tools/ocamlcmt$(EXE) "$(INSTALL_BINDIR)"; \
fi
$(INSTALL_DATA) \
utils/*.cmi \
parsing/*.cmi \
Expand Down

0 comments on commit 39a6e64

Please sign in to comment.