New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compile non-speed-critical tools to bytecode only #11993
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 | ||
|
||
|
@@ -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)))) | ||
|
@@ -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)))) | ||
|
@@ -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 | ||
|
@@ -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 \ | ||
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (removing this ad-hoc logic is a nice simplification) |
||
$(INSTALL_DATA) \ | ||
utils/*.cmi \ | ||
parsing/*.cmi \ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when INSTALL_BYTECODE_PROGRAMS is true, the layout we get is that
foo.byte
andfoo.opt
are available, andfoo
is a symbolic link tofoo.opt
. For bytecode-only programs I would expect to havefoo.byte
available, andfoo
as a symbolic link tofoo.byte
.If I understand correctly, this is not what this code does, it looks like it just installs
foo
and notfoo.byte
. Should we change this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No. The
.byte
/.opt
/ symbolic link dance is intended to let users choose between the two implementations if they must, and pick the best implementation by default otherwise. If there's only one implementation, there's no choice to be made. Plus, there's @kit-ty-kate 's suggestion above to get rid of all this symbolic link nonsense, and I'm in favor.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this PR, if users for some reason wanted to use a bytecode executable instead of its native counterpart, they would enable INSTALL_BYTECODE_PROGRAMS and then explicitly invoke
foo.byte
. Unless I am missing something, your change breaks this use-case by makingfoo.byte
unavailable for some tools. (But then: maybe no one was doing that, and especially for those tools nobody cares about in practice.)Independently of this backward-compatibility aspect, I don't see the problem with having a symlink. (My Linux box is full of symlinks all over, typically many of the
/usr/lib/*.so
files are symlinks.) It arguably even adds discoverability, if I dols -l .../bin/ocamlc
I can immediately tell that I have the native version on my system.I also didn't interpret Kate's comment #11993 (comment) to be complaining about symlinks, I read it as suggesting that we install at most one version of each tool, with the absence of symlinks a side-effect of that (or in fact we could keep symlinks if we really wanted, but I agree that in this case it makes less sense).
To summarize: my opinion is still that having the symlinks would be nicer, and I think that they help with compatibility in INSTALL_BYTECODE_PROGRAMS mode. It would probably be okay (not my preference but okay) to do without the links outside the INSTALL_BYTECODE_PROGRAMS mode. Then we could discuss (in a separate PR?) disabling this mode by default, and we would get closer to your ideal world (with a configure option still working for
.byte
aficionados).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced by your argument. For these rarely-used, non-performance-critical tools, I just want to go back to what we did in OCaml 4.02 and earlier. namely compilation to bytecode only and installation under the final name (no symlink to
.byte
). So, we will agree to disagree here and try to move on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, if you insist, that works for me.