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
Build programs with the $(EXE) extension #9652
Build programs with the $(EXE) extension #9652
Conversation
15cc65a
to
f361fe4
Compare
f361fe4
to
5c1c4db
Compare
I'm in favour of simplifying this, certainly. A few comments:
It's one thing having objects (.obj and .lib) floating around which might not be relevant, but it feels like a development irritation to end up with A possibility which would simplify the cleaning as well. We already have near full machinery to install the files with .exe added... that could be inverted? Dune intentionally chose to build everything internally with |
377c281
to
89ac3bb
Compare
David Allsopp (2020/06/09 06:37 -0700):
I'm in favour of simplifying this, certainly. A few comments:
- #8639 includes the ability to run `make clean` without
configuration, but it's also (on purpose) meant to be the case that it
cleans artefacts with different extensions. I quite regularly work in
a single tree which switches between mingw-w64 (.o & .exe), msvc (.obj
* .exe) and WSL (.o & no extension). `git clean -dfX` means I have to
go through a slow reconfiguration stage and for build system hacking I
quite like to be able to check what files are present (I use an alias
`git show-dirty` which lists all files which git is ignoring through
.gitignore). So I like `make distclean` to work without having to run
`configure` first (although I can use `git clean -dfX` then as easily)
but I also really like `make clean` to remove all the build artefacts,
not just the ones currently configured.
I have updated the PR to do that and also removed from it the commit
that took the configuration into account, if it did exist.
- From that, please could the `clean` targets here _always_ delete
`foo` and `foo.exe`, regardless of `$(EXE)` (this is why #8639
systematically expanded calls to `$(A)`, etc. and is what was done
for `ocamlnat`). That could be done relatively cleanly of course
with `CLEAN_PROGRAM` macro so that `$call CLEAN_PROGRAM,ocamldoc)`
expands to `rm -f ocamldoc ocamldoc.exe ocamldoc.opt
ocamldoc.opt.exe`
It seemed okay to do it manually, actually.
- I think `Bytelink.fix_exec_name` is an extremely old bug - that's
the only place where the compiler forces the addition of `.exe`. I
_think_ that the fix really ought to be to compile the custom
runtime there with `.exe` and then rename it after compilation back
to the name requested with `-o` (or something like that), but it's
obviously a corner case. In general, the drivers should never add
`.exe`.
I think I'll leave that for later (and perhaps for somebody else)
because it's not directly related to the issue this PR wants to fix, I
think.
- I don't think there's a problem introducing a dependency on `Config`
for ocamlmktop is there? As with `ocamlmklib`, isn't it just the
case that it's a tool which started life as a script (?!) and got
converted/written in OCaml long before the compiler-libs abstraction
existed? I would for now advise against adding `Sys.ext_exe` at this
stage - that's confusing for cross-compilation.
I implemented the change in ocamlmktop.
- Agreed that `read_cmt` could be built with the correct name
I did that.
One last thing that could be done here: two files in tools/ are kept at
clean time: ocamldep and cvt_emit. When cleaning, they get renamed with
a `.bak` extension rather than deleted because they are considered
"precious".
Given that `boot/ocamlc` now has the ability to compute dependencies, I
don't think tools/ocamldep is still so precious that make clean can't
delete it. Is it?
I'm less sure about cvt_emit but my understanding is that it is used to
build the native compiler and can then always be rebuilt rather easily.
So how aobut getting rid of the "precious" thing and just removing
ocamldep and cvt_emit like any other file when cleaning?
|
Actually, how about going one step further and building e.g. Would somebody disagree with this? If not I'd happily integrate it to the present PR. Please, let me know your opinions whatever they are. #FeedbackWanted |
i'm not excited. For .exe, there was a technical argument to do the change, which was |
89ac3bb
to
1ed4709
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.
Looks good. Just a few remarks and questions.
Makefile
Outdated
$(MAKE) coreall | ||
|
||
# Check if fixpoint reached | ||
|
||
CMPBYT := $(CAMLRUN) tools/cmpbyt |
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'd expect this one to get a $(EXE)
too...
Makefile
Outdated
($(MAKE) OCAML_FLEXLINK="../boot/ocamlrun$(EXE) \ | ||
./flexlink" MSVC_DETECT=0 \ |
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.
You have cut the line in a very strange place.
($(MAKE) OCAML_FLEXLINK="../boot/ocamlrun$(EXE) \ | |
./flexlink" MSVC_DETECT=0 \ | |
($(MAKE) OCAML_FLEXLINK="../boot/ocamlrun$(EXE) ./flexlink" \ | |
MSVC_DETECT=0 \ |
Makefile.common
Outdated
@@ -117,3 +117,12 @@ endif | |||
|
|||
$(DEPDIR): | |||
$(MKDIR) $@ | |||
|
|||
# When exeecutable files have an extension (e.g. ".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.
# When exeecutable files have an extension (e.g. ".exe"), | |
# When executable files have an extension (e.g. ".exe"), |
ocamltest/Makefile
Outdated
@@ -42,6 +42,8 @@ else | |||
endif | |||
endif | |||
|
|||
exe := $(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.
You define this variable but AFAICT you never use it.
tools/Makefile
Outdated
|
||
# 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 | ||
if test -f ocamldep.exe; then \ |
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 agree we can get rid of this special case for ocamldep
: it's not used by the build system anymore, so we won't need it while bootstrapping.
tools/Makefile
Outdated
$(eval $(call PROGRAM_SYNONYM,cvt_emit)) | ||
|
||
$(cvt_emit): cvt_emit.cmo | ||
$(CAMLC) $(LINKFLAGS) -o $@ $< |
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.
$(CAMLC) $(LINKFLAGS) -o $@ $< | |
$(CAMLC) $(LINKFLAGS) -o $@ $^ |
tools/Makefile
Outdated
$(ROOTDIR)/otherlibs/str/str.cma \ | ||
$(ROOTDIR)/otherlibs/$(UNIXLIB)/unix.cma \ | ||
caml_tex.ml | ||
caml_tex_objects := \ |
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.
Why rename this macro? These are libraries and a source file, none of them are object files...
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.
Travis is not happy because:
- check-typo complains
- the dependencies for ocamlcmt have moved inside the .depend file (because ocamlcmt is not at the same place as read_cmt in alphabetical order)
- the Changes entry is missing
I think we can ignore the last two.
tools/ocamlmktop.ml
Outdated
let ocamlc,extra_quote = | ||
if Sys.win32 then "ocamlc.exe","\"" else "ocamlc","" | ||
in | ||
let ocamlc = "ocamlc" ^ Config.ext_exe in |
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.
check-typo is not happy...
let ocamlc = "ocamlc" ^ Config.ext_exe in | |
let ocamlc = "ocamlc" ^ Config.ext_exe in |
Thanks a lot for the careful review.
Damien Doligez (2020/06/16 07:11 -0700):
@damiendoligez approved this pull request.
Looks good. Just a few remarks and questions.
> $(MAKE) coreall
# Check if fixpoint reached
+
+CMPBYT := $(CAMLRUN) tools/cmpbyt
I'd expect this one to get a `$(EXE)` too...
You are correct. This has now been fixed.
> + ($(MAKE) OCAML_FLEXLINK="../boot/ocamlrun$(EXE) \
+ ./flexlink" MSVC_DETECT=0 \
You have cut the line in a very strange place.
```suggestion
($(MAKE) OCAML_FLEXLINK="../boot/ocamlrun$(EXE) ./flexlink" \
MSVC_DETECT=0 \
```
Ah indeed. Fixed. thanks.
> @@ -117,3 +117,12 @@ endif
$(DEPDIR):
$(MKDIR) $@
+
+# When exeecutable files have an extension (e.g. ".exe"),
```suggestion
# When executable files have an extension (e.g. ".exe"),
```
Fixed too. thanks.
> @@ -42,6 +42,8 @@ else
endif
endif
+exe := $(EXE)
You define this variable but AFAICT you never use it.
You are right, thanks. THe useless definition has been removed.
# 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
+ if test -f ocamldep.exe; then \
I agree we can get rid of this special case for `ocamldep`: it's not
used by the build system anymore, so we won't need it while
bootstrapping.
I have stopped removing it to `ocamldep.bak`.
-cvt_emit: $(CVT_EMIT)
- $(CAMLC) $(LINKFLAGS) -o cvt_emit $(CVT_EMIT)
+$(eval $(call PROGRAM_SYNONYM,cvt_emit))
+
+$(cvt_emit): cvt_emit.cmo
+ $(CAMLC) $(LINKFLAGS) -o $@ $<
```suggestion
$(CAMLC) $(LINKFLAGS) -o $@ $^
```
Okay, done. Although the previous code was not wrong. It's more robust
that way, you are right.
> @@ -340,28 +356,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_objects := \
Why rename this macro?
I renamed the _variable_ because I wanted to use `camltex` for the name
of the program and it felt odd to have both `camltex` and `CAMLTEX`
around.
These are libraries and a source file, none of them are object
files...
I renamed the variable to `camltex_files`.
|
I removed the trailing whitespace that displeased check-typo, sorry
about that.
|
1ed4709
to
9c6675f
Compare
@xavierleroy: @damiendoligez has advised to ask you about cvt_emit being In my understanding, the tool is used to compile the native compiler and |
9c6675f
to
5dc4aba
Compare
|
I thought that was Damien's obsession :-) Just like it says in the comment: before you can analyze dependencies on the OCaml code, all generated .ml and .mli files must be generated. I think Damien was worried about having to rebuild the dependencies in an inconsistent-bootstrap state where Personally I'm not too worried. If I get into such an inconsistent state, maybe restarting from a consistent state is better. |
Nowadays I would just checkout OCaml in another directory and build cvt_emit there, so it doesn't matter anymore, I think we can remove it. |
Use argv[0] rather than hardcoding "objinfo_helper". That way the message is accurate whether there is a ".exe" extension or not.
Before this commit, the name of the compiler to use (ocamlc or ocamlc.exe) was determined base on the OS type. This commit replaces this by a mere string concatenation of "ocamlc" and the configured extension for executable files. This introduces a dependency of tools/ocamlmktop on the compiler's configuration module.
Commit 13786d7 accidentally removed a file twice.
The `core` target can depend on `coldstart` rather than invoking `$(MAKE) coldstart` as its first command.
Use the EXE build variable rather than OS type to determine the extension of executable files
This commit touches neither boot/ocamlc nor boot/ocamllex It has the side-effect of fixing the cleanup rules which did not use the $(EXE) extension when removing a file although it was produced with the $(EXE) extension.
Now that programs are built with their $(EXE) suffix, their installation rules can be simplified a bit because most of the programs get installed under the name they have been built with.
5dc4aba
to
8087f7f
Compare
Damien Doligez (2020/06/18 01:28 -0700):
Nowadays I would just checkout OCaml in another directory and build
cvt_emit there, so it doesn't matter anymore, I think we can remove
it.
thanks. I amended the PR to also stop considering cvt_emit as precious.
CI was okay before this but I will still wait until it passes again and
then I will merge.
Thanks a lot to the reviewers for their time!
|
This PR aims at fixing issue #7312.
In addition to what has already been implemented, a few other things
could be included here.
bytecomp/bytelink.ml
defines afix_exec_name
function. Rather thanlooking at
Sys.os_type
, this function could just check whether theprovided name ends with the defined extension, leave it
unchanged in that case and add the extension otherwise.
In
tools/ocamlmktop.ml
, the code that computesocamlc,extra_quote
could be modified so that the computation of ocamlc becomes something
like
"ocamlc" ^ Config.ext_exe
.But, at the moment,
tools/ocamlmktop.ml
does not depend on theconfiguration module. So, wouldn't it be worth making
ext_exe
alsoavailable e.g. from the Sys module?
Finally, in
utils/config.mlp
, the computation ofdefault_executable_name
could also be reworked so that just thebasename depends on the OS type but the
ext_exe
extension then getssystematically added.
Shall I go ahead and add all these changes to this PR?
Also, there is the case of the
tools/read_cmt
tool which getscurrently installed as
ocamlcmt
. Shall I change the PR so that thisprogram, too, gets built using the name it will have when installed?
Most lileky this PR breaks the dune build, in case somebody wants to
work on it, e.g. @trefis