-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Merge tools/Makefile into the root Makefile #11675
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
Conversation
526272f
to
10c0a41
Compare
10c0a41
to
d5e7932
Compare
d5e7932
to
11de2f1
Compare
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.
As ever, a thorough piece of work, and quite the nettle you've grasped again with this one, @shindere! It's pleasing that a 353 line Makefile
is removed with only 209 lines added elsewhere in its place :)
I was concerned - incorrectly - that this might affect Cygwin64 when built in bootstrapped flexdll mode but this is working fine (I think that's due to a combination of your work on utils/Makefile
and some of mine on $(MKEXE)
et al). I also bumped all the magic numbers, and bootstrapping also seems to be working as expected.
I think you could squash the "Makefile.common: simplify the generic macros" into the previous commit, but it's fine if you want to keep the two separate versions.
Most of my comments are cosmetic or typos - the only major thing which needs fixing is the doubling of commands caused by ocamltoolsopt
and ocamltoolsopt.opt
both making the same recursive call to make in parallel in the opt.opt
target.
In passing:
- In tools/ocamlmklib.ml, the
syslib
function is a leftover fromocamlbuild
days and thechop_suffix
functions appears never to have been used. - The spurious inclusion of
depend.cmi
in the dependencies of ocamldep is a hangover from pre#1078 days
Makefile
Outdated
|
||
partialclean:: | ||
rm -rf ocamlc$(EXE) | ||
rm -rf ocamlc ocamlc.exe |
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.
It was "wrong" before, but this should just be rm -f
(no -r
)
Makefile
Outdated
|
||
partialclean:: | ||
rm -f ocamlopt$(EXE) | ||
rm -f ocamlopt ocamlopt.exe ocamlopt.opt ocmalopt.opt.exe |
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.
Typo: ocamlopt.opt.exe
Makefile
Outdated
|
||
partialclean:: | ||
rm -f ocamlopt.opt$(EXE) | ||
rm -f ocamlc.opt ocamlc.opt.exe |
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 think it would be better to move these up with the bytecode version above (as is now the case for ocamlopt / ocamlopt.opt)
Makefile
Outdated
@@ -1069,6 +1053,8 @@ partialclean:: | |||
|
|||
# The lexer generator | |||
|
|||
ocamllex_LIBRARIES =\ |
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.
Stray line continuation
Makefile
Outdated
compilerlibs/ocamltoplevel.cmxa \ | ||
$(TOPLEVELSTART:.cmo=.cmx) | ||
ocamlnat_LIBRARIES = \ | ||
$(addprefix compilerlibs/ocaml,common optcomp bytecomp) \ |
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.
It reads strangely with 3 of these being prefixed with addprefix and ocamltoplevel not being. In this instance, might it be better just to have the list of 5 fully expanded (i.e. like the previous list, just without the extensions)
Makefile
Outdated
@@ -416,37 +407,42 @@ clean:: | |||
# The clean target | |||
clean:: partialclean | |||
rm -f configure~ $(PROGRAMS) $(PROGRAMS:=.exe) | |||
rm $(ocamllex_PROGRAMS) $(ocamllex_PROGRAMS:=.exe) |
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.
This gets corrected in a later commit, but this should be rm -f
Makefile
Outdated
TOOLS_TO_INSTALL = \ | ||
ocamldep ocamlprof ocamlcp ocamloptp ocamlmktop ocamlmklib ocamlobjinfo |
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 think it might be better to have $(TOOLS_TO_INSTALL)
defined alongside the $(TOOLS)
variable further up. It might also be clearer to put:
TOOLS_TO_INSTALL = ocamldep ocamlprof ocamlcp ..
TOOLS = $(TOOLS_TO_INSTALL) ocamlcmt dumpobj ...
?
Makefile
Outdated
otherlibs/str/str | ||
lintapidiff_MODULES = tools/lintapidiff | ||
|
||
tools/lintapidiff.opt$(EXE): VPATH += $(ROOTDIR)/otherlibs/str |
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 think this one doesn't need $(ROOTDIR)
. It looks like there a few tweaks needed to be able to say make lintapidiff
- 5f2f478 seemed to be working for me (at least to get it to build!)
278f373
to
df30414
Compare
David Allsopp (2022/12/06 12:59 -0800):
@dra27 commented on this pull request.
As ever, a thorough piece of work, and quite the nettle you've grasped
again with this one, @shindere!
Many thanks for always being so supportive and, at the same time, so
thorough in the reviews you are oding.
It's pleasing that a 353 line
Makefile is removed with only 209 lines added elsewhere in its
place :)
It is (perhaps the copyright header lines should not be counted as being
removed though), many thanks for having spotted this.
I was concerned - incorrectly - that this might affect Cygwin64 when
built in bootstrapped flexdll mode but this is working fine (I think
that's due to a combination of your work on utils/Makefile and some of
mine on $(MKEXE) et al).
That suggests (to me) that both works move us forward in a positive
direction. Good news!
I also bumped all the magic numbers, and
bootstrapping also seems to be working as expected.
Many thanks for having thought about doing this test!
I think you could squash the "Makefile.common: simplify the generic
macros" into the previous commit, but it's fine if you want to keep the
two separate versions.
No need to keep the two versions, you are right it's not worth keeping
that bit of the history so I squashed, according to your suggestion.
Most of my comments are cosmetic or typos - the only major thing which
needs fixing is the doubling of commands caused by ocamltoolsopt and
ocamltoolsopt.opt both making the same recursive call to make in
parallel in the opt.opt target.
In passing:
* In tools/ocamlmklib.ml, the syslib function is a leftover from
ocamlbuild days and the chop_suffix functions appears never to have
been used.
Oh, thanks for having checked the history for those!
* The spurious inclusion of depend.cmi in the dependencies of
ocamldep is a hangover from pre#1078 days
And thanks for having checked this, too.
In [2]Makefile:
>
partialclean::
- rm -rf ocamlc$(EXE)
+ rm -rf ocamlc ocamlc.exe
It was "wrong" before, but this should just be rm -f (no -r)
Well spotted (and fixed), thanks. I also noticed a line saying
`rm $(ocamllex_PROGRAMS) $(ocamllex_PROGRAMS:=.exe)` (without a `-f`),
so I added it, too, although its omission gets fixed by a later commit,
as you have spotted in a comment that appears below.
In [3]Makefile:
>
partialclean::
- rm -f ocamlopt$(EXE)
+ rm -f ocamlopt ocamlopt.exe ocamlopt.opt ocmalopt.opt.exe
Typo: ocamlopt.opt.exe
Fixed, thanks.
In [4]Makefile:
>
partialclean::
- rm -f ocamlc.opt$(EXE)
-
-# The native-code compiler compiled with itself
-
-ocamlopt.opt$(EXE): \
- compilerlibs/ocamlcommon.cmxa \
- compilerlibs/ocamloptcomp.cmxa \
- $(OPTSTART:.cmo=.cmx)
- $(CAMLOPT_CMD) $(OC_COMMON_LDFLAGS) $(OC_NATIVE_LDFLAGS) -o $@ $^
-
-partialclean::
- rm -f ocamlopt.opt$(EXE)
+ rm -f ocamlc.opt ocamlc.opt.exe
I think it would be better to move these up with the bytecode version
above (as is now the case for ocamlopt / ocamlopt.opt)
Done so.
In [5]Makefile:
> @@ -1069,6 +1053,8 @@ partialclean::
# The lexer generator
+ocamllex_LIBRARIES =\
Stray line continuation
Indeed, thanks. Fixed.
In [6]Makefile:
> @@ -1335,27 +1318,26 @@ endif
# The native toplevel
-ocamlnat_dependencies := \
- compilerlibs/ocamlcommon.cmxa \
- compilerlibs/ocamloptcomp.cmxa \
- compilerlibs/ocamlbytecomp.cmxa \
- otherlibs/dynlink/dynlink.cmxa \
- compilerlibs/ocamltoplevel.cmxa \
- $(TOPLEVELSTART:.cmo=.cmx)
+ocamlnat_LIBRARIES = \
+ $(addprefix compilerlibs/ocaml,common optcomp bytecomp) \
It reads strangely with 3 of these being prefixed with addprefix and
ocamltoplevel not being. In this instance, might it be better just to
have the list of 5 fully expanded (i.e. like the previous list, just
without the extensions)
Done so. I like it a bit less but I understand the concern so I did the
change.
In [7]Makefile.common:
> @@ -195,3 +195,34 @@ endif
if_file_exists = ( test ! -f $(1) || $(2) && rm -f $(1) )
MERGEMANIFESTEXE = $(call if_file_exists, $(1).manifest, \
mt -nologo -outputresource:$(1) -manifest $(1).manifest)
+
+# Macros and rules to compile OCaml programs
+
+.SECONDEXPANSION:
I think it's worth a comment here that .SECONDEXPANSION allows the
_LIBRARIES and _MODULES definition to appear after the OCAML_PROGRAM
call which uses them.
I have included (a variation of) the comment, thanks!
If we are being very pedantic, which we often
are, then I think the .SECONDEXPANSION actually belongs two commits
later in the history :)
I added it in the intermediate commit because it felt to me it was
precisely its purpose to make this happen.
In [8]Makefile:
>
+$(foreach PROGRAM, $(C_PROGRAMS),\
+ $(eval $(call PROGRAM_SYNONYM,$(PROGRAM))))
+
+# OCaml programs that are compiled in both bytecode and native code
+
+OCAML_PROGRAMS = ocamlc ocamlopt lex/ocamllex
+
+$(foreach PROGRAM, $(OCAML_PROGRAMS),\
+ $(eval $(call OCAML_PROGRAM,$(PROGRAM))))
+
+# OCaml programs that are compiled only in bytecode
+# Note: the bytecode toplevel, ocaml, is a bytecode program but at the
+# moment it's a special one, because it needs to be expunged, so we
+# can not declare it as we do for other bytecode-only programs.
Typo: cannot rather than "can not"
Didn't know, but fixed, thanks.
In [9]Makefile:
> @@ -444,11 +472,12 @@ ocaml.tmp: OC_BYTECODE_LDFLAGS += -I toplevel/byte -link
all
ocaml.tmp: $(ocaml_LIBRARIES:=.cma) $(ocaml_MODULES:=.cmo)
$(LINK_BYTECODE_PROGRAM) -o $@ $^
+$(eval $(call PROGRAM_SYNONYM,ocaml))
Is this worth putting with OCAML_BYTECODE_PROGRAMS above? It goes well
with the comment about why the ocaml command is a special case?
As discussed off-line, I am suggesting to leave the re-ordering of the
root Makefile for later, since it feels a task worth doing
independently. Is that okay?
In [10]Makefile.build_config.in:
> @@ -108,10 +108,17 @@ DEFAULT_BUILD_TARGET = @default_build_target@
OC_COMMON_CFLAGS = -g -strict-sequence -principal -absname \
-w +a-4-9-40-41-42-44-45-48 -warn-error +a -bin-annot \
-strict-formats
-OC_COMMON_LDFLAGS = -g
+OC_COMMON_LDFLAGS = -g $(INCLUDES)
+
+OC_BYTECODE_LDFLAGS =
Should these be in Makefile.common if they're not actually being
assigned values from configure?
As discussed offline, it is hoped that, one day, these flags will be
controlled by configure, e.g. to make it possible to control the
inclusion of debugging information from configure.
I could add that, if we reach the stage where there will be only one
Makefile, then `Makefile.common` will have no more reason to exist and
may then disappear.
In [11]tools/ocamltex.ml:
> @@ -207,15 +207,16 @@ module Toplevel = struct
Location.input_name := fname;
Location.input_lexbuf := Some lex;
try
+ let module P = Parsetree in
I think we could cope with the two instances of Parsetree below and
just not have this line? :)
Yes, you are right that it's better that way. After all there are no
short names for the other modules either so there is no good reason to
have one for this one.
In [12]tools/ocamltex.mli:
> @@ -0,0 +1,2 @@
+(* ocamltex.ml does not need to export any definition so here is
+ an empty interface *)
Please could this one have a copyright header, too?
Sure, done so, sorry I forgot.
In [13]tools/lintapidiff.mli:
> @@ -0,0 +1,2 @@
+(* lintapidiff.ml does not need to export any definition so here is
+ an empty interface *)
Copyright header
Done
In [14]tools/make_opcodes.mli:
> @@ -0,0 +1 @@
+(* make_opcodes.mll exports no definition so here is an empty interface *)
Copyright header
Done
In [15]Makefile:
> middle_end/closure middle_end/flambda middle_end/flambda/base_types \
- asmcomp driver toplevel
-INCLUDES = $(addprefix -I ,$(DIRS))
+ asmcomp driver toplevel tools
+INCLUDES = $(addprefix -I ,$(VPATH))
The need for -I space could be made explicit with -I$(SPACE)? (it
obviously wasn't before)
Frankly, I am unsure. To me the rule is readable as is so unless you
insist I'd tend to leave it alone, at least for the time being.
In [16]Makefile:
> @@ -416,37 +407,42 @@ clean::
# The clean target
clean:: partialclean
rm -f configure~ $(PROGRAMS) $(PROGRAMS:=.exe)
+ rm $(ocamllex_PROGRAMS) $(ocamllex_PROGRAMS:=.exe)
This gets corrected in a later commit, but this should be rm -f
Yes, you are totally correct. I still fixed the commit, as discussed
earlier.
In [17]Makefile:
> +TOOLS_TO_INSTALL = \
+ ocamldep ocamlprof ocamlcp ocamloptp ocamlmktop ocamlmklib ocamlobjinfo
I think it might be better to have $(TOOLS_TO_INSTALL) defined
alongside the $(TOOLS) variable further up. It might also be clearer to
put:
TOOLS_TO_INSTALL = ocamldep ocamlprof ocamlcp ..
TOOLS = $(TOOLS_TO_INSTALL) ocamlcmt dumpobj ...
Done. I also introduced a `TOOLS_PROGRAMS` that has similar content to
`TOOLS` but with the `tools/` prefix added. Note that I started by
calling that variable `TOOL_PROGRAMS` which seemed more grammatical but
then I went for `TOOLS_PROGRAMS` to refer to the fact that it talks
about programs that are in the `tools` directory. And, while I was at
it, I also introduced `TOOLS_MODULES` to avoid having to repeat
`tools/profiling` in the definitions of `TOOLS_BYTECODE_TARGETS` and
`TOOLS_NATIVE_TARGETS`. Thisalso makes it eaiy to add other tool
modules, should we need to.
In [18]Makefile:
>
.PHONY: ocamltoolsopt
ocamltoolsopt: ocamlopt
- $(MAKE) -C tools opt
+ $(MAKE) tools-allopt
This isn't quite right - before this target compiled just
tools/profiling.cmx but now it does a full build and because it's in a
recursive make call, things are being built twice.
It's sufficient to fix the build just by removing the call to
ocamltoolsopt in the opt.opt target, but this technically means that
make world && make opt now compiles the .opt versions of the tools,
which it's not supposed to.
I am unsure how to go about this, then.
In [19]Makefile:
> else
checkstack:
@
endif
# Lint @SInCE and @deprecated annotations
+lintapidiff_LIBRARIES = \
+ $(addprefix compilerlibs/ocaml,common bytecomp middleend) \
+ otherlibs/str/str
+lintapidiff_MODULES = tools/lintapidiff
+
+tools/lintapidiff.opt$(EXE): VPATH += $(ROOTDIR)/otherlibs/str
I think this one doesn't need $(ROOTDIR).
You are right indeed, thanks. Fixed.
It looks like there a few
tweaks needed to be able to say make lintapidiff
There was a mistake in the definition of `OCAML_NATIVE_PROGRAMS`: it
contained `tools/lintapidiff` but should have contained
`tools/lintapidiff.opt` for the macro to do the right things. That
happened because the way to deal with the `.opt` suffix has change
during this PR has been worked on. It's now fixeed and seems to work, at
least as far as building `tools/lintapidiff.opt` is concerned.
In [21]Makefile:
> +
+cmpbyt_LIBRARIES = $(addprefix compilerlibs/ocaml,common bytecomp)
+cmpbyt_MODULES = tools/cmpbyt
+
+# Scan latex files, and run ocaml code examples
+
+ocamltex_LIBRARIES = \
+ $(addprefix compilerlibs/ocaml,common bytecomp toplevel) \
+ $(addprefix otherlibs/,str/str unix/unix)
+ocamltex_MODULES = tools/ocamltex
+
+# ocamltex uses str.cma and unix.cma and so must be compiled with
+# $(ROOTDIR)/ocamlc rather than with $(ROOTDIR)/boot/ocamlc since the boot
+# compiler does not necessarily have the correct shared library
+# configuration.
+$(ocamltex): CAMLC = $(OCAMLRUN) $(ROOTDIR)/ocamlc$(EXE) $(STDLIBFLAGS)
I think it would be worth adding a comment to note that this also
applies to the compilation of ocamltex.ml and ocamltex.mli (because
they are dependencies) as that's both important and also a subtle part
of how GNU make works
I did add the comment. It's jsut that the definitions apply to all
theprerequisites so even to the libraries I think, so I am wondering
whether this is quite right. What do you think?
|
All good, thanks @shindere! Two specific replies: for the issue with the
I'll pull the revised branch and have a look (apropos our offline discussion) for the overriding of
Hmm, it's kind of a dirty "secret" of the build at the moment that compilerlibs is compiled using I applied this inelegant copy-and-paste diff: --- a/compilerlibs/Makefile.compilerlibs
+++ b/compilerlibs/Makefile.compilerlibs
@@ -416,6 +416,7 @@ utils/config_%.mli: utils/config.mli
beforedepend:: utils/config_main.mli utils/config_boot.mli
+compilerlibs/ocamlcommon.cma: CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims runtime/primitives
compilerlibs/ocamlcommon.cma: $(COMMON_CMI) $(ALL_CONFIG_CMO) $(COMMON)
$(CAMLC) -a -linkall -o $@ $(COMMON)
partialclean:: and then did the
It may also be possible to use a pattern rule to apply that a bit more elegantly (I think that might even be stable with the newer prefix-length, rather than order-in-makefile, rules for applying pattern rules?) |
tools/objinfo.mli
Outdated
(* OCaml *) | ||
(* *) | ||
(* Damien Doligez and Francois Rouaix, INRIA Rocquencourt *) | ||
(* Ported to Caml Special Light by John Malecki *) |
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.
Wrong copyright?
Makefile
Outdated
git ls-files -- 'otherlibs/*/*.mli' 'stdlib/*.mli' |\ | ||
grep -Ev internal\|obj\|stdLabels\|moreLabels |\ | ||
tools/lintapidiff.opt $(VERSIONS) | ||
|
||
# Tools | ||
|
||
TOOLS_BYTECODE_TARGETS = $(TOOLS_PROGRAMS) $(TOOLS_MODULES:=.cmo) | ||
|
||
TOOLS_NATIVE_TARGETS = $(TOOLS_PROGRAMSS:=.opt) $(TOOLS_MODULES:=.cmx) |
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.
Typo: extra S
at the end of TOOLS_PROGRAMS
The rules were using the LINKFLAGS variable whose definition had been lost while merging lex/Makefile in the root Makefile.
Remove leftover from commit 3e52e4e Also remove the no longer used DEF_SYMBOL_PREFIX variable
The compilation of tools/checkstack.c to tools/checkstack.$(O) was already happening in the root Makefile, so it is more coherent to also link the executable file in the same Makefile.
df30414
to
5966b1b
Compare
The purpose of this commit is to use the same compiler flags to compile the programs in the tools/ directory than those used in the root Makefile. In addition to a bit of re-ordering, this means two changes: 1. Disabling warning 40 in tools. It was enabled before this commit but the code didn't trigger it. 2. Enabling warning 70, which required the creation of a bunch of interface files. Also, the -g flag has been moved from the CAMLC/CAMLOPT variables to the COMPFLAGS and LINKFLAGS variables and added to the recipe that builds make_opcodes. Moreover, the - appearing in the compilation rules for .cmi[iox] files just before the file to be compiled has been removed and the flags in these recipes have been re-ordered so that -c appears at the end of the recipe, just before the name of the file to compile.
5966b1b
to
c4a9171
Compare
Florian Angeletti (2022/12/09 02:06 -0800):
@Octachron commented on this pull request.
__________________________________________________________________
In [1]tools/objinfo.mli:
> @@ -0,0 +1,17 @@
+(**************************************************************************)
+(* *)
+(* OCaml *)
+(* *)
+(* Damien Doligez and Francois Rouaix, INRIA Rocquencourt *)
+(* Ported to Caml Special Light by John Malecki *)
Wrong copyright?
Yes, absolutely. Sorry about that and many thanks for having spotted it.
The copyright was also wrong in a few other files, that should now be in
order.
|
I also added you to the Changes entry, @Octachron.
|
c4a9171
to
2c4fd25
Compare
David Allsopp (2022/12/09 02:12 -0800):
@dra27 commented on this pull request.
__________________________________________________________________
In [1]Makefile:
> git ls-files -- 'otherlibs/*/*.mli' 'stdlib/*.mli' |\
grep -Ev internal\|obj\|stdLabels\|moreLabels |\
tools/lintapidiff.opt $(VERSIONS)
# Tools
+TOOLS_BYTECODE_TARGETS = $(TOOLS_PROGRAMS) $(TOOLS_MODULES:=.cmo)
+
+TOOLS_NATIVE_TARGETS = $(TOOLS_PROGRAMSS:=.opt) $(TOOLS_MODULES:=.cmx)
Typo: extra S at the end of TOOLS_PROGRAMS
Oops, thanks. Fixed.
|
David Allsopp (2022/12/09 01:46 -0800):
All good, thanks @shindere! Two specific replies:
for the issue with the `opt` and `opt.opt` targets:
> I am unsure how to go about this, then.
I'll pull the revised branch and have a look (apropos our offline
discussion)
Many thanks. For the record, @dra27 has proposed
dra27@d6867e6,
which I thought I could improve by doing some computations during the
configure stage but I didn't like the result so @dra27 kindly agreed
that his commit be cherry-picked as part of this pull request.
for the overriding of `CAMLC` in `ocamltex`'s compilation:
> I did add the comment. It's jsut that the definitions apply to all theprerequisites so even to the libraries I think, so I am wondering whether this is quite right. What do you think?
Hmm, it's kind of a dirty "secret" of the build at the moment that
compilerlibs is compiled using `$(ROOTDIR)/boot/ocamlc` but has to be
linkable by programs compiled with `$(ROOTDIR)/ocamlc`.
My understanding is that will no longer be true once the work on the
build system has been completed. At least that this will not have to be
true. Do you also understand things that way, @dra27?
Indeed, at the
moment, if you do a build, then, say, `touch parsing/location.ml
tools/ocamltex.ml ; make tools/ocamltex` then `ocamlcommon.cma` gets
incorrectly rebuilt using `$(ROOTDIR)/ocamlc` instead of
`$(ROOTDIR)/boot/ocamlc`. That can be changed by having an explicit
`compilerlibs/ocamlcommon.cma: CAMLC = ...` in
`compilerlibs/Makefile.compilerlibs` - perhaps that a good idea,
therefore, to make the compiler used for the libraries explicit?
But then,
I applied this inelegant copy-and-paste diff:
```diff
--- a/compilerlibs/Makefile.compilerlibs
+++ b/compilerlibs/Makefile.compilerlibs
@@ -416,6 +416,7 @@ utils/config_%.mli: utils/config.mli
beforedepend:: utils/config_main.mli utils/config_boot.mli
+compilerlibs/ocamlcommon.cma: CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims runtime/primitives
compilerlibs/ocamlcommon.cma: $(COMMON_CMI) $(ALL_CONFIG_CMO) $(COMMON)
$(CAMLC) -a -linkall -o $@ $(COMMON)
partialclean::
```
and then did the `touch parsing/location.ml ...` from above and it looks like `location.cmo` and `ocamlcommon.cma` are correctly produced using `$(ROOTDIR)/boot/ocamlc` and then `ocamltex.cmo` and `ocamltex` using `$(ROOTDIR)/ocamlc`:
```
***@***.***:~/ocaml-7$ touch parsing/location.ml tools/ocamltex.ml
***@***.***:~/ocaml-7$ make tools/ocamltex
./boot/ocamlrun ./boot/ocamlc -nostdlib ... -c parsing/location.ml
./boot/ocamlrun ./boot/ocamlc -nostdlib ... -o compilerlibs/ocamlcommon.cma ...
./boot/ocamlrun ./ocamlc -nostdlib ... -c tools/ocamltex.ml
./boot/ocamlrun ./ocamlc -nostdlib ... -o tools/ocamltex ...
```
It may also be possible to use a pattern rule to apply that a bit more
elegantly (I think that might even be stable with the newer
prefix-length, rather than order-in-makefile, rules for applying
pattern rules?)
Do you mean to apply this to all the bytecode libraries built in
compilerlibs? So something like
```
compilerlibs/%.cma: CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims runtime/primitives
```
?
By the way: except if we want to add the presently discussed change, the
PR should now be ready for a last review and, maybe, to be merged.
|
|
||
# OCaml programs that are compiled in both bytecode and native code | ||
|
||
OCAML_PROGRAMS = ocamlc ocamlopt lex/ocamllex $(TOOLS_PROGRAMS) |
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.
tools/ocamloptp
needs adding to this list (as it's used for the clean
target) - this is the cause of the CI failure at the moment
Yes, that's right - I was anticipating that at some point we'll be able to tell trivially whether a separate set of compiler-libs is needed, or not.
Yes (apart from the
Yes, I agree! I think it might be worth trying to fix this issue here, though - it does at least sit right at the end of the commit series. |
David Allsopp (2022/12/12 04:10 -0800):
`tools/ocamloptp` needs adding to this list (as it's used for the
`clean` target) - this is the cause of the CI failure at the moment
Indeed, sorry! Fixed.
|
2a5cb7c
to
dc15bb5
Compare
David Allsopp (2022/12/12 04:13 -0800):
> Do you mean to apply this to all the bytecode libraries built in
compilerlibs? So something like
```
compilerlibs/%.cma: CAMLC = $(BOOT_OCAMLC) $(BOOT_STDLIBFLAGS) -use-prims runtime/primitives
```
Yes (apart from the `clean` check which is failing in CI) - I just
don't know (without trying) how the pattern rules will interact.
Okay so I pushed one commit to fix `make clean`. As discussed,
`tools/ocamloptp` etc. are removed unconditionnally because during `make
clean` the configuration is not included, even if it exists.
> By the way: except if we want to add the presently discussed change, the
PR should now be ready for a last review and, maybe, to be merged.
Yes, I agree! I think it might be worth trying to fix this issue here,
though - it does at least sit right at the end of the commit series.
I have pushed another commit that defines the right compiler to use for
both `ocamlcommon.cma` and `ocamlbytecomp.cma`.
CI is happy now. The AppVeyor failure is unrelated (one memory model
test failed). So hopefully this should finally be ready to go. IN any
case many thanks, @dra27 for allyour support.
|
f2cfdfe
to
6623576
Compare
This is because the configuration is not available during clenaup so we cannot rely on it to determine whether ocamloptp etc. have been built.
6623576
to
f61b76e
Compare
Now that each tool specifies on which libraries it depends, there is no need to wait until all the compiler libs have been built to start building the tools. The build can thus become more parallel and thus faster.
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.
This is making a journey through precheck#807 and assuming that doesn't show up anything, this is good to go with CI!
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.
The mingw32 failure in Jenkins is a sporadic memory model test failure - this is ready to go. A.OUT1!
Footnotes
-
see last section of https://www.bell-labs.com/usr/dmr/www/odd.html ↩
This continues the work started in #11243, #11248, #11268 and #11420.
As these former pull requests, the present one is best reviewed in a
commit-by-commit way.
The PR starts by fixing the build of ocamllex by taking the link flags
into account again -- they got accidentally lost in #11420.
After a few minor commits, a more substantial one adjusts the compilation
flags used to compile and link the programs in the tools/ directory so that
they match those used by the root Makefile. In particular, this
implied the creation of a few interface files which had been forgotten
in #11288, which in a way demonstrates how hard it was/is to e.g. enable
or disable a given warning all over our codebase.
In the same vein, a few commits work on distinguishing the compilation
and link stages for a few tools: rather than building them from their .ml
sources directly, we make sure to first compile them to .cmo files and then
only link them. This is so that the compilation can use the already existing
compilation rules rather than dedicated ones and, that way, make sure
the same flags are passed to the compilers consistently.
This PR also starts to use GNU make's
VPATH
variable to letmake
know where to look for prerequisites. This variable is then
used to compute which directories to pass to the compiler as arguments
of
-I
. That way, we make sure the compiler and GNU make agreeon where to look for files.
In addition to a few other simplifications, among which there is the
computation of the
LN
variable during configure rather than during build,this PR extends the existing build framework with a few build
variables and, more importantly, with a few macros that make linking OCaml
programs more concise and uniform.
Basically, to get a program
foo
linked, list its libraries infoo_LIBRARIES
, its modules infoo_MODULES
and call one of the providedlink macros depending on whether you want to produce both bytecode and
native versions of
foo
(withOCAML_PROGRAM
), only its bytecodeversion (with
OCAML_BYTECODE_PROGRAM
) or only its native versoin(with, guess?...
OCAML_NATIVE_PROGRAM
, yes).Finally, before this PR the
cmt
andcmit
source artifacts oftools/ocamlmktop_init
were not installed as they should have been. The PRfixes this and installs them.