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

Add support for CoqMakefile.local-late #12411

Merged
merged 3 commits into from May 27, 2021

Conversation

JasonGross
Copy link
Member

This allows users to write rules that depend on variables such as
VOFILES and VDFILE, which is essential in some of my use-cases (for
example, to properly handle seamless version switching, I need to make
all of the .vo files depend on a file where I record the version of Coq
being used).

Fixes #10912

Kind: feature / infrastructure.

Does this qualify for 8.12 / 8.12+beta1?

@JasonGross JasonGross added kind: infrastructure CI, build tools, development tools. part: tools Coqdoc, coq_makefile, etc. kind: enhancement Enhancement to an existing user-facing feature, tactic, etc. labels May 25, 2020
@JasonGross JasonGross requested review from a team as code owners May 25, 2020 23:18
@Zimmi48
Copy link
Member

Zimmi48 commented May 26, 2020

Does this qualify for 8.12 / 8.12+beta1?

Nope, sorry.

@Zimmi48 Zimmi48 added this to the 8.13+beta1 milestone May 26, 2020
@SkySkimmer SkySkimmer added the needs: fixing The proposed code change is broken. label May 26, 2020
@SkySkimmer
Copy link
Contributor

Test suite change is incorrect according to CI

@gares
Copy link
Member

gares commented May 26, 2020

Can't you just move down the inclusion of Makefile.coq.local.
I see this strategy is more backward compatible, but I may at least give it a try.

@JasonGross
Copy link
Member Author

Can't you just move down the inclusion of

Oh, yeah, if there was no reason to have it be so early in the first place (e.g., overriding variables before the rest of the file processes them), then, yeah, let's just move it to the bottom of the file

@JasonGross
Copy link
Member Author

JasonGross commented Jun 24, 2020

Sorry for the late reply, I'm looking into this again now.

Note that moving it downwards breaks the use-case of overriding CAMLFLAGS (or OCAMLLIBS or COQSRCLIBS) and expecting CAMLDOCFLAGS to automatically pick up this change. We can either accept this cost, or I can replace all uses of $(CAMLFLAGS) with $(CAMLFLAGS) $(OCAMLWARN) and then change the := setting of CAMLDOCFLAGS to a =. What do you think should be done here?

JasonGross added a commit to JasonGross/coq that referenced this pull request Jun 24, 2020
As per coq#12411 (comment),
instead of using a local-late file, we just move the local file down.
This means that we need to replace all the relevant := assignments with
= so that users can still override variables, and this mandates that we
split up CAMLFLAGS.
@JasonGross
Copy link
Member Author

Okay, I've changed the := to =. I believe this is ready for review again.

@JasonGross JasonGross removed the needs: fixing The proposed code change is broken. label Jun 24, 2020
@JasonGross
Copy link
Member Author

@gares It seems that just moving the local file to the bottom breaks many of the variable overriding features, e.g., how Mtac2 overrides COQ_SRC_SUBDIRS. It's possible that by changing all the variable assignments from := to =, we could fix this, but I'm quite hesitant to rely on nuances in when make evaluates which variables. I'm inclined to stick with the simpler solution of having both files.

JasonGross added a commit to JasonGross/coq that referenced this pull request Jun 24, 2020
As per coq#12411 (comment),
instead of using a local-late file, we just move the local file down.
This means that we need to replace all the relevant := assignments with
= so that users can still override variables, and this mandates that we
split up CAMLFLAGS.
JasonGross added a commit to JasonGross/coq that referenced this pull request Jun 24, 2020
This reverts commit 8715429.

It actually breaks uses of variable overriding in the wild, as per
coq#12411 (comment)
JasonGross added a commit to JasonGross/coq that referenced this pull request Jun 24, 2020
As per coq#12411 (comment),
instead of using a local-late file, we just move the local file down.
This means that we need to replace all the relevant := assignments with
= so that users can still override variables, and this mandates that we
split up CAMLFLAGS.
JasonGross added a commit to JasonGross/coq that referenced this pull request Jun 24, 2020
This reverts commit 8715429.

It actually breaks uses of variable overriding in the wild, as per
coq#12411 (comment)
@gares
Copy link
Member

gares commented Jun 25, 2020

The variables one can override are documented. I don't recall that one to be documented as overrideable, and should not become so since it reflects Coq sources layout. Mtac2 should be fixed, IMO we should report a bug. Did you investigate the other failures?

@gares
Copy link
Member

gares commented Jun 25, 2020

CC @Janno @beta-ziliani : do you recall why you had to override that makefile variable?

@Janno
Copy link
Contributor

Janno commented Jun 25, 2020

CC @Janno @beta-ziliani : do you recall why you had to override that makefile variable?

It was introduced when porting to 8.8 in 677df93. We previously had
-I $(COQMF_COQLIB)/user-contrib/Unicoq as an alternative but I guess that broke with 8.8.

Then for a short while we didn't have COQ_SRC_SUBDIRS (Mtac2/Mtac2#127) but that broke Coq's windows builds so now we have it again.

@JasonGross
Copy link
Member Author

Did you investigate the other failures?

I did not, let me push another build so I can see the failures

@JasonGross
Copy link
Member Author

It seems that Mtac2 is the only failure. Regarding the Mtac2 failure, I found:

I'm much afraid that using $(shell ocamlfind printconf destdir) as a destination install seems broken and this is what broke the windows build.

As this is a coq_makefile project, you should integrate with where coq_makefile thinks the plugins should be going. For example, this patch will try to install in my root ~/.opam folder even if called with a coq_makefile coming from a ./configure -local Coq.

