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

Merge lex/Makefile into the root Makefile #11420

Merged
merged 7 commits into from
Sep 7, 2022

Conversation

shindere
Copy link
Contributor

@shindere shindere commented Jul 9, 2022

This continues the work started with e.g. #11248 and the yet unmerged #11268.

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.

This is all fine - the comments I have are mostly typos. -safe-string could possibly be removed in a separate PR.

There are two places where pattern rules could add flags - in the case of the toplevel rules, it's quite concise; for adding warning flags back to the lex/ modules it involves some duplication. However, I think your plan is to implement these differently, so those two suggestions are more for discussion as to whether your existing plan for the module-specific flags would cover those patterns?

Makefile Outdated
Comment on lines 1349 to 1361
COMPILE_NATIVE_TOPLEVEL_MODULE = \
$(COMPILE_NATIVE_MODULE) -I toplevel/native -c

toplevel/topdirs.cmx: toplevel/topdirs.ml
$(CAMLOPT_CMD) $(COMPFLAGS) $(OPTCOMPFLAGS) -I toplevel/native -c $<
$(COMPILE_NATIVE_TOPLEVEL_MODULE) $<

$(TOPLEVELINIT:.cmo=.cmx): $(TOPLEVELINIT:.cmo=.ml) \
toplevel/native/topeval.cmx
$(CAMLOPT_CMD) $(COMPFLAGS) $(OPTCOMPFLAGS) -I toplevel/native -c $<
$(COMPILE_NATIVE_TOPLEVEL_MODULE) $<

$(TOPLEVELSTART:.cmo=.cmx): $(TOPLEVELSTART:.cmo=.ml) \
toplevel/native/topmain.cmx
$(CAMLOPT_CMD) $(COMPFLAGS) $(OPTCOMPFLAGS) -I toplevel/native -c $<
$(COMPILE_NATIVE_TOPLEVEL_MODULE) $<
Copy link
Member

Choose a reason for hiding this comment

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

This could be done more concisely as:

toplevel/topdirs.cmx toplevel/toploop.cmx $(TOPLEVELSTART:.cmo=.cmx): \
  OC_NATIVE_CFLAGS+=-I toplevel/native

and then COMPILE_NATIVE_MODULE, COMPILE_NATIVE_TOPLEVEL_MODULE and TOPLEVELINIT could all be removed

Comment on lines 78 to 79
# is for private variables (i.e. reseverd by the compiler's build system),
# the OCAML prefix is used for variables user can define to add their
Copy link
Member

Choose a reason for hiding this comment

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

Two typos: reserved and "the user can define"

Comment on lines 87 to 90
# ZZZ is either CFLAGS (compile-tme flags) or LDFLAGS (link-time flags).
# However, countrary to what is done for C compilers, the flags in the
# CFLAGS category are not passed at link time, so if a flag is needed
# at both stages, like e.e. -g, it should be added to both XXX_YYY_CFLAGS and
Copy link
Member

Choose a reason for hiding this comment

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

Three typos: compile-time, contrary and e.g.


OC_COMMON_CFLAGS = -g -strict-sequence -principal -absname \
-w +a-4-9-40-41-42-44-45-48-66 -warn-error +a -bin-annot \
-safe-string -strict-formats
Copy link
Member

Choose a reason for hiding this comment

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

FWIW we could use this opportunity to remove -safe-string, as it's only there for compatibility.

Makefile Outdated
@@ -1072,18 +1070,39 @@ libraryopt:
partialclean::
$(MAKE) -C stdlib clean

# The lexer and parser generators
# The lexer generators
Copy link
Member

Choose a reason for hiding this comment

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

Typo: generator


ocamllex_MODULES = $(addprefix lex/,\
cset syntax parser lexer table lexgen compact common output outputbis main)

Copy link
Member

Choose a reason for hiding this comment

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

At this point, the additional warnings disabled by the merge could be re-enabled with:

lex/%.cmo: OC_COMMON_CFLAGS+=-w +40+41+66
lex/%.cmi: OC_COMMON_CFLAGS+=-w +40+41+66
lex/%.cmx: OC_COMMON_CFLAGS+=-w +40+41+66

@xavierleroy
Copy link
Contributor

If it was not for pesky bootstrapping questions, ocamllex could be an independent program, separate from the core distribution. For this reason, I think it deserves its own makefile. Doing otherwise will make it harder to separate ocamllex from the core distribution if we decide to do this in the future.

@shindere shindere force-pushed the merge-lex-makefile branch 3 times, most recently from 4648176 to cdbb140 Compare August 2, 2022 15:00
@shindere shindere force-pushed the merge-lex-makefile branch 2 times, most recently from 043ebcc to e392d56 Compare August 23, 2022 12:30
@shindere
Copy link
Contributor Author

shindere commented Aug 23, 2022 via email

@shindere shindere force-pushed the merge-lex-makefile branch 6 times, most recently from d3d47d3 to 9e03e3a Compare August 24, 2022 18:46
@shindere
Copy link
Contributor Author

All checks have passed, so this should be ready for a hopefully final
review, @dra27.

Many thanks for your support, in any case.

This commit introduces a set of build variables that will be used to
define which compiler flags to use to build the compiler.

At this stage, the framework is used only in the root Makefile
so it does only define the variables required by this root Makefile.

The framework will be extended as required to take into account
the different sub-makefiles as they get merged into the root one.

The build variables are defined in Makefile.build_config.in rather than in
Makefile.common so that the flags can, if necessary, be controlled
by the configure script (see for instance OC_NATIVE_CFLAGS).
…e flag)

When building the bytecode version of ocamllex, the -strict-sequence flag
was passed twice. This commit removes one of its occurrences.
Make sure ocamlyacc is always called with -v and --strict.

Before this commit, the parsers of the debugger and of ocamltest
were not generated using these options.
The changes are:
- The -principal flag has been added
- Warning 41 is enabled and causes no error

The files compiled from the root Makefile have more warnings disabled than
those compiled with lex/Makefile but this is not a problem.
@shindere shindere force-pushed the merge-lex-makefile branch from 9e03e3a to 4941085 Compare August 25, 2022 08:27
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.

I put this through precheck#760 just before the weekend because, well, build system.

This is good to go from my perspective. Given that lex/Makefile is already not standalone1, I'm not sure that it's made accurately extracting it in future any harder (indeed, perhaps by looking less trivial, it might avoid missing subtle changes like ocaml/num#19).

Footnotes

  1. It pulls in Makefile.common, and therefore the whole of the configuration infrastructure

@dra27 dra27 mentioned this pull request Oct 3, 2022
@shindere
Copy link
Contributor Author

shindere commented Oct 11, 2022 via email

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