Skip to content

Get rid of the stdlib/Compflags script#8601

Merged
shindere merged 1 commit intoocaml:trunkfrom
shindere:remove-compflags-script
Apr 10, 2019
Merged

Get rid of the stdlib/Compflags script#8601
shindere merged 1 commit intoocaml:trunkfrom
shindere:remove-compflags-script

Conversation

@shindere
Copy link
Copy Markdown
Contributor

@shindere shindere commented Apr 9, 2019

this PR implements a suggestion by @xavierleroy.

The stdlib/Compflags script was used to provide module-specific
compiler flags. Now that we use GNU make, these flags can be
handled by make itslef.

It has been verified that the outputs of make world.opt before and
after this commit are equivalent. They are not identical, but their only
differences are aobut spacing and the fact that, before the commit,
the AWK variable was expanded by the subshell invoked bymake,
whereas after the commit, the variable is expanded by make itself.

Copy link
Copy Markdown
Member

@gasche gasche left a comment

Choose a reason for hiding this comment

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

It would be nice to have some explanation, in comments, of how the code work, so that people that are not experts in horrible GNU Make tricks have a chance of being able to locate this part of the logic and modify it if necessary. I feel like the shell script was approachable, but the new code less so.

(I expect the gains to be related to faster compilation due to reduced process forking, with possibly larger effects on Windows?)

stdlib/Makefile Outdated

stdlib__scanf.cmx: COMPFLAGS += -inline 9

%Labels.cmo: private COMPFLAGS += -nolabels -no-alias-deps
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what does private mean here and below?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it’s to replicate the behaviour of the case in the script - if you add a specific rule for one of these files, then this rule would no longer apply. I’m not sure why it’s on the next one, though, @shindere?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the pointer. Do you understand why it is used for %Labels.cmo but not for %Labels.cmx, and with the double-target rule below but not the double-target rule above? (Maybe we could consistently use private in all cases of this hidden pattern-matching for simplicity?)

@dra27
Copy link
Copy Markdown
Member

dra27 commented Apr 9, 2019

This is very nice! One thought, which might aid future debugging - perhaps the switches could be added to ADDCOMPFLAGS (or another name of that already exists) and COMPFLAGS remain untouched with ADDCOMPFLAGS being empty by default

@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Apr 9, 2019 via email

@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Apr 9, 2019 via email

@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Apr 9, 2019 via email

@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Apr 9, 2019 via email

@dra27
Copy link
Copy Markdown
Member

dra27 commented Apr 9, 2019

@shindere - the change would alter every deletion of $(shell ./Compflags $@) to $(ADDCOMPFLAGS) and otherwise only affect the added lines, adding one ADDCOMPFLAGS = line? It would also guard against anything external overriding of COMPFLAGS (I'm haven't checked thoroughly whether this is possible)

@dra27
Copy link
Copy Markdown
Member

dra27 commented Apr 9, 2019

@shindere - the other question was on what the private annotation was doing, which you've covered in answers to @gasche

@gasche
Copy link
Copy Markdown
Member

gasche commented Apr 9, 2019

I would really like to see this code (1) documented and (2) made consistent. If I can't understand what it does and how further changes to it should be written, it's reasonable to assume that many other contributors will be in the same situation. I am not in favor of a code that makes the build system harder to understand and evolve if the only benefit is "readability" as perceived by the three people in the project who know too much Make for their own good.

@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Apr 9, 2019 via email

@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Apr 9, 2019 via email

@shindere shindere force-pushed the remove-compflags-script branch from ed028b7 to baa785e Compare April 9, 2019 22:55
@gasche
Copy link
Copy Markdown
Member

gasche commented Apr 10, 2019

So, hy didn't you request this in runtime/Makefile which IMO is more complicated and (private put apart) also uses target-specific variables and even complex macro definitions?

This was an oversight on my part, please also document runtime/Makefile.

What do you mean by consistent?

I would appreciate if the story for where to put private was simpler than "this is what @shindere experimentally figured were the minimal additions" -- how can another user go extend that if they want to add a new case? If I understand what private is doing here (but I probably don't), it should be correct to put private in all the definitions; in that case I would be much in favor of doing that, as it gives a clear rationale that is easy to understand and follow.

This script was used to provide module-specific compiler flags.
Now that we use GNU make, these flags can be handled by make itslef.
@shindere shindere force-pushed the remove-compflags-script branch from baa785e to 40c88ee Compare April 10, 2019 08:08
@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Apr 10, 2019 via email

@gasche
Copy link
Copy Markdown
Member

gasche commented Apr 10, 2019

I can still consider documenting [asmrun/Makefile] in the future, but in my opinion this wouldn't fit in the present PR.

That's fine with me.

Please see the updated version. It also addresses @dra27's suggestion to have the module-specific flags in a dedicated variable, MODCOMPFLAGS.

Thanks! The new version looks nice indeed, and in particular I understand the explanation for the usage of private. (I also think that using a dedicated variable is nicer.)

@shindere
Copy link
Copy Markdown
Contributor Author

shindere commented Apr 10, 2019 via email

@shindere shindere merged commit 0dec0ce into ocaml:trunk Apr 10, 2019
@shindere shindere deleted the remove-compflags-script branch April 10, 2019 08:59
@shindere
Copy link
Copy Markdown
Contributor Author

Just pushed b29e897 to trunk to fix a typo.

But, unfortunately, that's not the end of the story: it seems "private"
is not understood by make 3.81 which is used on MacOS.

Working on an alternative version that does not need provate.

Will submit a new PR for that later today.

shindere added a commit that referenced this pull request Apr 11, 2019
@shindere
Copy link
Copy Markdown
Contributor Author

As a conclusion of the discussion that took place on #8608, this PR has
finally been reverrted in commits f7ba936
and 49ce3b0 because the solution proposed
in the present PR works only with GNU make newer than 3.82 while Mac OS X
still ships GNU make 3.81 and there is no solid way to achieve the same
result in a way compliant with GNU make 3.81, sadly.

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.

3 participants