Skip to content
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

Makefile cleanup #1434

Merged
merged 4 commits into from
Dec 10, 2017
Merged

Makefile cleanup #1434

merged 4 commits into from
Dec 10, 2017

Conversation

damiendoligez
Copy link
Member

main Makefile:

  • remove some dicrepancies between Unix and Windows
  • fix hard-bootstrap instructions
  • remove obsolete targets package-macosx and base.opt
  • various clean-ups

cc @garrigue : is base.opt really obsolete?

@dra27
Copy link
Member

dra27 commented Oct 18, 2017

Is this also going through precheck?

@shindere
Copy link
Contributor

shindere commented Oct 18, 2017 via email

@shindere
Copy link
Contributor

In the checkstack target, is the "else ; " line really necessary, actually?
(I realise it was already there, just wondering whether we couldn't get
rid of it, while we are at it)

In ci-build: is it really necessary to run core and coreboot
before world?

Would a code like:

if $make_native; then
target=world.opt
else
target=world
fi
$make $jobs $target

be okay?

Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good modulo a probably unwanted change to ci-build.

@@ -16,13 +16,18 @@
# The main Makefile

# Hard bootstrap how-to:
# (only necessary in some cases, for example if you remove some primitive)
# (only necessary if you remove or rename some primitive)
#
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This update to the "hard bootstrap how-to" is welcome, but note that these two rounds of bootstrap are needed only because the bootstrap is currently half-broken. We need to talk about ways to fix it. My feeling is that it can be fixed easily and that the bootstrap can be further simplified to "half a round".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After working on it for a few hours I believe that we cannot un-break it without reverting #324, so we have to choose between:

  • one round of bootstrap for every case
  • two rounds for removing a primitive and no bootstrap needed when adding one.

tools/ci-build Outdated
@@ -218,7 +218,6 @@ case $configure in
*) error "internal error";;
esac

$make $jobs coldstart
$make $jobs core
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feels very wrong. If you start with a fresh copy of the sources (not from a previous build), boot/ is missing a number of files (boot/ocamlrun + the stdlib) that make core needs. It's the job of make coldstart to populate boot/.

More generally, I strongly suggest to do $make $jobs world.opt and skip the bootstrap in the main CI test. Reasons:

  • make world.opt is what most if not all users do. In the current ci-build we have a build procedure that doesn't match the procedure(s) that the end-user will apply. With accompanying risk of divergence.
  • It is wasteful to test the bootstrap on all configurations every time. Let's have a specific bootstrap test in the other-configs CI test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But core does coldstart so it works.

Good point about world.opt, but what will users really do? If they go by README.adoc, they'll do:

make world
make bootstrap [optional]
make opt
make opt.opt

and then they are told that they could have done make world.opt.

If they go by README.win32.adoc they'll do:

make world bootstrap opt opt.opt install

If they use OPAM, they'll do:

make world
make world.opt

I see much room for improvement here.

Copy link
Contributor

@xavierleroy xavierleroy Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But core does coldstart so it works.

Urgh, I didn't guess that.

I would still very much prefer make world.opt or, almost equivalently,

make world
make opt
make opt.opt

The bootstrap needs to be de-emphasized from README.adoc. In the very early days, it was the best test we had that the newly-built ocamlc worked. Nowadays we have the test suite as a much more comprehensive test. Building the .opt compilers is also a pretty good way to exercise a compiler that we just built, although it is ocamlopt rather than ocamlc.

I see much room for improvement here.

Agreed.

Copy link
Member

@dra27 dra27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the Makefile changes look good to me - just comments on whether the improvements could go further.

else
$(MAKE) opt-core
$(MAKE) otherlibrariesopt ocamltoolsopt
endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be better to have adopted the Windows version here?

opt: opt-core
	$(MAKE) otherlibrariesopt ocamltoolsopt

and make the relationship between opt and opt-core explicit?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you look at the file's history you'll see a lot of back-and-forth between dependencies and recursive calls to $(MAKE), all of them committed to fix parallel make. In my eye, all these versions are equivalent. I probably chose this one with the idea that opt-core would disappear eventually.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and I don't like having a phony target as a dependency because then it's not clear that it will be built every time. Better to call it explicitly IMO.