The problem is indeed not easy as coq_makefile lacks the proper integration with OCamlbuild to make this work. But given this approach seems broken I'd suggest to revert and instead move to a different build system if you need ocamlfind integration.

Originally posted by @ejgallego in unicoq/unicoq#17 (comment)

So indeed the issue here seems to be that coq_makefile doesn't have good enough support for this use case, which @vbgl describes in unicoq/unicoq#17:

To give some more context and motivation, I’d like to be able to install Unicoq and then use it as any third-party library. For instance, here is a patch to Mtac2 that shows that Unicoq can be used without hard-coding the path where it is installed nor repeating esoteric commands like “Declare ML Module "unicoq".”.

What should be done?

@SkySkimmer SkySkimmer added the needs: fixing The proposed code change is broken. label Jul 1, 2020
JasonGross added a commit to JasonGross/coq that referenced this pull request Apr 26, 2021
@JasonGross JasonGross requested a review from jfehrle April 26, 2021 12:54
Copy link
Member

@jfehrle jfehrle left a comment

Choose a reason for hiding this comment

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

The doc looks good. Nonetheless, a few more suggestions--I leave it up to you whether to include them.

doc/sphinx/practical-tools/utilities.rst Outdated Show resolved Hide resolved
doc/changelog/08-tools/12411-makefile-local-late.rst Outdated Show resolved Hide resolved
doc/sphinx/practical-tools/utilities.rst Outdated Show resolved Hide resolved
doc/sphinx/practical-tools/utilities.rst Outdated Show resolved Hide resolved
doc/sphinx/practical-tools/utilities.rst Outdated Show resolved Hide resolved
tools/CoqMakefile.in Outdated Show resolved Hide resolved
The optional file ``CoqMakefile.local-late`` is included at the end of the generated
file ``CoqMakefile``. The following is a partial list of accessible variables:

:COQ_VERSION:
Copy link
Member

@gares gares Apr 27, 2021

Choose a reason for hiding this comment

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

This variable is also available in the non -late file (I'm using it already). Please move it upward.
Ditto for COQMAKEFILE_VERSION, COQC and COQFLAGS and COQLIBS.

I did not check the others.

Copy link
Member Author

Choose a reason for hiding this comment

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

All variables are available for use in recipes of rules in the non-late file, as well as in the definitions of variables assigned using =. They are also available in the prerequisites of rules only if you double the $ and enable secondary expansion. However, these variables are not available when naming the outputs of rules, nor in top-level ifeq/ifneq statements, nor in variables assigned with :=. (I presume your use-cases involve the former kind and not the latter kind?) Do you have suggestions for making this distinction more clear in the documentation?

Copy link
Member

Choose a reason for hiding this comment

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

Indeed. I think it is fine, your explanation could also go in the doc, since the external pointer is a bit boring to follow.

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've added some explanation in the doc, please take a look

Copy link
Member

@gares gares left a comment

Choose a reason for hiding this comment

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

please move the non -late specific variable doc to the previous section

JasonGross added a commit to JasonGross/coq that referenced this pull request Apr 30, 2021
@JasonGross JasonGross force-pushed the makefile-local-late branch 2 times, most recently from d1de27a to d04da97 Compare April 30, 2021 15:43
@github-actions github-actions bot added the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label May 4, 2021
JasonGross added a commit to JasonGross/coq that referenced this pull request May 12, 2021
@coqbot-app coqbot-app bot removed the needs: rebase Should be rebased on the latest master to solve conflicts or have a newer CI run. label May 12, 2021
@JasonGross
Copy link
Member Author

Rebased. Is this ready for merge?

@gares
Copy link
Member

gares commented May 15, 2021

The test suite is broken

@JasonGross
Copy link
Member Author

No idea why the behavior changed, but I've updated the expected output.

JasonGross added a commit to JasonGross/coq that referenced this pull request May 15, 2021
As requested in PR comments

Change passive voice to active voice and fix a grammar error
As per coq#12411 (comment)

Add more documentation about Makefile var use

Also apply suggestions from code review

Co-authored-by: Jim Fehrle <jim.fehrle@gmail.com>
JasonGross added a commit to JasonGross/coq that referenced this pull request May 26, 2021
As requested in PR comments

Change passive voice to active voice and fix a grammar error
As per coq#12411 (comment)

Add more documentation about Makefile var use

Also apply suggestions from code review

Co-authored-by: Jim Fehrle <jim.fehrle@gmail.com>
JasonGross and others added 3 commits May 27, 2021 11:56
This allows users to write rules that depend on variables such as
VOFILES and VDFILE, which is essential in some of my use-cases (for
example, to properly handle seamless version switching, I need to make
all of the .vo files depend on a file where I record the version of Coq
being used).

Fixes coq#10912
As requested in PR comments

Change passive voice to active voice and fix a grammar error
As per coq#12411 (comment)

Add more documentation about Makefile var use

Also apply suggestions from code review

Co-authored-by: Jim Fehrle <jim.fehrle@gmail.com>
@JasonGross
Copy link
Member Author

CI Green, @gares I think this is finally ready for merge

@gares
Copy link
Member

gares commented May 27, 2021

@coqbot merge now

@coqbot-app coqbot-app bot merged commit b7d10ab into coq:master May 27, 2021
@JasonGross JasonGross deleted the makefile-local-late branch May 28, 2021 00:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: enhancement Enhancement to an existing user-facing feature, tactic, etc. kind: infrastructure CI, build tools, development tools. part: tools Coqdoc, coq_makefile, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

coq_makefile should include a user-defined file after all the definitions are given
6 participants