opt.opt: core opt-core ocamlc.opt all ocamlopt.opt ocamllex.opt \
ocamltoolsopt ocamltoolsopt.opt otherlibrariesopt $(OCAMLDOC_OPT) \
ocamltest.opt
endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be considered as not for this GPR, but if opt.opt is being tidied up then perhaps it should go the whole hog. There's no earthly reason why the target for "building the native-code versions of the tools" should run checkstack, runtime, core, ocaml, opt-core, otherlibraries $(WITH_DEBUGGER) $(WITH_OCAMLDOC) ocamltest, otherlibrariesopt or ocamltoolsopt.

I think most of this is here because world.opt is lazy? I think tests and manual-pregen should probably depend on world.opt rather than opt.opt if it is changed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At some point we'll probably decide between making each of these targets self-sufficient, or properly documenting their dependencies. And then I hope we'll eliminate most of them.
But this is for another PR.

Makefile Outdated
$(MAKE) core
$(MAKE) ocaml
endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, if we're in the business of tidying these, why not do the minimum necessary to start the toplevel:

	$(MAKE) coldstart
	$(MAKE) ocamlc
	$(MAKE) ocaml

Copy link
Member Author

@damiendoligez damiendoligez Oct 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the toplevel is started with option -I otherlibs/[win32]unix so we should probably also build otherlibraries for consistency.

.PHONY: checkstack
checkstack:
ifeq "$(UNIX_OR_WIN32)" "unix"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your Makefile-fu is superior to mine - is this one of those cases where it would be a good idea for the Windows part to have:

	@

(i.e. have the Windows target being a recipe which does nothing, rather than a target with no recipe)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it makes a difference in behavior, but I'll do it because it improves readability.

@shindere
Copy link
Contributor

shindere commented Oct 19, 2017 via email

@shindere
Copy link
Contributor

shindere commented Oct 19, 2017 via email

@damiendoligez
Copy link
Member Author

@xavierleroy The "probably unwanted" change is actually the starting point of this PR...

Anyway, here is a new commit that takes (most) remarks into account. @dra27 feel free to insist if you feel strongly about your first remark.

@dra27
Copy link
Member

dra27 commented Oct 19, 2017

All LGTM!

Copy link
Contributor

@xavierleroy xavierleroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that will do just fine for the moment. But this boostrap step in the CI script will go away eventually, I'm sure.

@xavierleroy
Copy link
Contributor

@damiendoligez I'm unable to guess if you intend this change for 4.06 or not, so I'll let you do the appropriate merge(s).

@damiendoligez damiendoligez added this to the 4.07-or-later milestone Oct 20, 2017
@damiendoligez
Copy link
Member Author

I'm waiting to give @garrigue a chance to comment. No hurry for this one.

@garrigue
Copy link
Contributor

Well, I suppose that I'm called in because I'm the originator of the optimized world.opt target.
But honestly, I don't have much to say at this point. We are talking of a different era, when compiling everything with the byte code version of the native compiler was very slow, so I introduced a mechanism to use the native version as much as possible. This was removed a while ago by @alainfrisch IIRC, to make things simpler. Also, most of the (big) otherlibraries and camlp4 are now out of the distribution, meaning that speed of compilation in this later phase is no longer an issue.

Making the targets more standard could indeed help new developers.
By the way, I don't think many end users compiled caml by hand these days, so they are less of a problem (on the other hand some packagers may not be ocaml experts).

@shindere
Copy link
Contributor

shindere commented Oct 24, 2017 via email

@gasche gasche merged commit 3882302 into ocaml:trunk Dec 10, 2017
@damiendoligez damiendoligez deleted the makefile-cleanup branch January 19, 2018 14:03
EmileTrotignon pushed a commit to EmileTrotignon/ocaml that referenced this pull request Jan 12, 2024
* percent-encode base-64 code when sharing
* to fix old share links, convert ' ' to '+' before base-64 decoding
* add #rawcode= as alternative to #code= (takes plain non-base64, but percent-encoded text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants